Skip to content

Commit

Permalink
Change food items list test to ignore order
Browse files Browse the repository at this point in the history
Signed-off-by: Emilie <emilie.robichaud@bnymellon.com>
  • Loading branch information
emilie-robichaud committed Sep 18, 2023
1 parent 6ff1649 commit a881857
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 14 deletions.
5 changes: 5 additions & 0 deletions coffee-shop-kata-solutions/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public CoffeeShopOrder(String customerName, List<Item> 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()
* <p>
* NOTE: This method show-cases a switch-case pattern matching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -59,9 +60,8 @@ public void setUp()
@Test
public void getFoodItemsForOrderTest()
{
List<String> expected = List.of("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE",
"CHOCOLATE_CHIP cookie", "GLAZED donut");
assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder());
List<String> expected = List.of("CHOCOLATE_CHIP cookie", "EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", "GLAZED donut");
assertThat(coffeeShopOrder.getFoodItemsForOrder()).hasSameElementsAs(expected);
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions coffee-shop-kata/jdk21/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public CoffeeShopOrder(String customerName, List<Item> 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()
* <p>
* NOTE: This method show-cases a switch-case pattern matching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -62,9 +63,8 @@ public void setUp()
public void getFoodItemsForOrderTest()
{
// TODO: Complete the method getFoodItemsForOrder() in CoffeeShopOrder to make this pass
List<String> expected = List.of("EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE",
"CHOCOLATE_CHIP cookie", "GLAZED donut");
assertEquals(expected, coffeeShopOrder.getFoodItemsForOrder());
List<String> expected = List.of("CHOCOLATE_CHIP cookie", "EVERYTHING bagel with HERB_GARLIC_CREAM_CHEESE", "GLAZED donut");
assertThat(coffeeShopOrder.getFoodItemsForOrder()).hasSameElementsAs(expected);
}

@Test
Expand Down
5 changes: 5 additions & 0 deletions coffee-shop-kata/jdk8/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.24.2</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public CoffeeShopOrder(String customerName, java.util.List<Item> 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()
* <p>
* NOTE: This method show-cases a switch-case pattern matching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -56,10 +57,10 @@ public void setUp()
public void getFoodItemsForOrderTest()
{
ArrayList<String> 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
Expand Down

0 comments on commit a881857

Please sign in to comment.