diff --git a/coffee-shop-kata-solutions/pom.xml b/coffee-shop-kata-solutions/pom.xml index 28dd4062..07c0fe75 100644 --- a/coffee-shop-kata-solutions/pom.xml +++ b/coffee-shop-kata-solutions/pom.xml @@ -53,6 +53,11 @@ org.junit.jupiter junit-jupiter + + org.assertj + assertj-core + 3.24.2 + diff --git a/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index 55d36b28..e19e3184 100644 --- a/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata-solutions/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -52,8 +52,8 @@ public CoffeeShopOrder(String customerName, List orderItems) * Return a list of custom strings for the customer's food items! * The string format for each food item is as follows: * If the item is a Bagel: "[bagelType] with [spreadType]" - * If the item is a Cookie: "[cookieType]" - * If the item is a Donut: "[donutType]" + * If the item is a Cookie: "[cookieType] cookie" + * If the item is a Donut: "[donutType] donut" * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. diff --git a/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java index 24a16a2a..c114ee40 100644 --- a/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata-solutions/src/test/java/bnymellon/codekata/coffeeshopkata/CoffeeShopTest.java @@ -34,6 +34,7 @@ import static bnymellon.codekatas.coffeeshopkata.food.CookieType.CHOCOLATE_CHIP; import static bnymellon.codekatas.coffeeshopkata.food.DonutType.GLAZED; import static bnymellon.codekatas.coffeeshopkata.food.SpreadType.HERB_GARLIC_CREAM_CHEESE; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -59,9 +60,8 @@ public void setUp() @Test public void getFoodItemsForOrderTest() { - List expected = List.of("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", - "CHOCOLATE_CHIP cookie", "GLAZED donut"); - assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder()); + List expected = List.of("CHOCOLATE_CHIP cookie", "EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", "GLAZED donut"); + assertThat(coffeeShopOrder.getFoodItemsForOrder()).hasSameElementsAs(expected); } @Test diff --git a/coffee-shop-kata/jdk21/pom.xml b/coffee-shop-kata/jdk21/pom.xml index e99dbc34..367bf4de 100644 --- a/coffee-shop-kata/jdk21/pom.xml +++ b/coffee-shop-kata/jdk21/pom.xml @@ -51,6 +51,11 @@ org.junit.jupiter junit-jupiter + + org.assertj + assertj-core + 3.24.2 + diff --git a/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index 36053ab3..938760e8 100644 --- a/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata/jdk21/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -34,8 +34,8 @@ public CoffeeShopOrder(String customerName, List orderItems) * Return a list of custom strings for the customer's food items! * The string format for each food item is as follows: * If the item is a Bagel: "[bagelType] with [spreadType]" - * If the item is a Cookie: "[cookieType]" - * If the item is a Donut: "[donutType]" + * If the item is a Cookie: "[cookieType] cookie" + * If the item is a Donut: "[donutType] donut" * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. diff --git a/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java index 37de0cd4..6dbfa4d5 100644 --- a/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata/jdk21/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java @@ -33,6 +33,7 @@ import static bnymellon.codekatas.coffeeshopkata.food.CookieType.CHOCOLATE_CHIP; import static bnymellon.codekatas.coffeeshopkata.food.DonutType.GLAZED; import static bnymellon.codekatas.coffeeshopkata.food.SpreadType.HERB_GARLIC_CREAM_CHEESE; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -62,9 +63,8 @@ public void setUp() public void getFoodItemsForOrderTest() { // TODO: Complete the method getFoodItemsForOrder() in CoffeeShopOrder to make this pass - List expected = List.of("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", - "CHOCOLATE_CHIP cookie", "GLAZED donut"); - assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder()); + List expected = List.of("CHOCOLATE_CHIP cookie", "EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", "GLAZED donut"); + assertThat(coffeeShopOrder.getFoodItemsForOrder()).hasSameElementsAs(expected); } @Test diff --git a/coffee-shop-kata/jdk8/pom.xml b/coffee-shop-kata/jdk8/pom.xml index 67671795..98632dae 100644 --- a/coffee-shop-kata/jdk8/pom.xml +++ b/coffee-shop-kata/jdk8/pom.xml @@ -42,6 +42,11 @@ ${junit5.version} test + + org.assertj + assertj-core + 3.24.2 + diff --git a/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java b/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java index e9ba220d..30e03da0 100644 --- a/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java +++ b/coffee-shop-kata/jdk8/src/main/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopOrder.java @@ -50,8 +50,8 @@ public CoffeeShopOrder(String customerName, java.util.List orderItems) * Return a list of custom strings for the customer's food items! * The string format for each food item is as follows: * If the item is a Bagel: "[bagelType] with [spreadType]" - * If the item is a Cookie: "[cookieType]" - * If the item is a Donut: "[donutType]" + * If the item is a Cookie: "[cookieType] cookie" + * If the item is a Donut: "[donutType] donut" * Otherwise: throw new IllegalStateException() *

* NOTE: This method show-cases a switch-case pattern matching. diff --git a/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java b/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java index 434643aa..fadd3c8d 100644 --- a/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java +++ b/coffee-shop-kata/jdk8/src/test/java/bnymellon/codekatas/coffeeshopkata/CoffeeShopTest.java @@ -28,6 +28,7 @@ import static bnymellon.codekatas.coffeeshopkata.food.CookieType.CHOCOLATE_CHIP; import static bnymellon.codekatas.coffeeshopkata.food.DonutType.GLAZED; import static bnymellon.codekatas.coffeeshopkata.food.SpreadType.HERB_GARLIC_CREAM_CHEESE; +import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -56,10 +57,10 @@ public void setUp() public void getFoodItemsForOrderTest() { ArrayList expected = new ArrayList<>(); - expected.add("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE"); expected.add("CHOCOLATE_CHIP cookie"); + expected.add("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE"); expected.add("GLAZED donut"); - assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder()); + assertThat(coffeeShopOrder.getFoodItemsForOrder()).hasSameElementsAs(expected); } @Test