diff --git a/java/TODO.md b/java/TODO.md index aec0c21..7ac3e18 100644 --- a/java/TODO.md +++ b/java/TODO.md @@ -4,7 +4,7 @@ We will be using the mikado method to incrementally create the test data builder pattern for the Invoice class. Indentation represents dependencies, and should be done first -- [ ] Add a test to highlight the issue in Invoice, using the test data builder pattern +- [x] Add a test to highlight the issue in Invoice, using the test data builder pattern - [x] Create a test data builder for the Invoice class - [x] Create a test data builder for the PurchaseBook class - [x] Create a test data builder for the Novel class diff --git a/java/src/test/java/com/murex/tbw/purchase/InvoiceTest.java b/java/src/test/java/com/murex/tbw/purchase/InvoiceTest.java index 73ee0a9..0495399 100644 --- a/java/src/test/java/com/murex/tbw/purchase/InvoiceTest.java +++ b/java/src/test/java/com/murex/tbw/purchase/InvoiceTest.java @@ -1,9 +1,12 @@ package com.murex.tbw.purchase; +import com.murex.tbw.domain.country.TestCountries; import org.junit.jupiter.api.Test; import static com.murex.tbw.domain.book.NovelTestDataBuilder.aNovel; +import static com.murex.tbw.purchase.InvoiceTestDataBuilder.anInvoice; import static com.murex.tbw.purchase.PurchasedBookTestDataBuilder.aPurchase; +import static org.junit.jupiter.api.Assertions.assertEquals; class InvoiceTest { @Test @@ -32,17 +35,11 @@ void Mikado_Method_Constraint_Applies_tax_rules_when_computing_total_amount() { @Test void Mikado_Method_And_Test_Data_Builders_Constraint_Applies_tax_rules_when_computing_total_amount() { // Using the Mikado method and the Test Data Builder pattern: - // Instantiate an Invoice sent to USA -// InvoiceBuilder.anInvoice() -// .sentTo("USA") -// .withItem(aNovel() -// .costing(50)) -// .build(); - - aPurchase().of(aNovel().costing(50)).quantity(1).build(); + Invoice invoice = anInvoice().sentTo(TestCountries.USA) + .with(aPurchase().of(aNovel().costing(50))).build(); - // Add it a purchased novel costing 50 // Assert the total amount of the invoice is 56,35 : 15% of taxes plus a 2% reduction on novels + assertEquals(56.35, invoice.computeTotalAmount()); } }