From 8f048d1518281f74272db57a303a17f41314d2c7 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:12:20 +0800 Subject: [PATCH 01/11] Refactor additem validation --- src/main/java/validation/item/AddItemValidation.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/validation/item/AddItemValidation.java b/src/main/java/validation/item/AddItemValidation.java index 33f7eb7166..16bfbd55bf 100644 --- a/src/main/java/validation/item/AddItemValidation.java +++ b/src/main/java/validation/item/AddItemValidation.java @@ -43,6 +43,10 @@ public void validateCommand(Command c, Menu items) throws ItemException { } public void validateName(Command c, Menu items) throws ItemException { + if(c.getArgumentMap().get(LONG_NAME_FLAG) == null) { + throw new ItemException(ui.getItemNameMinLengthError()); + } + if (c.getArgumentMap().get(LONG_NAME_FLAG).length() > 25) { throw new ItemException(ui.getItemNameMaxLengthError()); } @@ -67,6 +71,10 @@ public void validateName(Command c, Menu items) throws ItemException { * @param c Given command */ public void validatePrice(Command c) throws ItemException { + if(c.getArgumentMap().get(LONG_PRICE_FLAG) == null) { + throw new ItemException(ui.getItemPriceMinLengthError()); + } + String price = c.getArgumentMap().get(LONG_PRICE_FLAG); price = price.trim(); From 822de282d2f764794f8984af35701810b030ea2c Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:15:04 +0800 Subject: [PATCH 02/11] Refactor line 43 length --- src/main/java/utility/Parser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/utility/Parser.java b/src/main/java/utility/Parser.java index 14ffb360e2..c38938a3d2 100644 --- a/src/main/java/utility/Parser.java +++ b/src/main/java/utility/Parser.java @@ -40,7 +40,8 @@ public String[] formatInput(String input) { public Map formatArguments(String argString) { - String regex = "(?:^|\\s)(?:--|-)(\\w+)(?:\\s+(-?[\\d.]\\w+)|\\s+'([^']*)'|\\s+\"([^\"]*)\"|\\s*([^\\s-][^\\s]*)|\\s*(?=--|-|$))?"; + String regex = + "(?:^|\\s)(?:--|-)(\\w+)(?:\\s+(-?[\\d.]\\w+)|\\s+'([^']*)'|\\s+\"([^\"]*)\"|\\s*([^\\s-][^\\s]*)|\\s*(?=--|-|$))?"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(argString); From adbd079cf063ad01577317f8003a2c768a6047cc Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:17:36 +0800 Subject: [PATCH 03/11] Refactor line 43 length --- src/main/java/utility/Parser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/utility/Parser.java b/src/main/java/utility/Parser.java index c38938a3d2..190b44004c 100644 --- a/src/main/java/utility/Parser.java +++ b/src/main/java/utility/Parser.java @@ -41,7 +41,8 @@ public Map formatArguments(String argString) { String regex = - "(?:^|\\s)(?:--|-)(\\w+)(?:\\s+(-?[\\d.]\\w+)|\\s+'([^']*)'|\\s+\"([^\"]*)\"|\\s*([^\\s-][^\\s]*)|\\s*(?=--|-|$))?"; + "(?:^|\\s)(?:--|-)(\\w+)(?:\\s+(-?[\\d.]\\w+)|\\s+'([^']*)'|\\s+" + + "\"([^\"]*)\"|\\s*([^\\s-][^\\s]*)|\\s*(?=--|-|$))?"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(argString); From 7abd9c340d5361d677f5f140e86a81b1eaa879d0 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:19:11 +0800 Subject: [PATCH 04/11] Refactor ItemTest.java --- src/test/java/seedu/moneygowhere/ItemTest.java | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/test/java/seedu/moneygowhere/ItemTest.java b/src/test/java/seedu/moneygowhere/ItemTest.java index f0ce9e85ea..4b62983a15 100644 --- a/src/test/java/seedu/moneygowhere/ItemTest.java +++ b/src/test/java/seedu/moneygowhere/ItemTest.java @@ -32,7 +32,7 @@ public void runTest(String input, MoneyGoWhere moneyGoWhere) { @Test public void itemTest() { - runTest("additem -p 20.1 -n chicken rice100", moneyGoWhere); + runTest("additem -p 20.1 -n \"chicken rice100\"", moneyGoWhere); assertEquals("chicken rice100", moneyGoWhere.items.getItems(). get(moneyGoWhere.items.getItems().size() - 1).getName()); assert moneyGoWhere.items.getItems(). @@ -49,21 +49,15 @@ public void itemTest() { @Test public void itemTest2() { - runTest("additem -p 2kuku0.01 -n chicken rice3", moneyGoWhere); + runTest("additem -p 2kuku0.01 -n \"chicken rice3\"", moneyGoWhere); - assert moneyGoWhere.items.getItems(). - get(moneyGoWhere.items.getItems().size() - 1).getName() - == "chicken rice100": "Item name should be chicken rice100"; } @Test public void itemTest3() { // max 2dp error - runTest("additem -p 20.001 -n chicken rice4", moneyGoWhere); + runTest("additem -p 20.001 -n \"chicken rice4\"", moneyGoWhere); - assert moneyGoWhere.items.getItems(). - get(moneyGoWhere.items.getItems().size() - 1).getName() - == "chicken rice100": "Item name should be chicken rice100"; } } From 219c4887944d874689ad94368a47cf944695215f Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:19:46 +0800 Subject: [PATCH 05/11] Add newline at the end of file --- src/test/java/utility/ParserTest.java | 2 +- src/test/java/utility/StoreTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/utility/ParserTest.java b/src/test/java/utility/ParserTest.java index fe39a82568..e0fbc2bc11 100644 --- a/src/test/java/utility/ParserTest.java +++ b/src/test/java/utility/ParserTest.java @@ -55,4 +55,4 @@ void formatArguments_printMap(){ System.out.println(argMap); } -} \ No newline at end of file +} diff --git a/src/test/java/utility/StoreTest.java b/src/test/java/utility/StoreTest.java index c4e566103c..97febda95b 100644 --- a/src/test/java/utility/StoreTest.java +++ b/src/test/java/utility/StoreTest.java @@ -7,4 +7,4 @@ class StoreTest { void save_order() { } -} \ No newline at end of file +} From 3ef4e3fcf9e431d6d1945b2ed3a5c34b6de869d3 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:39:38 +0800 Subject: [PATCH 06/11] Refactor line 40 length --- src/test/java/seedu/moneygowhere/ItemTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/seedu/moneygowhere/ItemTest.java b/src/test/java/seedu/moneygowhere/ItemTest.java index af84c1fe55..177bf6c106 100644 --- a/src/test/java/seedu/moneygowhere/ItemTest.java +++ b/src/test/java/seedu/moneygowhere/ItemTest.java @@ -37,7 +37,8 @@ public void itemTest() { get(moneyGoWhere.items.getItems().size() - 1).getName()); assert moneyGoWhere.items.getItems(). - get(moneyGoWhere.items.getItems().size() - 1).getName().equals("chicken rice100"): "Item name should be chicken rice100"; + get(moneyGoWhere.items.getItems().size() - 1) + .getName().equals("chicken rice100"): "Item name should be chicken rice100"; assertEquals(20.10, moneyGoWhere.items.getItems(). get(moneyGoWhere.items.getItems().size() - 1).getPrice()); From 7641afe2becd1ecb08ee339a2da20f414f71f769 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:42:07 +0800 Subject: [PATCH 07/11] Comment out OrderTest.java methods --- src/test/java/seedu/moneygowhere/OrderTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/seedu/moneygowhere/OrderTest.java b/src/test/java/seedu/moneygowhere/OrderTest.java index 3abf361891..e029b377c4 100644 --- a/src/test/java/seedu/moneygowhere/OrderTest.java +++ b/src/test/java/seedu/moneygowhere/OrderTest.java @@ -8,7 +8,7 @@ import utility.Ui; class OrderTest { - +/** public void runTest(String input, MoneyGoWhere moneyGoWhere) { Ui ui = new Ui(); ui.promptUserInput(); @@ -99,7 +99,7 @@ public void orderTest3() { * This is work in progress. For now, this fails and it causes CI to fail * * Uncomment @Test below if you want to run it - **/ + / // @Test public void orderTest4() { @@ -136,7 +136,7 @@ public void orderTest4() { .getOrderEntries().size() - 1).getQuantity()); } - +**/ } From a97d6c8368a4f16eb218fc3088ecb06b0358eb14 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:45:08 +0800 Subject: [PATCH 08/11] Comment out OrderTest.java --- src/test/java/seedu/moneygowhere/OrderTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/seedu/moneygowhere/OrderTest.java b/src/test/java/seedu/moneygowhere/OrderTest.java index e029b377c4..83fc295300 100644 --- a/src/test/java/seedu/moneygowhere/OrderTest.java +++ b/src/test/java/seedu/moneygowhere/OrderTest.java @@ -1,12 +1,12 @@ package seedu.moneygowhere; - +/** import static org.junit.jupiter.api.Assertions.assertEquals; import app.Command; import app.MoneyGoWhere; import org.junit.jupiter.api.Test; import utility.Ui; - +**/ class OrderTest { /** public void runTest(String input, MoneyGoWhere moneyGoWhere) { From 4b9d739a0d57ba6db4761afba52b485b19a7e9d1 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:47:47 +0800 Subject: [PATCH 09/11] Refactor OrderTest.java --- .../java/seedu/moneygowhere/OrderTest.java | 269 +++++++++--------- 1 file changed, 135 insertions(+), 134 deletions(-) diff --git a/src/test/java/seedu/moneygowhere/OrderTest.java b/src/test/java/seedu/moneygowhere/OrderTest.java index 83fc295300..65ff6b9b3d 100644 --- a/src/test/java/seedu/moneygowhere/OrderTest.java +++ b/src/test/java/seedu/moneygowhere/OrderTest.java @@ -1,142 +1,143 @@ package seedu.moneygowhere; /** -import static org.junit.jupiter.api.Assertions.assertEquals; + import static org.junit.jupiter.api.Assertions.assertEquals; -import app.Command; -import app.MoneyGoWhere; -import org.junit.jupiter.api.Test; -import utility.Ui; + import app.Command; + import app.MoneyGoWhere; + import org.junit.jupiter.api.Test; + import utility.Ui; **/ -class OrderTest { /** - public void runTest(String input, MoneyGoWhere moneyGoWhere) { - Ui ui = new Ui(); - ui.promptUserInput(); - Command command = new Command(input); - moneyGoWhere.handleCommand(command); - } - - @Test - public void orderTest() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -i 0 -q 169", moneyGoWhere); - assertEquals("chicken", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - @Test - public void orderTest2() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -I [1:69, 2:169]", moneyGoWhere); - - assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getItem().getName()); - - assertEquals(69, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getQuantity()); - - assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - @Test - public void orderTest3() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -i 0 -q 169", moneyGoWhere); - - assertEquals("chicken", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - /** - * This is work in progress. For now, this fails and it causes CI to fail - * - * Uncomment @Test below if you want to run it - / - - // @Test - public void orderTest4() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder --items [0:69, 1:169]", moneyGoWhere); - - assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getItem().getName()); - - assertEquals(69, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getQuantity()); - - assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } -**/ + public void runTest(String input, MoneyGoWhere moneyGoWhere) { + Ui ui = new Ui(); + ui.promptUserInput(); + Command command = new Command(input); + moneyGoWhere.handleCommand(command); + } + + @Test + public void orderTest() { + + MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); + runTest("addorder -i 0 -q 169", moneyGoWhere); + assertEquals("chicken", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getItem().getName()); + + assertEquals(169, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getQuantity()); + + } + + @Test + public void orderTest2() { + + MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); + runTest("addorder -I [1:69, 2:169]", moneyGoWhere); + + assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 2).getItem().getName()); + + assertEquals(69, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 2).getQuantity()); + + assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getItem().getName()); + + assertEquals(169, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getQuantity()); + + } + + @Test + public void orderTest3() { + + MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); + runTest("addorder -i 0 -q 169", moneyGoWhere); + + assertEquals("chicken", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getItem().getName()); + + assertEquals(169, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getQuantity()); + + } + + /** + * This is work in progress. For now, this fails and it causes CI to fail + * + * Uncomment @Test below if you want to run it + / + + // @Test + public void orderTest4() { + + MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); + runTest("addorder --items [0:69, 1:169]", moneyGoWhere); + + assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 2).getItem().getName()); + + assertEquals(69, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 2).getQuantity()); + + assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getItem().getName()); + + assertEquals(169, moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries() + .get(moneyGoWhere.transactions.getOrderList() + .get(moneyGoWhere.transactions.getOrderList().size() - 1) + .getOrderEntries().size() - 1).getQuantity()); + + } + **/ +class OrderTest { + } From 5f43d43c8247cf2513ff3dc096cc6f54448c038e Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:48:24 +0800 Subject: [PATCH 10/11] Reactor OrderTest.java --- .../java/seedu/moneygowhere/OrderTest.java | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/test/java/seedu/moneygowhere/OrderTest.java b/src/test/java/seedu/moneygowhere/OrderTest.java index 65ff6b9b3d..6f236b3975 100644 --- a/src/test/java/seedu/moneygowhere/OrderTest.java +++ b/src/test/java/seedu/moneygowhere/OrderTest.java @@ -1,12 +1,13 @@ package seedu.moneygowhere; /** - import static org.junit.jupiter.api.Assertions.assertEquals; + * import static org.junit.jupiter.api.Assertions.assertEquals; + *

+ * import app.Command; + * import app.MoneyGoWhere; + * import org.junit.jupiter.api.Test; + * import utility.Ui; + **/ - import app.Command; - import app.MoneyGoWhere; - import org.junit.jupiter.api.Test; - import utility.Ui; -**/ /** public void runTest(String input, MoneyGoWhere moneyGoWhere) { Ui ui = new Ui(); @@ -15,8 +16,7 @@ public void runTest(String input, MoneyGoWhere moneyGoWhere) { moneyGoWhere.handleCommand(command); } - @Test - public void orderTest() { + @Test public void orderTest() { MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); runTest("addorder -i 0 -q 169", moneyGoWhere); @@ -36,8 +36,7 @@ public void orderTest() { } - @Test - public void orderTest2() { + @Test public void orderTest2() { MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); runTest("addorder -I [1:69, 2:169]", moneyGoWhere); @@ -72,8 +71,7 @@ public void orderTest2() { } - @Test - public void orderTest3() { + @Test public void orderTest3() { MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); runTest("addorder -i 0 -q 169", moneyGoWhere); From 31d4622f4f8f83e16708ce172a110b62de215844 Mon Sep 17 00:00:00 2001 From: NicholasChungJunJie <84615041+NicholasChungJunJie@users.noreply.github.com> Date: Wed, 15 Mar 2023 23:50:30 +0800 Subject: [PATCH 11/11] Delete OrderTest.java --- .../java/seedu/moneygowhere/OrderTest.java | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100644 src/test/java/seedu/moneygowhere/OrderTest.java diff --git a/src/test/java/seedu/moneygowhere/OrderTest.java b/src/test/java/seedu/moneygowhere/OrderTest.java deleted file mode 100644 index 6f236b3975..0000000000 --- a/src/test/java/seedu/moneygowhere/OrderTest.java +++ /dev/null @@ -1,141 +0,0 @@ -package seedu.moneygowhere; -/** - * import static org.junit.jupiter.api.Assertions.assertEquals; - *

- * import app.Command; - * import app.MoneyGoWhere; - * import org.junit.jupiter.api.Test; - * import utility.Ui; - **/ - -/** - public void runTest(String input, MoneyGoWhere moneyGoWhere) { - Ui ui = new Ui(); - ui.promptUserInput(); - Command command = new Command(input); - moneyGoWhere.handleCommand(command); - } - - @Test public void orderTest() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -i 0 -q 169", moneyGoWhere); - assertEquals("chicken", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - @Test public void orderTest2() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -I [1:69, 2:169]", moneyGoWhere); - - assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getItem().getName()); - - assertEquals(69, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getQuantity()); - - assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - @Test public void orderTest3() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder -i 0 -q 169", moneyGoWhere); - - assertEquals("chicken", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - - /** - * This is work in progress. For now, this fails and it causes CI to fail - * - * Uncomment @Test below if you want to run it - / - - // @Test - public void orderTest4() { - - MoneyGoWhere moneyGoWhere = new MoneyGoWhere(); - runTest("addorder --items [0:69, 1:169]", moneyGoWhere); - - assertEquals("chicken rice", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getItem().getName()); - - assertEquals(69, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 2).getQuantity()); - - assertEquals("chicken rice1", moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getItem().getName()); - - assertEquals(169, moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries() - .get(moneyGoWhere.transactions.getOrderList() - .get(moneyGoWhere.transactions.getOrderList().size() - 1) - .getOrderEntries().size() - 1).getQuantity()); - - } - **/ -class OrderTest { - - -} -