Skip to content

Commit 8fdd33e

Browse files
committed
[java][booking][02_parameter_object] Introduce Tax parameter object
1 parent c02aedb commit 8fdd33e

File tree

3 files changed

+25
-10
lines changed

3 files changed

+25
-10
lines changed

examples/java/java-booking-02_introduce_parameter_object/src/main/java/tv/codely/booking/Booking.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public Booking(
2121
Customer customer,
2222
BookingType bookingType,
2323
Discount discount,
24-
TaxType taxType,
25-
TaxValue taxValue
24+
Tax tax
2625
) {
2726
this.id = id;
2827
this.startDate = bookingDateRange.startDate();
@@ -33,8 +32,8 @@ public Booking(
3332
this.bookingType = bookingType;
3433
this.discountType = discount.type();
3534
this.discountValue = discount.value();
36-
this.taxType = taxType;
37-
this.taxValue = taxValue;
35+
this.taxType = tax.type();
36+
this.taxValue = tax.value();
3837
}
3938

4039
public BookingStatus statusFor(LocalDateTime date) {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package tv.codely.booking;
2+
3+
public final class Tax {
4+
private final TaxType type;
5+
private final TaxValue value;
6+
7+
public Tax(TaxType type, TaxValue value) {
8+
this.type = type;
9+
this.value = value;
10+
}
11+
12+
public TaxType type() {
13+
return type;
14+
}
15+
16+
public TaxValue value() {
17+
return value;
18+
}
19+
}

examples/java/java-booking-02_introduce_parameter_object/src/test/java/tv/codely/booking/BookingShould.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ void get_the_correct_status_when_the_booking_has_not_started_yet() {
2424
),
2525
BookingType.VACATION,
2626
new Discount(DiscountType.NONE, new DiscountValue(0)),
27-
TaxType.NONE,
28-
new TaxValue(0)
27+
new Tax(TaxType.NONE, new TaxValue(0))
2928
);
3029

3130
assertEquals(BookingStatus.NOT_STARTED, booking.statusFor(dateBeforeBookingHasStarted));
@@ -48,8 +47,7 @@ void get_the_correct_status_when_the_booking_is_currently_active() {
4847
),
4948
BookingType.VACATION,
5049
new Discount(DiscountType.NONE, new DiscountValue(0)),
51-
TaxType.NONE,
52-
new TaxValue(0)
50+
new Tax(TaxType.NONE, new TaxValue(0))
5351
);
5452

5553
assertEquals(BookingStatus.ACTIVE, booking.statusFor(dateBetweenBooking));
@@ -72,8 +70,7 @@ void get_the_correct_status_when_the_booking_is_finished() {
7270
),
7371
BookingType.VACATION,
7472
new Discount(DiscountType.NONE, new DiscountValue(0)),
75-
TaxType.NONE,
76-
new TaxValue(0)
73+
new Tax(TaxType.NONE, new TaxValue(0))
7774
);
7875

7976
assertEquals(BookingStatus.FINISHED, booking.statusFor(dateAfterBookingEnds));

0 commit comments

Comments
 (0)