From 863fd6486e995b45ba1a1b00be8ee3e93d2f9ef8 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 13:33:57 +0200 Subject: [PATCH 01/11] Domain model finished --- domain-model.md | 70 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 domain-model.md diff --git a/domain-model.md b/domain-model.md new file mode 100644 index 00000000..39d52f6a --- /dev/null +++ b/domain-model.md @@ -0,0 +1,70 @@ +# Domain model + +## User stories +### User story 1 +``` +As a member of the public, +So I can order a bagel before work, +I'd like to add a specific type of bagel to my basket. +``` + +### User story 2 +``` +As a member of the public, +So I can change my order, +I'd like to remove a bagel from my basket. +``` + +### User story 3 +``` +As a member of the public, +So that I can not overfill my small bagel basket +I'd like to know when my basket is full when I try adding an item beyond my basket capacity. +``` + +### User story 4 +``` +As a Bob's Bagels manager, +So that I can expand my business, +I’d like to change the capacity of baskets. +``` + +### User story 5 +``` +As a member of the public +So that I can maintain my sanity +I'd like to know if I try to remove an item that doesn't exist in my basket. +``` + + +## Shopping Basket Class + +### Variables +| Variables | Description | +|--------------------------|----------------------------------------------------------------------| +| List basket | Container containing the bagels the customer has added to basket. | +| Integer basketSize | Size of the basket. | + +### Bagel Enum +| Bagel | Description | +|----------|-------------------| +| plain | Plain bagel | +| cheese | Bagle with cheese | +| honey | Bagle with honey | +| frosting | Bagle with frosting | + +### Methods +| Methods | Scenario | Outputs | +|-------------------------------------------------------------|------------------------------------------------------------------|--------------------------------------------| +| `Boolean addBagel(Basket basket.bagle)` | Customer successfully adds bagel to basket | Return true | +| | Customer fails to add bagel to basket | Return false | +| `String removeBagel(Basket basket.bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | +| | Customer tries to remove bagel not in the basket from the basket | `Error: This bagel is not in your basket.` | +| `Boolean basketIsFull(Basket basket, int basketSize)` | Basket is full | Return true | +| | Basket is not full | Return false | +| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return true | +| | Manager fails in changing the capacity of the basket | Return false | +| `Boolean bagleInBasket(Basket basket.bagle, Basket basket)` | Specific bagle is in basket | Return true | +| | Specific bagle is not in basket | Return false + + From b5d8322de76491754057126f0d4a06ebddf221f9 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 13:42:27 +0200 Subject: [PATCH 02/11] Simplified domain model --- domain-model.md | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/domain-model.md b/domain-model.md index 39d52f6a..5c4709b2 100644 --- a/domain-model.md +++ b/domain-model.md @@ -45,26 +45,13 @@ I'd like to know if I try to remove an item that doesn't exist in my basket. | List basket | Container containing the bagels the customer has added to basket. | | Integer basketSize | Size of the basket. | -### Bagel Enum -| Bagel | Description | -|----------|-------------------| -| plain | Plain bagel | -| cheese | Bagle with cheese | -| honey | Bagle with honey | -| frosting | Bagle with frosting | - ### Methods -| Methods | Scenario | Outputs | -|-------------------------------------------------------------|------------------------------------------------------------------|--------------------------------------------| -| `Boolean addBagel(Basket basket.bagle)` | Customer successfully adds bagel to basket | Return true | -| | Customer fails to add bagel to basket | Return false | -| `String removeBagel(Basket basket.bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | -| | Customer tries to remove bagel not in the basket from the basket | `Error: This bagel is not in your basket.` | -| `Boolean basketIsFull(Basket basket, int basketSize)` | Basket is full | Return true | -| | Basket is not full | Return false | -| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return true | -| | Manager fails in changing the capacity of the basket | Return false | -| `Boolean bagleInBasket(Basket basket.bagle, Basket basket)` | Specific bagle is in basket | Return true | -| | Specific bagle is not in basket | Return false - +| Methods | Scenario | Outputs | +|-------------------------------------------------------|------------------------------------------------------------------|-------------------------------------------| +| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | +| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | +| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | +| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | +| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return trueg | +| | Manager fails in changing the capacity of the basket | Return false | From 9d333300de46f100b69a48d77d497a6edc78b85c Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 13:57:11 +0200 Subject: [PATCH 03/11] Minor cleanup in domain model. Added first test. --- domain-model.md | 24 ++++----- .../java/com/booleanuk/core/BasketTest.java | 49 +++++++++++++++++++ 2 files changed, 61 insertions(+), 12 deletions(-) diff --git a/domain-model.md b/domain-model.md index 5c4709b2..990ea640 100644 --- a/domain-model.md +++ b/domain-model.md @@ -40,18 +40,18 @@ I'd like to know if I try to remove an item that doesn't exist in my basket. ## Shopping Basket Class ### Variables -| Variables | Description | -|--------------------------|----------------------------------------------------------------------| -| List basket | Container containing the bagels the customer has added to basket. | -| Integer basketSize | Size of the basket. | +| Variables | Description | +|-----------------------------|----------------------------------------------------------------------| +| `List basket` | Container containing the bagels the customer has added to basket. | +| `Integer basketSize` | Size of the basket. | ### Methods -| Methods | Scenario | Outputs | -|-------------------------------------------------------|------------------------------------------------------------------|-------------------------------------------| -| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | -| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | -| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | -| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | -| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return trueg | -| | Manager fails in changing the capacity of the basket | Return false | +| Methods | Scenario | Outputs | +|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------| +| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | +| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | +| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | +| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | +| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return true | +| | Manager fails in changing the capacity of the basket | Return false | diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index e35771b3..4ab1504d 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -4,5 +4,54 @@ import org.junit.jupiter.api.Test; class BasketTest { + @Test + public void addBagelTest(){ + Basket b = new Basket(); + String expectedSuccess = "Bagel added successfully."; + String expectedFail = "Basket is full."; + + String testSuccess = b.addBagel("Cream"); + String testFail = b.addBagel("Cream"); + + Assertions.assertEquals(expectedSuccess, testSuccess); + Assertions.assertEquals(expectedFail, testFail); + } } + +/* +### User story 1 +``` +As a member of the public, +So I can order a bagel before work, +I'd like to add a specific type of bagel to my basket. +``` + +### User story 2 +``` +As a member of the public, +So I can change my order, +I'd like to remove a bagel from my basket. +``` + +### User story 3 +``` +As a member of the public, +So that I can not overfill my small bagel basket +I'd like to know when my basket is full when I try adding an item beyond my basket capacity. +``` + +### User story 4 +``` +As a Bob's Bagels manager, +So that I can expand my business, +I’d like to change the capacity of baskets. +``` + +### User story 5 +``` +As a member of the public +So that I can maintain my sanity +I'd like to know if I try to remove an item that doesn't exist in my basket. +``` + */ \ No newline at end of file From 9903c8185145b68f95015a2d8a1dffe3e8a3807a Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:03:52 +0200 Subject: [PATCH 04/11] Adjustments to first test case --- src/test/java/com/booleanuk/core/BasketTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 4ab1504d..8b1ec4a0 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -7,12 +7,13 @@ class BasketTest { @Test public void addBagelTest(){ Basket b = new Basket(); + basket.basketSize = 1; String expectedSuccess = "Bagel added successfully."; String expectedFail = "Basket is full."; String testSuccess = b.addBagel("Cream"); - String testFail = b.addBagel("Cream"); + String testFail = b.addBagel("Chocolate"); Assertions.assertEquals(expectedSuccess, testSuccess); Assertions.assertEquals(expectedFail, testFail); From 385fc90f3bd1014e4c5b67141539e5a99f452686 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:05:28 +0200 Subject: [PATCH 05/11] Even more adjustments to first test case --- src/test/java/com/booleanuk/core/BasketTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 8b1ec4a0..552092bf 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -7,7 +7,7 @@ class BasketTest { @Test public void addBagelTest(){ Basket b = new Basket(); - basket.basketSize = 1; + b.basketSize = 1; String expectedSuccess = "Bagel added successfully."; String expectedFail = "Basket is full."; From 735b0069294a11360181a7a4595021a15cf774b5 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:07:32 +0200 Subject: [PATCH 06/11] Implemented addBagel function, and passed testing. --- src/main/java/com/booleanuk/core/Basket.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main/java/com/booleanuk/core/Basket.java b/src/main/java/com/booleanuk/core/Basket.java index df7a20aa..28a3b519 100644 --- a/src/main/java/com/booleanuk/core/Basket.java +++ b/src/main/java/com/booleanuk/core/Basket.java @@ -1,5 +1,17 @@ package com.booleanuk.core; +import java.util.ArrayList; + public class Basket { + ArrayList basket = new ArrayList<>(); + Integer basketSize = 1; + + public String addBagel(String bagel){ + + if (basket.size() >= this.basketSize) + return "Basket is full."; + basket.add(bagel); + return "Bagel added successfully."; + } } From abb34f55979e3d806637380284dc1d40b26c6d21 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:14:38 +0200 Subject: [PATCH 07/11] Added second test containing tests for user story 2 and 5. For reference first test contains tests for user story 1 and 3. --- .../java/com/booleanuk/core/BasketTest.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 552092bf..7aac241c 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -18,15 +18,27 @@ public void addBagelTest(){ Assertions.assertEquals(expectedSuccess, testSuccess); Assertions.assertEquals(expectedFail, testFail); } + + @Test + public void removeBagelTest(){ + Basket b = new Basket(); + + b.addBagel("Chocolate"); + + String expectedSuccess = "Bagel successfully removed from basket."; + String expectedFail = "This bagel is not in your basket."; + + String testSuccess = b.removeBagel("Chocolate"); + String testFail = b.removeBagel("Cream"); + + Assertions.assertEquals(expectedSuccess, testSuccess); + Assertions.assertEquals(expectedFail, testFail); + } } + /* -### User story 1 -``` -As a member of the public, -So I can order a bagel before work, -I'd like to add a specific type of bagel to my basket. -``` + ### User story 2 ``` From 3d22f1a6cbaba286c0572d047b620e8dc72c423a Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:33:06 +0200 Subject: [PATCH 08/11] Finished final test --- src/main/java/com/booleanuk/core/Basket.java | 14 +++++ .../java/com/booleanuk/core/BasketTest.java | 59 +++++++++---------- 2 files changed, 41 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Basket.java b/src/main/java/com/booleanuk/core/Basket.java index 28a3b519..42932022 100644 --- a/src/main/java/com/booleanuk/core/Basket.java +++ b/src/main/java/com/booleanuk/core/Basket.java @@ -14,4 +14,18 @@ public String addBagel(String bagel){ basket.add(bagel); return "Bagel added successfully."; } + + public String removeBagel(String bagel){ + + if (!basket.contains(bagel)){ + return "This bagel is not in your basket."; + } + + basket.remove(bagel); + return "Bagel successfully removed from basket."; + } + + } + + diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 7aac241c..29376a63 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -34,37 +34,32 @@ public void removeBagelTest(){ Assertions.assertEquals(expectedSuccess, testSuccess); Assertions.assertEquals(expectedFail, testFail); } -} + @Test + public void changeBasketCapacityTest(){ + Basket b = new Basket(); + b.basketSize = 1; + + String basketIsNotFull = "Bagel added successfully."; + String basketIsFull = "Basket is full."; + + // Triggers basket is full error + b.addBagel("Cheese"); + String failString = b.addBagel("Chocolate"); -/* - - -### User story 2 -``` -As a member of the public, -So I can change my order, -I'd like to remove a bagel from my basket. -``` - -### User story 3 -``` -As a member of the public, -So that I can not overfill my small bagel basket -I'd like to know when my basket is full when I try adding an item beyond my basket capacity. -``` - -### User story 4 -``` -As a Bob's Bagels manager, -So that I can expand my business, -I’d like to change the capacity of baskets. -``` - -### User story 5 -``` -As a member of the public -So that I can maintain my sanity -I'd like to know if I try to remove an item that doesn't exist in my basket. -``` - */ \ No newline at end of file + // Verifies basket is full error + Assertions.assertEquals(basketIsFull, failString); + + // Changes capacity of basketCapacity and verifies equality + int newBasketCapacity = 2; + b.changeBasketCapacity(newBasketCapacity); + Assertions.assertEquals(newBasketCapacity, b.basketSize); + + // Repeat first test to demonstrate that the basket has increased + String successString = b.addBagel("Chocolate"); + Assertions.assertEquals(basketIsNotFull, successString); + + // Test to see if function returns true + Assertions.assertTrue(b.changeBasketCapacity(3)); + } +} From fcde2a6a77442d76f0a10dc5e89cb3f5548a3c53 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:42:00 +0200 Subject: [PATCH 09/11] Minor adjustments to domain model. Changed changeBasketCapacity return type to void. --- domain-model.md | 15 +++++++-------- src/test/java/com/booleanuk/core/BasketTest.java | 3 --- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/domain-model.md b/domain-model.md index 990ea640..f6b0ce2e 100644 --- a/domain-model.md +++ b/domain-model.md @@ -46,12 +46,11 @@ I'd like to know if I try to remove an item that doesn't exist in my basket. | `Integer basketSize` | Size of the basket. | ### Methods -| Methods | Scenario | Outputs | -|-------------------------------------------------|------------------------------------------------------------------|-------------------------------------------| -| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | -| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | -| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | -| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | -| `Boolean changeBasketCapacity(int newCapacity)` | Manager successfully changes the capacity of the basket | Return true | -| | Manager fails in changing the capacity of the basket | Return false | +| Methods | Scenario | Outputs | +|----------------------------------------------|-----------------------------------------------------------------|-------------------------------------------| +| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | +| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | +| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | +| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | +| `Void changeBasketCapacity(int newCapacity)` | Manager changes the capacity of the basket | - | diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 29376a63..0948d2f7 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -58,8 +58,5 @@ public void changeBasketCapacityTest(){ // Repeat first test to demonstrate that the basket has increased String successString = b.addBagel("Chocolate"); Assertions.assertEquals(basketIsNotFull, successString); - - // Test to see if function returns true - Assertions.assertTrue(b.changeBasketCapacity(3)); } } From 8dea8feaf04376d1dcafe7b24fe821a0d7d2e303 Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:43:39 +0200 Subject: [PATCH 10/11] Implemented changeBasketCapacity function, and passed tests. --- src/main/java/com/booleanuk/core/Basket.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/booleanuk/core/Basket.java b/src/main/java/com/booleanuk/core/Basket.java index 42932022..cdb3211a 100644 --- a/src/main/java/com/booleanuk/core/Basket.java +++ b/src/main/java/com/booleanuk/core/Basket.java @@ -6,7 +6,7 @@ public class Basket { ArrayList basket = new ArrayList<>(); Integer basketSize = 1; - public String addBagel(String bagel){ + public String addBagel(String bagel) { if (basket.size() >= this.basketSize) return "Basket is full."; @@ -15,9 +15,9 @@ public String addBagel(String bagel){ return "Bagel added successfully."; } - public String removeBagel(String bagel){ + public String removeBagel(String bagel) { - if (!basket.contains(bagel)){ + if (!basket.contains(bagel)) { return "This bagel is not in your basket."; } @@ -25,7 +25,8 @@ public String removeBagel(String bagel){ return "Bagel successfully removed from basket."; } - + public void changeBasketCapacity(Integer newBasketCapacity) { + this.basketSize = newBasketCapacity; + } } - From 6fc68a098f3a130efe5072ae26c3a8a9cf08ea7b Mon Sep 17 00:00:00 2001 From: Thomas Wiik Date: Wed, 14 Aug 2024 14:49:27 +0200 Subject: [PATCH 11/11] Added comments in tests. Changed function and variable names related to basket size from basketCapacity to basketSize for consistency. Minor adjustment to addBagel function changing >= to = --- domain-model.md | 14 +++++++------- src/main/java/com/booleanuk/core/Basket.java | 7 ++++--- src/test/java/com/booleanuk/core/BasketTest.java | 15 +++++++++------ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/domain-model.md b/domain-model.md index f6b0ce2e..c2fe76cf 100644 --- a/domain-model.md +++ b/domain-model.md @@ -46,11 +46,11 @@ I'd like to know if I try to remove an item that doesn't exist in my basket. | `Integer basketSize` | Size of the basket. | ### Methods -| Methods | Scenario | Outputs | -|----------------------------------------------|-----------------------------------------------------------------|-------------------------------------------| -| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | -| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | -| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | -| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | -| `Void changeBasketCapacity(int newCapacity)` | Manager changes the capacity of the basket | - | +| Methods | Scenario | Outputs | +|--------------------------------------|------------------------------------------------------------------|-------------------------------------------| +| `String addBagel(String bagle)` | Customer successfully adds bagel to basket | `Bagel added successfully.` | +| | Customer fails to add bagel to basket as basket is full | `Basket is full.` | +| `String removeBagel(String bagle)` | Customer successfully removes bagel from basket | `Bagel successfully removed from basket.` | +| | Customer tries to remove bagel not in the basket from the basket | `This bagel is not in your basket.` | +| `Void changeBasketSize(int newSize)` | Manager changes the size of the basket | - | diff --git a/src/main/java/com/booleanuk/core/Basket.java b/src/main/java/com/booleanuk/core/Basket.java index cdb3211a..2590f421 100644 --- a/src/main/java/com/booleanuk/core/Basket.java +++ b/src/main/java/com/booleanuk/core/Basket.java @@ -8,7 +8,8 @@ public class Basket { public String addBagel(String bagel) { - if (basket.size() >= this.basketSize) + // If the size of the basket is equal to or larger + if (basket.size() == this.basketSize) return "Basket is full."; basket.add(bagel); @@ -25,8 +26,8 @@ public String removeBagel(String bagel) { return "Bagel successfully removed from basket."; } - public void changeBasketCapacity(Integer newBasketCapacity) { - this.basketSize = newBasketCapacity; + public void changeBasketSize(Integer newBasketSize) { + this.basketSize = newBasketSize; } } diff --git a/src/test/java/com/booleanuk/core/BasketTest.java b/src/test/java/com/booleanuk/core/BasketTest.java index 0948d2f7..78fc0c09 100644 --- a/src/test/java/com/booleanuk/core/BasketTest.java +++ b/src/test/java/com/booleanuk/core/BasketTest.java @@ -9,9 +9,11 @@ public void addBagelTest(){ Basket b = new Basket(); b.basketSize = 1; + // Expected return strings String expectedSuccess = "Bagel added successfully."; String expectedFail = "Basket is full."; + // Resulting strings from addBagel execution String testSuccess = b.addBagel("Cream"); String testFail = b.addBagel("Chocolate"); @@ -22,12 +24,13 @@ public void addBagelTest(){ @Test public void removeBagelTest(){ Basket b = new Basket(); - b.addBagel("Chocolate"); + // Expected return strings String expectedSuccess = "Bagel successfully removed from basket."; String expectedFail = "This bagel is not in your basket."; + // Resulting strings from removeBagel execution String testSuccess = b.removeBagel("Chocolate"); String testFail = b.removeBagel("Cream"); @@ -36,7 +39,7 @@ public void removeBagelTest(){ } @Test - public void changeBasketCapacityTest(){ + public void changeBasketSizeTest(){ Basket b = new Basket(); b.basketSize = 1; @@ -50,10 +53,10 @@ public void changeBasketCapacityTest(){ // Verifies basket is full error Assertions.assertEquals(basketIsFull, failString); - // Changes capacity of basketCapacity and verifies equality - int newBasketCapacity = 2; - b.changeBasketCapacity(newBasketCapacity); - Assertions.assertEquals(newBasketCapacity, b.basketSize); + // Changes size of basketSize and verifies equality + int newBasketSize = 2; + b.changeBasketSize(newBasketSize); + Assertions.assertEquals(newBasketSize, b.basketSize); // Repeat first test to demonstrate that the basket has increased String successString = b.addBagel("Chocolate");