From 9cd83796348de7a5888e1a710f5915c3de544f3a Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Sun, 14 Apr 2024 02:07:49 +0800 Subject: [PATCH 1/8] Git add META-INF --- src/main/META-INF/MANIFEST.MF | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/main/META-INF/MANIFEST.MF diff --git a/src/main/META-INF/MANIFEST.MF b/src/main/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..0bb1e1ff91 --- /dev/null +++ b/src/main/META-INF/MANIFEST.MF @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +Main-Class: seedu.omnitravel.omnitravel.OmniTravel + From fb04fa87511b585846151e9efcf46835664f93aa Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Sun, 14 Apr 2024 15:39:14 +0800 Subject: [PATCH 2/8] Add Junit test for ui functions --- .../java/seedu/omnitravel/OmniTravelTest.java | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 61c23b323b..31792f4de8 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -567,9 +567,6 @@ public void testTotalExpenseCommand() throws OmniException { assertEquals(capturedOutputStream.toString(), input); } - - - @Test public void testCurrencyExchangeCommand() throws OmniException { Parser.currencyExchangeCommand("change 100 /from USD /to EUR"); @@ -711,4 +708,67 @@ public void testListTagsCommandMethod() throws OmniException{ String[] command = {"listtags"}; Parser.listTagsCommand(command, list); } + + @Test + public void testPrintDateTimeExceptionError() { + String input = "Invalid date, please input the date in the following order: YYYY-MM-DD" + + System.lineSeparator(); + Ui.printDateTimeExceptionError(); + assertEquals(input, capturedOutputStream.toString()); + } + + @Test + public void testHelpCommand() { + String input = "____________________________________________________________" + System.lineSeparator() + + "These are the available commands!" + System.lineSeparator() + System.lineSeparator() + + "1. list : List out the current list for given date sorted\n" + + "2. help: Get all commands for the chatbot\n" + + "3. bye: Exit the chatbot\n" + + "4. add \n" + + "5. accommodation \n" + + "6. food \n" + + "7. landmark \n" + + "8. delete \n" + + "9. find \n" + + "10. check \n" + + "11. uncheck \n" + + "12. tag \n" + + "13. untag \n" + + "14. update \n" + + "15. findtag \n" + + "16. findtype \n" + + "17. listtags \n" + + "18. expense \n" + + "19. removeexpense \n" + + "20. totalexpense \n" + + "21. change /from /to \n" + System.lineSeparator() + + "____________________________________________________________"; + Ui.helpCommand(); + assertEquals(capturedOutputStream.toString().trim(), input); + } + + @Test + public void testPrintBye() { + String input = "____________________________________________________________" + System.lineSeparator() + + "Thank you for using Omnitravel" + System.lineSeparator() + + "We hope to see you again! Goodbye!" + System.lineSeparator() + + "____________________________________________________________"; + Ui.printBye(); + assertEquals(capturedOutputStream.toString().trim(), input); + } + + @Test + public void testPrintGreeting() { + String input = "____________________________________________________________" + System.lineSeparator() + + " ____ _ _ _ _____ ____ ____ _ _____ _\n" + + "/ _ \\/ \\__/|/ \\ /|/ \\/__ __\\/ __\\/ _ \\/ \\ |\\/ __// \\\n" + + "| / \\|| |\\/||| |\\ ||| | / \\ | \\/|| / \\|| | //| \\ | |\n" + + "| \\_/|| | ||| | \\||| | | | | /| |-||| \\// | /_ | |_/\\\n" + + "\\____/\\_/ \\|\\_/ \\|\\_/ \\_/ \\_/\\_\\\\_/ \\|\\__/ \\____\\\\____/)" + + System.lineSeparator() + "Hello" + System.lineSeparator() + "How may I assist you?" + + System.lineSeparator() + "____________________________________________________________"; + Ui.printGreeting(); + assertEquals(capturedOutputStream.toString().trim(), input); + } + } From f69789189e0cd568e2e09c2fe67cb4d13beb9746 Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Sun, 14 Apr 2024 17:01:08 +0800 Subject: [PATCH 3/8] Update javadocs --- .../TravelActivityList.java | 42 +++++++++++-------- src/main/java/seedu/omnitravel/ui/Ui.java | 12 ++++++ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java index 488077f966..5c674e9760 100644 --- a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java +++ b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java @@ -95,10 +95,10 @@ public int getNoOfTravelActivities(){ //@@author ChinYanXu /** - * Removes travel activity from the travel activity list - * @param activityNumber The travel activity index number or description on the list + * Removes travel activity from the travel activity list using the travel activity index number + * + * @param activityNumber The index number of the travel activity that the user wants to remove */ - public void removeTravelActivity(int activityNumber) throws OmniException { assert activityNumber != 0 : "There is not activities in the list"; @@ -116,6 +116,13 @@ public void removeTravelActivity(int activityNumber) throws OmniException { assert newSize == initialListSize - 1 : "There is an error with list size!"; } + /** + * Overloaded version of removeTravelActivity function to enable user to remove travel activities from the travel + * activity list using the travel activity description + * + * @param activity The description of travel activity that the user wants to remove + */ + public void removeTravelActivity(String activity){ int foundCounter = 0; for (int iterator = 0; iterator < travelActivities.size(); iterator += 1) { @@ -153,14 +160,12 @@ public String getDescription(String plan){ } //@@author ChinYanXu /** - * Finds all activities in the TravelActivity list that contains a keyword specified - * by the user. + * Finds all activities in the TravelActivity list that contains a keyword specified by the user. * - * @param activityName keyword specified by the user to find activities in the TravelActivity list - * related to the keyword. + * @param activityName keyword specified by the user to find travel activities in the TravelActivity list + * with description related to the keyword. */ - public void searchKeyword (String activityName) { int foundCounter = 0; for (TravelActivity travelActivity : travelActivities) { @@ -180,10 +185,11 @@ public void searchKeyword (String activityName) { } /** - * Overloaded version of searchKeyword function to enable user to exclude certain activities from their search + * Overloaded version of searchKeyword function to enable user to exclude certain travel activities from their + * search * - * @param activityName The description of tasks that the user wants to find - * @param exclusion The keyword that the user uses to remove unwanted results from the search + * @param activityName The description of the travel activities that the user wants to find + * @param exclusion The keyword that the travel activities uses to remove unwanted results from the search */ public void searchKeyword (String activityName, String exclusion) { @@ -328,9 +334,9 @@ public ArrayList getTravelActivities () { //@@author ChinYanXu /** - * Find all the tasks with a particular tag and prints them out + * Find all the travel activities with a particular tag and prints them out * - * @param tag The tag of tasks that the user wants to find + * @param tag The tag of travel activities that the user wants to find */ public void findTag(String tag){ @@ -352,9 +358,9 @@ public void findTag(String tag){ } /** - * Overloaded version of findtag function to enable user to exclude certain activities from their search + * Overloaded version of findtag function to enable user to exclude certain travel activities from their search * - * @param tag The tag of tasks that the user wants to find + * @param tag The tag of the travel activities that the user wants to find * @param exclude The keyword that the user uses to remove unwanted results from the search */ @@ -377,9 +383,9 @@ public void findTag(String tag, String exclude){ } /** - * Find all the tasks of a particular type and prints them out + * Find all the travel activities of a particular type and prints them out * - * @param type The type of tasks that the user wants to find + * @param type The type of travel activities that the user wants to find */ public void findType(String type){ @@ -404,7 +410,7 @@ public void findType(String type){ /** * Overloaded version of findtype to enable user to exclude certain activities from their search * - * @param type The type of tasks that the user wants to find + * @param type The type of travel activities that the user wants to find * @param exclude The keyword that the user uses to remove unwanted results from the search * */ diff --git a/src/main/java/seedu/omnitravel/ui/Ui.java b/src/main/java/seedu/omnitravel/ui/Ui.java index 67b903aea2..5852ceb221 100644 --- a/src/main/java/seedu/omnitravel/ui/Ui.java +++ b/src/main/java/seedu/omnitravel/ui/Ui.java @@ -103,15 +103,27 @@ public static void helpCommand(){ printLine(); } + /** + * Prints out the error message for when the user inputs the date in the wrong format + */ + //@@author daryltay415 public static void printDateTimeExceptionError(){ System.out.println("Invalid date, please input the date in the following order: YYYY-MM-DD"); } + /** + * Prints out the error message for when there is an error when saving the file + */ + public static void printSavingError(){ System.out.println("Something went wrong when saving the file"); } + /** + * Prints out the error message for when InterruptedException is thrown + */ + public static void printInterruptedError(){ System.out.println("Warning Website might be down!"); } From cd09c7024265a35cd86ab766fb6e72c769a75dbe Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Sun, 14 Apr 2024 17:58:31 +0800 Subject: [PATCH 4/8] Update UserGuide --- docs/UserGuide.md | 51 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 00c38f39af..d08a324fdb 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -168,16 +168,19 @@ ____________________________________________________________ ``` ### Find activity from the list using activity description : `find` -Find an activity based on their description. All activities with the given description will be listed out. +Find activities based on their description. All activities with the given description will be listed out. Format: `find DESCRIPTION [/exclude KEYWORD]` -* `DESCRIPTION` has to match the activity description exactly to find the activity -* `DESCRIPTION` can also be a keyword that is included in the description. +* `DESCRIPTION` has to be a word, a phrase or a segment of the activity description to find the activity +* `KEYWORD` has to be a word, a phrase or a segment of the activity description to exclude the activity -Examples of usage (assuming saizeriya is in list): +Examples of usage (assuming saizeriya is in list): * `find saizeriya` +* `find saizeriya /exclude pizza` + +Expected outcome: +Without `/exclude` -Expected output: ``` ____________________________________________________________ Here are what you are looking for: @@ -187,9 +190,7 @@ ____________________________________________________________ ``` With `/exclude`: -* `find saizeriya /exclude pizza` -Expected output: ``` ____________________________________________________________ Here are what you are looking for: @@ -209,17 +210,22 @@ Examples of usage: * `delete 1` * `delete Eiffel` -Expected output: +Expected outcome: +When ACTIVITY is a number ``` ____________________________________________________________ I have removed this activity: -Accommodation: Four Seasons Hotel :14 Mar 2025 :2 days +1. Accommodation: Four Seasons Hotel :14 Mar 2025 :2 days ____________________________________________________________ ``` + +When ACTIVITY is a keyword ``` ____________________________________________________________ I have removed this activity: 1. Landmark: Eiffel Tower :14 Mar 2025 :2 hours (go up tower) +2. Landmark: Eiffel Tower Food Stand :14 Mar 2025 :1 hours (dinner) +3. Accommodation: Hotel beside Eiffel Tower :14 Mar 2025 :2 days (rest) ____________________________________________________________ ``` @@ -373,17 +379,28 @@ ____________________________________________________________ Find an activity based on their tag. All activities with the given tag will be listed out. Format: `findtag TAG [/exclude KEYWORD]` -* `TAG` has to match the activity tag exactly to find the activity +* `TAG` has to be a word, a phrase or a segment of the activity description to find the activity +* `KEYWORD` has to be a word, a phrase or a segment of the activity description to exclude the activity Examples of usage: * `findtag spicy` * `findtag spicy /exclude mala` Expected outcome: +Without `/exclude` ``` ____________________________________________________________ Here are what you are looking for: [ ] 1. Food: Mala Hotpot :14 Mar 2025 :2 hours (very spicy) +[ ] 2. Food: McSpicy :16 Mar 2025 :1 hour (very spicy) +____________________________________________________________ +``` + +With `/exclude` +``` +____________________________________________________________ +Here are what you are looking for: +[ ] 1. Food: McSpicy :16 Mar 2025 :1 hour (very spicy) ____________________________________________________________ ``` @@ -413,7 +430,8 @@ ____________________________________________________________ Find an activity based on their type. All activities with the given type will be listed out. Format: `findtype TYPE [/exclude KEYWORD]` -* `TYPE` has to match the activity type exactly to find the activity +* `TYPE` has to be a word, a phrase or a segment of the activity description to find the activity +* `KEYWORD` has to be a word, a phrase or a segment of the activity description to exclude the activity * The different types are `general`, `accommodation`, `food`, `landmark` Examples of usage: @@ -421,6 +439,8 @@ Examples of usage: * `findtype general /exclude japan` Expected outcome: + +Without `/exclude` ``` ____________________________________________________________ Here are what you are looking for: @@ -429,6 +449,15 @@ Here are what you are looking for: ____________________________________________________________ ``` +With `/exclude` +``` +____________________________________________________________ +Here are what you are looking for: +[ ] 1. General: Go to Hong Kong :25 Aug 2025 :6 hours (with family) +____________________________________________________________ +``` + + ### Adding an expense amount: `expense` Adds an expense amount to an existing travel activity. From 3ce1ead03bd7d9a6a39b8e8b415dbd9d14842e37 Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Sun, 14 Apr 2024 22:25:57 +0800 Subject: [PATCH 5/8] Add more line coverage for travelactivitytypes --- .../TravelActivityList.java | 4 +- .../java/seedu/omnitravel/OmniTravelTest.java | 165 ++++++++++++++++-- 2 files changed, 151 insertions(+), 18 deletions(-) diff --git a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java index 5c674e9760..6b25ca16d3 100644 --- a/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java +++ b/src/main/java/seedu/omnitravel/travelactivitytypes/TravelActivityList.java @@ -101,7 +101,7 @@ public int getNoOfTravelActivities(){ */ public void removeTravelActivity(int activityNumber) throws OmniException { - assert activityNumber != 0 : "There is not activities in the list"; + assert activityNumber != 0 : "There is no activities in the list"; int indexOfActivity = activityNumber - 1; int initialListSize = noOfActivities; if(activityNumber > noOfActivities){ @@ -402,7 +402,7 @@ public void findType(String type){ } } if (foundCounter == 0) { - System.out.println("Sorry I could not find what you are looking for."); + System.out.println("Sorry, I could not find what you are looking for."); } } diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 31792f4de8..72d4da29ac 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -104,6 +104,16 @@ public void addTest() { assertEquals("visit home", travelActivityList.getDescription("visit home")); } + @Test + public void deleteTestWhenInputIsGreaterThanNumberOfActivityInList() throws OmniException { + TravelActivityList travelActivityList = new TravelActivityList(); + travelActivityList.addTravelActivity(new TravelActivity("visit museum", + LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "")); + travelActivityList.addTravelActivity(new TravelActivity("visit home", + LocalDate.parse("2019-12-14"), "5hours", "Sightseeing", "$50")); + assertThrows(OmniException.class, () -> travelActivityList.removeTravelActivity(3)); + } + @Test public void deleteTest() throws OmniException { //add the plan @@ -113,8 +123,8 @@ public void deleteTest() throws OmniException { travelActivityList.addTravelActivity(travelActivity); assertEquals("visit museum", travelActivityList.getDescription("visit museum")); //delete the plan - travelActivityList.removeTravelActivity("1"); - assertEquals("visit museum", travelActivityList.getDescription("visit museum")); + travelActivityList.removeTravelActivity(1); + assertEquals("cant be found", travelActivityList.getDescription("visit museum")); //testing the keyword delete enhancement TravelActivity travelActivity2 = new TravelActivity("visit home", LocalDate.parse("2019-12-14"), "5hours", "Sightseeing", "$50"); @@ -143,16 +153,31 @@ public void getNoActivitiesTest() throws OmniException { //check number of activities assertEquals(3, travelActivityList.getNoOfTravelActivities()); //delete the first plan - travelActivityList.removeTravelActivity("1"); - assertEquals("visit museum", travelActivityList.getDescription("visit museum")); + travelActivityList.removeTravelActivity(1); + assertEquals("cant be found", travelActivityList.getDescription("visit museum")); //check number of activities - assertEquals(3, travelActivityList.getNoOfTravelActivities()); + assertEquals(2, travelActivityList.getNoOfTravelActivities()); + } + + @Test + public void checkWhenTravelActivityIsAlreadyCheckedTest() throws OmniException { + TravelActivityList travelActivityList = new TravelActivityList(); + TravelActivity travelActivity1 = new TravelActivity("visit museum", + LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$50"); + travelActivityList.addTravelActivity(travelActivity1); + travelActivityList.checkTravelActivity(1); + travelActivityList.checkTravelActivity(1); + String result = "I have checked this activity:" + System.lineSeparator() + + "[X] 1. General: visit museum :12 May 2019 :2hours (Sightseeing) ($50)" + System.lineSeparator() + + "This activity is already done!" + System.lineSeparator(); + assertEquals(capturedOutputStream.toString(), result); } @Test public void checkTest() throws OmniException { //add the first plan TravelActivityList travelActivityList = new TravelActivityList(); + assertThrows(OmniException.class, () -> travelActivityList.checkTravelActivity(1)); TravelActivity travelActivity1 = new TravelActivity("visit museum", LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$50"); travelActivityList.addTravelActivity(travelActivity1); @@ -167,6 +192,7 @@ public void checkTest() throws OmniException { public void uncheckTest() throws OmniException { //add the first plan TravelActivityList travelActivityList = new TravelActivityList(); + assertThrows(OmniException.class, () -> travelActivityList.uncheckTravelActivity(1)); TravelActivity travelActivity1 = new TravelActivity("visit museum", LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$50"); travelActivityList.addTravelActivity(travelActivity1); @@ -185,6 +211,22 @@ public void trueTest(){ assertTrue(true); } + @Test + public void findWithoutExclusionWhenListIsEmptyTest () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.searchKeyword("anything"); + assertEquals(capturedOutputStream.toString(), result); + } + + @Test + public void findWithExclusionWhenListIsEmptyTest () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.searchKeyword("anything", "nothing"); + assertEquals(capturedOutputStream.toString(), result); + } + @Test //basic test for searchKeyword function public void findWithoutExclusionTest () { @@ -204,6 +246,23 @@ public void findWithExclusionTest () { travelActivityListNew.searchKeyword("mala", "utown"); assertEquals(capturedOutputStream.toString(), findExpectedOutput); } + + @Test + public void findTagWithoutExclusionAndTagIsNotInListTest () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.findTag("sightseeing"); + assertEquals(capturedOutputStream.toString(), result); + } + + @Test + public void findTagWithExclusionAndTagIsNotInListTest () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.findTag("sightseeing", "holiday"); + assertEquals(capturedOutputStream.toString(), result); + } + @Test //basic test for searchKeyword function public void findTagWithoutExclusionTest () { @@ -223,6 +282,23 @@ public void findTagWithExclusionTest () { travelActivityListNew.findTag("sightseeing", "merlion"); assertEquals(capturedOutputStream.toString(), findExpectedOutput2); } + + @Test + public void findTypeWithoutExclusionTestAndActivityIsNotFound () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry, I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.findType("accommodation"); + assertEquals(capturedOutputStream.toString(), result); + } + + @Test + public void findTypeWithExclusionTestAndActivityIsNotFound () { + TravelActivityList travelActivityListNew = new TravelActivityList(); + String result = "Sorry, I could not find what you are looking for." + System.lineSeparator(); + travelActivityListNew.findType("accommodation", "waffle"); + assertEquals(capturedOutputStream.toString(), result); + } + @Test public void findTypeWithExclusionTest () { try { @@ -238,7 +314,6 @@ public void findTypeWithExclusionTest () { } } - @Test public void findTypeWithoutExclusionTest () { try { @@ -253,6 +328,12 @@ public void findTypeWithoutExclusionTest () { } } + @Test + public void testTagActivityWhenTaskNumberIsGreaterThanListSize() throws OmniException { + TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> list.tagActivity(1, "activity 1")); + } + @Test public void testTagActivity() throws OmniException { TravelActivityList list = new TravelActivityList(); @@ -278,6 +359,14 @@ public void testRemoveTagFromActivity() throws OmniException { // Remove an existing tag list.removeTag(1); assertEquals("visit museum", list.getDescription("visit museum")); + assertThrows(OmniException.class, () -> list.removeTag(3)); + } + + @Test + public void testUpdateActivityWhenActivityIndexIsGreaterThanListSize() throws OmniException{ + TravelActivityList travelActivityList = new TravelActivityList(); + assertThrows(OmniException.class, () -> travelActivityList.updateTravelActivity(1, + LocalDate.parse("2020-12-10"), "3hours", "misc")); } @Test @@ -296,6 +385,20 @@ public void testUpdateActivity() throws OmniException{ assertEquals("3hours", travelActivity1.getDuration()); } + @Test + public void testExpenseActivityAndTaskNumberIsGreaterThanListSize() throws OmniException { + TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> list.expenseActivity(1, "$10")); + } + + @Test + public void testExpenseActivityAndExpenseDontStartWithDollarSign() throws OmniException { + TravelActivityList list = new TravelActivityList(); + list.addTravelActivity(new TravelActivity("visit museum", + LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$30")); + assertThrows(OmniException.class, () -> list.expenseActivity(1, "10")); + } + @Test public void testExpenseActivity() throws OmniException { TravelActivityList list = new TravelActivityList(); @@ -308,6 +411,12 @@ public void testExpenseActivity() throws OmniException { assertEquals("$50", travelActivity.getExpense()); } + @Test + public void testRemoveExpenseAndTaskNumberIsGreaterThanListSize() throws OmniException { + TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> list.removeExpense(1)); + } + @Test public void testRemoveExpense() throws OmniException { TravelActivityList list = new TravelActivityList(); @@ -323,6 +432,14 @@ public void testRemoveExpense() throws OmniException { assertEquals("visit museum", list.getDescription("visit museum")); } + @Test + public void testTotalExpanseAndTypeIsInvalid() throws OmniException{ + TravelActivityList list = new TravelActivityList(); + list.addTravelActivity(new TravelActivity("visit museum", + LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$20")); + assertThrows(OmniException.class, () -> list.totalExpense("NA")); + } + @Test public void testTotalExpanseAll() throws OmniException{ TravelActivityList list = new TravelActivityList(); @@ -399,6 +516,21 @@ public void testIsNumeric() { assertFalse(CheckParameters.isNumeric("abc")); } + @Test + public void testGetListWhenActivityIsNull() throws OmniException { + TravelActivityList travelActivityListNew = new TravelActivityList(); + travelActivityListNew.addTravelActivity(null); + travelActivityListNew.listTravelActivities(false, false, LocalDate.now()); + assertEquals(capturedOutputStream.toString().trim(), "There are no activities to list"); + } + + @Test + public void testGetListWhenEmpty() throws OmniException { + TravelActivityList travelActivityListNew = new TravelActivityList(); + travelActivityListNew.listTravelActivities(false, false, LocalDate.now()); + assertEquals(capturedOutputStream.toString().trim(), "There are no activities to list"); + } + @Test public void testGetList() throws OmniException { TravelActivityList travelActivityListNew = initialiseTestTravelActivityList(); @@ -534,6 +666,7 @@ public void testRemoveExpenseCommand() throws OmniException { Parser.removeExpenseCommand(input, list); assertEquals(capturedOutputStream.toString(), expectedOutput5); } + @Test public void testFindCommandWithoutExclusion() throws OmniException { try { @@ -562,9 +695,9 @@ public void testFindCommandWithExclusion() throws OmniException { @Test public void testTotalExpenseCommand() throws OmniException { TravelActivityList list = new TravelActivityList(); - String input = "The total expense for all travel activities is: $0.0" + System.lineSeparator(); + String result = "The total expense for all travel activities is: $0.0" + System.lineSeparator(); Parser.totalExpenseCommand("totalexpense", list); - assertEquals(capturedOutputStream.toString(), input); + assertEquals(capturedOutputStream.toString(), result); } @Test @@ -711,15 +844,15 @@ public void testListTagsCommandMethod() throws OmniException{ @Test public void testPrintDateTimeExceptionError() { - String input = "Invalid date, please input the date in the following order: YYYY-MM-DD" + String result = "Invalid date, please input the date in the following order: YYYY-MM-DD" + System.lineSeparator(); Ui.printDateTimeExceptionError(); - assertEquals(input, capturedOutputStream.toString()); + assertEquals(result, capturedOutputStream.toString()); } @Test public void testHelpCommand() { - String input = "____________________________________________________________" + System.lineSeparator() + + String result = "____________________________________________________________" + System.lineSeparator() + "These are the available commands!" + System.lineSeparator() + System.lineSeparator() + "1. list : List out the current list for given date sorted\n" + "2. help: Get all commands for the chatbot\n" + @@ -744,22 +877,22 @@ public void testHelpCommand() { "21. change /from /to \n" + System.lineSeparator() + "____________________________________________________________"; Ui.helpCommand(); - assertEquals(capturedOutputStream.toString().trim(), input); + assertEquals(capturedOutputStream.toString().trim(), result); } @Test public void testPrintBye() { - String input = "____________________________________________________________" + System.lineSeparator() + + String result = "____________________________________________________________" + System.lineSeparator() + "Thank you for using Omnitravel" + System.lineSeparator() + "We hope to see you again! Goodbye!" + System.lineSeparator() + "____________________________________________________________"; Ui.printBye(); - assertEquals(capturedOutputStream.toString().trim(), input); + assertEquals(capturedOutputStream.toString().trim(), result); } @Test public void testPrintGreeting() { - String input = "____________________________________________________________" + System.lineSeparator() + + String result = "____________________________________________________________" + System.lineSeparator() + " ____ _ _ _ _____ ____ ____ _ _____ _\n" + "/ _ \\/ \\__/|/ \\ /|/ \\/__ __\\/ __\\/ _ \\/ \\ |\\/ __// \\\n" + "| / \\|| |\\/||| |\\ ||| | / \\ | \\/|| / \\|| | //| \\ | |\n" + @@ -768,7 +901,7 @@ public void testPrintGreeting() { System.lineSeparator() + "Hello" + System.lineSeparator() + "How may I assist you?" + System.lineSeparator() + "____________________________________________________________"; Ui.printGreeting(); - assertEquals(capturedOutputStream.toString().trim(), input); + assertEquals(capturedOutputStream.toString().trim(), result); } } From bcd1ff7e497b255eeca4065c887029882f6c6450 Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Mon, 15 Apr 2024 01:35:38 +0800 Subject: [PATCH 6/8] Improve line coverage for Parser and CheckParameter class --- .../java/seedu/omnitravel/parser/Parser.java | 3 +- .../java/seedu/omnitravel/OmniTravelTest.java | 155 +++++++++++++++++- 2 files changed, 153 insertions(+), 5 deletions(-) diff --git a/src/main/java/seedu/omnitravel/parser/Parser.java b/src/main/java/seedu/omnitravel/parser/Parser.java index b0d76b3615..4aa921ea94 100644 --- a/src/main/java/seedu/omnitravel/parser/Parser.java +++ b/src/main/java/seedu/omnitravel/parser/Parser.java @@ -233,7 +233,8 @@ public static void tagCommand(String line, TravelActivityList list) throws OmniE * @throws OmniException if command.length != 2 && command[1] is not numeric */ public static void removeTagCommand(String[] command, TravelActivityList list) throws OmniException { - assert command != null && command.length >= 2 : "Command array should not be null or empty"; + assert command != null && command.length >= 2 : "Command array should not be null, empty or longer than " + + "length 2"; assert list != null : "TravelActivityList should not be null"; logger.log(Level.INFO, "Remove tag command: " + Arrays.toString(command)); diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 72d4da29ac..175241a47c 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.time.DateTimeException; +import java.time.format.DateTimeParseException; import java.util.NoSuchElementException; class OmniTravelTest { @@ -552,7 +553,7 @@ public void testGetList() throws OmniException { } @Test - public void testActivityCommand() throws OmniException { + public void testActivityCommandAccommodation() throws OmniException { TravelActivityList list = new TravelActivityList(); String expectedOutput4 = "____________________________________________________________" + System.lineSeparator() + @@ -563,10 +564,53 @@ public void testActivityCommand() throws OmniException { assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); } + @Test + public void testActivityCommandFood() throws OmniException { + TravelActivityList list = new TravelActivityList(); + String expectedOutput4 = "____________________________________________________________" + + System.lineSeparator() + + "I added a new food activity" + System.lineSeparator() + + "Food: description :4 Oct 2024 :2 days (test)" + System.lineSeparator() + + "____________________________________________________________"; + Parser.activityCommand("food description /date 2024-10-04 /duration 2 days /tag test", list); + assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); + } + + @Test + public void testActivityCommandLandmark() throws OmniException { + TravelActivityList list = new TravelActivityList(); + String expectedOutput4 = "____________________________________________________________" + + System.lineSeparator() + + "I added a new landmark" + System.lineSeparator() + + "Landmark: description :4 Oct 2024 :2 days (test)" + System.lineSeparator() + + "____________________________________________________________"; + Parser.activityCommand("landmark description /date 2024-10-04 /duration 2 days /tag test", list); + assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); + } + + @Test + public void testActivityCommandError() throws OmniException { + TravelActivityList list = new TravelActivityList(); + String expectedOutput4 = "____________________________________________________________" + + System.lineSeparator() + + "Unknown activity type" + + "____________________________________________________________"; + assertThrows(OmniException.class, () -> Parser.activityCommand( + "Test description /date 2024-10-04 /duration 2 days /tag test", list)); + } + + @Test + public void testActivityCommandButDateIsBeforeNow() throws OmniException { + TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> Parser.activityCommand( + "accommodation description /date 2000-10-04 /duration 2 days /tag test", list)); + } @Test public void testTagCommand() throws OmniException { TravelActivityList list = initialiseTestTravelActivityList(); + assertThrows(OmniException.class, () -> Parser.tagCommand("tag 1", list)); + assertThrows(OmniException.class, () -> Parser.tagCommand("tag", list)); String expectedOutput5 = "I have tagged this task:" + System.lineSeparator() + "Accommodation: nus rvrc :12 Dec 2025 :5 years (test)"; Parser.tagCommand("tag 1 test", list); @@ -578,10 +622,12 @@ public void testRemoveTagCommand() throws OmniException { TravelActivityList list = initialiseTestTravelActivityList(); Parser.tagCommand("tag 1 test", list); String[] input = {"untag", "1"}; + String[] input1 = {"untag", "1", "5"}; String expectedOutput6 = "I have tagged this task:" + System.lineSeparator() + "Accommodation: nus rvrc :12 Dec 2025 :5 years (test)" + System.lineSeparator() + "Tag removed from the task:" + System.lineSeparator() + "Accommodation: nus rvrc :12 Dec 2025 :5 years"; + assertThrows(OmniException.class, () -> Parser.removeTagCommand(input1, list)); Parser.removeTagCommand(input, list); assertEquals(capturedOutputStream.toString().trim(), expectedOutput6); } @@ -590,6 +636,8 @@ public void testRemoveTagCommand() throws OmniException { public void testUpdateCommand() throws OmniException { TravelActivityList list = initialiseTestTravelActivityList(); list.addTravelActivity(accommodationNew1); + assertThrows(OmniException.class, () -> Parser.updateCommand( + "update 1 /date 2000-04-04 /duration 2 days /tag test", list)); Parser.updateCommand("update 1 /date 2025-04-04 /duration 2 days /tag test", list); String expectedOutput7 = "I have updated this task\n" + "from: Accommodation: nus rvrc :12 Dec 2025 :5 years (campus stay)\n" + @@ -601,6 +649,8 @@ public void testUpdateCommand() throws OmniException { public void testFindTagCommandWithoutExclusion() throws OmniException { try { TravelActivityList travelActivityListNew = initialiseTestTravelActivityList(); + assertThrows(OmniException.class, () -> Parser.findTagCommand( + "findtype", travelActivityListNew)); String findExpectedOutput2 = "Here are what you are looking for:" + System.lineSeparator() + "[ ] 1. General: merlion :7 Apr 2026 :2 hours (sightseeing)" + System.lineSeparator() + "[ ] 2. General: chinatown :21 Feb 2025 :5 hours (sightseeing)" + System.lineSeparator(); @@ -626,6 +676,8 @@ public void testFindTagCommandWithExclusion() throws OmniException { @Test public void testFindTypeCommandWithoutExclusion() throws OmniException { TravelActivityList travelActivityListNew = initialiseTestTravelActivityList(); + assertThrows(OmniException.class, () -> Parser.findTypeCommand( + "findtype", travelActivityListNew)); String expectedOutput3 = "Here are what you are looking for:" + System.lineSeparator() + "[ ] 1. General: esplanade :19 Mar 2026 :3 hours (concert)" + System.lineSeparator() + "[ ] 2. General: merlion :7 Apr 2026 :2 hours (sightseeing)" + System.lineSeparator() + @@ -647,6 +699,10 @@ public void testFindTypeCommandWithExclusion() throws OmniException { public void testExpenseCommand() throws OmniException { TravelActivityList list = new TravelActivityList(); list.addTravelActivity(accommodationNew1); + assertThrows(OmniException.class, () -> Parser.expenseCommand( + "expense 1", list)); + assertThrows(OmniException.class, () -> Parser.expenseCommand( + "expense", list)); String expectedOutput4 = "I have added expense for this task:" + System.lineSeparator() + "Accommodation: nus rvrc :12 Dec 2025 :5 years (campus stay) ($50)" + System.lineSeparator(); Parser.expenseCommand("expense 1 $50", list); @@ -657,6 +713,9 @@ public void testExpenseCommand() throws OmniException { public void testRemoveExpenseCommand() throws OmniException { TravelActivityList list = new TravelActivityList(); list.addTravelActivity(accommodationNew1); + String[] command1 = {"removeexpense","2", "5"}; + assertThrows(OmniException.class, () -> Parser.removeExpenseCommand( + command1, list)); Parser.expenseCommand("expense 1 $50", list); String[] input = {"removeExpense", "1"}; String expectedOutput5 = "I have added expense for this task:" + System.lineSeparator() + @@ -671,6 +730,8 @@ public void testRemoveExpenseCommand() throws OmniException { public void testFindCommandWithoutExclusion() throws OmniException { try { TravelActivityList travelActivityListNew = initialiseTestTravelActivityList(); + assertThrows(OmniException.class, () -> Parser.findCommand( + "find", travelActivityListNew)); String findExpectedOutput = "Here are what you are looking for:" + System.lineSeparator() + "[ ] 1. Food: utown mala :19 Jun 2028 :2 hours (spicy)" + System.lineSeparator() + "[ ] 2. Food: pgpr mala :7 Jul 2026 :1 hours (spicy)" + System.lineSeparator(); @@ -695,9 +756,23 @@ public void testFindCommandWithExclusion() throws OmniException { @Test public void testTotalExpenseCommand() throws OmniException { TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> Parser.totalExpenseCommand( + "", list)); + assertThrows(OmniException.class, () -> Parser.totalExpenseCommand( + "expenditure", list)); String result = "The total expense for all travel activities is: $0.0" + System.lineSeparator(); Parser.totalExpenseCommand("totalexpense", list); assertEquals(capturedOutputStream.toString(), result); + TravelActivityList newList = initialiseTestTravelActivityList(); + Parser.totalExpenseCommand("totalexpense /type general", list); + String result1 = "The total expense for all travel activities is: $0.0" + System.lineSeparator() + + "The total expense for TravelActivity travel activities is: $0.0" + System.lineSeparator(); + assertEquals(capturedOutputStream.toString(), result1); + String result2 = "The total expense for all travel activities is: $0.0" + System.lineSeparator() + + "The total expense for TravelActivity travel activities is: $0.0" + System.lineSeparator() + + "The total expense for accommodation travel activities is: $0.0" + System.lineSeparator(); + Parser.totalExpenseCommand("totalexpense /type accommodation", list); + assertEquals(capturedOutputStream.toString(), result2); } @Test @@ -711,6 +786,21 @@ public void testCurrencyExchangeCommand() throws OmniException { public void testAddExceptions() throws OmniException { CheckParameters.addExceptions(new String[]{"description", "/date", "2024-04-08", "/duration", "2 days"}, "add", "add description /date 2024-04-08 /duration 2 days"); + assertThrows(OmniException.class, () -> CheckParameters.addExceptions(new String[]{ + " ", "2024-04-08", "2 days"}, "add", + "add description /date 2024-04-08 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.addExceptions(new String[]{ + "description", " ", "2 days"}, "add", + "add description /date 2024-04-08 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.addExceptions(new String[]{ + "description", "2024-04-08"," "}, "add", + "add description /date 2024-04-08 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.addExceptions(new String[]{ + "description", "2024-04-08", "2 days", " "}, "add", + "add description /date 2024-04-08 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.addExceptions(new String[]{ + "description"}, + "add","add description /date 2024-04-08 /duration 2 days")); } @Test @@ -727,12 +817,19 @@ public void testIsValidExpense() throws OmniException { assertThrows(OmniException.class, () -> { CheckParameters.isValidExpense("-0"); }); + assertTrue(!CheckParameters.isValidExpense("number")); } @Test public void testCheckCurrencyParameters() throws OmniException { CheckParameters.checkCurrencyParameters(new String[]{"change", "100", "/from", "USD", "/to", "EUR"}, - "change 100 /from USD /to EUR"); + "change 100 /from USD /to EUR"); + assertThrows(OmniException.class, () -> CheckParameters.checkCurrencyParameters(new String[]{ + "change", "hundred", "USD", "EUR"}, "change 100 /from USD /to EUR")); + assertThrows(OmniException.class, () -> CheckParameters.checkCurrencyParameters(new String[]{ + "change", "hundred", "usd", "usd"}, "change 100 /from USD /to EUR")); + assertThrows(OmniException.class, () -> CheckParameters.checkCurrencyParameters(new String[]{ + "change", "hundred", "USD"}, "change 100 /from USD /to EUR")); } @Test @@ -779,6 +876,24 @@ public void testGetListMethod() throws OmniException { Parser.getList("list", list); } + @Test + public void testGetListMethodButDateIsInWrongFormat() throws OmniException { + TravelActivityList list = new TravelActivityList(); + assertThrows(DateTimeParseException.class, () -> list.addTravelActivity(new Accommodation("Airbnb", + LocalDate.parse("20-1200-12"), "2hours", "", ""))); + assertThrows(OmniException.class, () -> Parser.getList("list /date 20-1200-12", list)); + } + + @Test + public void testGetListMethodButDateIsBeforeNow() throws OmniException { + TravelActivityList list = new TravelActivityList(); + list.addTravelActivity(new Accommodation("Airbnb", + LocalDate.parse("2020-12-12"), "2hours", "", "")); + assertThrows(OmniException.class, () -> Parser.getList("list /date 1920-12-12", list)); + } + + + @Test public void testGetListMethodWithSorting() throws OmniException{ TravelActivityList list = new TravelActivityList(); @@ -798,6 +913,8 @@ public void testGetListMethodWithDate() throws OmniException{ @Test public void testAddCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); + assertThrows(OmniException.class, () -> Parser.addCommand( + "add home /date 2000-12-12 /duration 2 days", list)); // Test case without tags Parser.addCommand("add home /date 2026-12-12 /duration 2 days", list); // Test case with tags @@ -807,10 +924,13 @@ public void testAddCommandMethod() throws OmniException{ @Test public void testDeleteCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); - list.addTravelActivity(accommodationNew1); - list.addTravelActivity(foodNew2); String[] command1 = {"delete", "1"}; String[] command2 = {"delete", "pgpr mala"}; + String[] command3 = {"delete"}; + assertThrows(OmniException.class, () -> Parser.deleteCommand(command1, list, "delete 1")); + list.addTravelActivity(accommodationNew1); + list.addTravelActivity(foodNew2); + assertThrows(OmniException.class, () -> Parser.deleteCommand(command3, list, "delete 1")); Parser.deleteCommand(command1, list, "delete 1"); Parser.deleteCommand(command2, list, "delete pgpr mala"); } @@ -818,6 +938,8 @@ public void testDeleteCommandMethod() throws OmniException{ @Test public void testCheckCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); + String[] command1 = {"check"}; + assertThrows(OmniException.class, () -> Parser.checkCommand(command1, list)); list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"check", "1"}; @@ -827,6 +949,8 @@ public void testCheckCommandMethod() throws OmniException{ @Test public void testUncheckCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); + String[] command1 = {"check"}; + assertThrows(OmniException.class, () -> Parser.uncheckCommand(command1, list)); list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"uncheck", "1"}; @@ -839,6 +963,8 @@ public void testListTagsCommandMethod() throws OmniException{ list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"listtags"}; + String[] command1 = {"listtags", "list", "tag"}; + assertThrows(OmniException.class, () -> Parser.listTagsCommand(command1, list)); Parser.listTagsCommand(command, list); } @@ -904,4 +1030,25 @@ public void testPrintGreeting() { assertEquals(capturedOutputStream.toString().trim(), result); } + @Test + public void testUpdateException () { + assertThrows(OmniException.class, () -> CheckParameters.updateExceptions(new String[]{ + " ", "2024-05-20", "2 days", "test"}, "update 1 /date 2024-05-20 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.updateExceptions(new String[]{ + "1", " ", "2 days", "test"}, "update 1 /date 2024-05-20 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.updateExceptions(new String[]{ + "description", "2024-05-20"," ", "test"}, "update 1 /date 2024-05-20 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.updateExceptions(new String[]{ + "description", "2024-05-20", "2 days", " "}, "update 1 /date 2024-05-20 /duration 2 days")); + assertThrows(OmniException.class, () -> CheckParameters.updateExceptions(new String[]{ + "1"}, "update 1 /date 2024-05-20 /duration 2 days")); + } + + @Test + public void testListException () { + assertThrows(OmniException.class, () -> CheckParameters.listExceptions(new String[]{ + "test", "/date",}, new String[]{"test", "2024-05-20", "2 days", "test"}, + "testing")); + } + } From d7489c5e8516e1bf6c63a99e558079b4cce4169e Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Mon, 15 Apr 2024 02:42:34 +0800 Subject: [PATCH 7/8] Update chinyanxu.md and fix JUnit bugs --- docs/team/chinyanxu.md | 45 +++++++++++++------ .../java/seedu/omnitravel/OmniTravelTest.java | 42 +++++++++-------- 2 files changed, 54 insertions(+), 33 deletions(-) diff --git a/docs/team/chinyanxu.md b/docs/team/chinyanxu.md index 6c892b4528..a1bb6e4a2e 100644 --- a/docs/team/chinyanxu.md +++ b/docs/team/chinyanxu.md @@ -10,25 +10,42 @@ to quickly group and retrieve information. ### Summary of Contributions Given below are my contributions to the project. -* New Feature: Added the find, findtag and findtype command - * What it does: Enables the user to sort and display all the travel activities stored in Omnitravel or only display - * travel activities of certain types or with certain tags. - * Users are able to exclude travel activities with certain keywords from being displayed while searching - +* New Feature: Added the find command [#25](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/25) + * What it does: Enables the user to display all the travel activities stored in Omnitravel containing a certain + * keyword in their description + * Justification: User might only want to see a list of certain activities and this feature will enable them to do so. + * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their + * search +* New Feature: Added the findtag command [#89](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/89) + * What it does: Enables the user to display all the travel activities stored in Omnitravel containing a certain tag + * Justification: User might have tagged each activity to categorise them and might want to see which activity belongs + * to a tag. This feature enables them to do so. + * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their + * search +* New Feature: Added the findtype command [#91](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/91) + * What it does: Enables the user to display all the travel activities stored in Omnitravel of a certain type + * Justification: User might have sorted each activity into their respective types and might want to see which + * activity is under a type. This feature enables them to do so. + * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their + * search #### Code contribution: -[RepoSense link] -https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=chinyanxu&breakdown=true +[RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=chinyanxu&breakdown=true) * Enhancements implemented to existing features * Added a way to delete travel activities from the list using keywords instead of just the index of the travel - * activity - * Implemented a way to test System.out.println output on numerous JUnit tests - + * activity [#211](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/211) * Documentation * User Guide: - * Added documentation for feature `find`, `findtag` and `findtype` - * Added documentation for delete by keyword enhancement - + * Added documentation for feature `find` [#127](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/127) + * Added documentation for feature `findtag` [#127](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/127) + * Added documentation for feature `findtype` [#127](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/127) + * Added documentation for delete by keyword enhancement [#211](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/211) * Developer Guide: - * Added OmniTravel value proposition. + * Added OmniTravel value proposition. [#92](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/92) + * Community: + * Suggested fixes for other teams in the forum [#38](https://github.com/nus-cs2113-AY2324S2/forum/issues/38) +* Contributions to team-based-tasks + * Contributed large portions of the JUnit tests + * Implemented a way to test text outputted to console [#92](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/92) + * Implemented a way to test if an exception is triggered diff --git a/src/test/java/seedu/omnitravel/OmniTravelTest.java b/src/test/java/seedu/omnitravel/OmniTravelTest.java index 90e129e6a8..0cc4e3c73c 100644 --- a/src/test/java/seedu/omnitravel/OmniTravelTest.java +++ b/src/test/java/seedu/omnitravel/OmniTravelTest.java @@ -434,7 +434,7 @@ public void testRemoveExpense() throws OmniException { } @Test - public void testTotalExpanseAndTypeIsInvalid() throws OmniException{ + public void testTotalExpenseAndTypeIsInvalid() throws OmniException{ TravelActivityList list = new TravelActivityList(); list.addTravelActivity(new TravelActivity("visit museum", LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$20")); @@ -442,7 +442,7 @@ public void testTotalExpanseAndTypeIsInvalid() throws OmniException{ } @Test - public void testTotalExpanseAll() throws OmniException{ + public void testTotalExpenseAll() throws OmniException{ TravelActivityList list = new TravelActivityList(); list.addTravelActivity(new TravelActivity("visit museum", LocalDate.parse("2019-05-12"),"2hours", "Sightseeing", "$20")); @@ -453,7 +453,7 @@ public void testTotalExpanseAll() throws OmniException{ } @Test - public void testTotalExpanseAccommodation() throws OmniException{ + public void testTotalExpenseAccommodation() throws OmniException{ TravelActivityList list = new TravelActivityList(); list.addTravelActivity(new Accommodation("RVRC", LocalDate.parse("2022-07-12"), "3hours", "hostel", "$70")); @@ -463,7 +463,7 @@ public void testTotalExpanseAccommodation() throws OmniException{ } @Test - public void testTotalExpanseFood() throws OmniException{ + public void testTotalExpenseFood() throws OmniException{ TravelActivityList list = new TravelActivityList(); list.addTravelActivity(new Food("UTOWN Flavours", LocalDate.parse("2028-05-12"), "1 hours", "lunch", "$10")); @@ -473,7 +473,7 @@ public void testTotalExpanseFood() throws OmniException{ } @Test - public void testTotalExpanseLandmark() throws OmniException{ + public void testTotalExpenseLandmark() throws OmniException{ TravelActivityList list = new TravelActivityList(); list.addTravelActivity(new Landmark("Berlin Wall", LocalDate.parse("2027-08-14"), "1 hours", "sightseeig", "$5")); @@ -567,11 +567,11 @@ public void testActivityCommandAccommodation() throws OmniException { @Test public void testActivityCommandFood() throws OmniException { TravelActivityList list = new TravelActivityList(); - String expectedOutput4 = "____________________________________________________________" + + String expectedOutput4 = "_______________________________________________________________________________" + System.lineSeparator() + "I added a new food activity" + System.lineSeparator() + "Food: description :4 Oct 2024 :2 days (test)" + System.lineSeparator() + - "____________________________________________________________"; + "_______________________________________________________________________________"; Parser.activityCommand("food description /date 2024-10-04 /duration 2 days /tag test", list); assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); } @@ -579,11 +579,11 @@ public void testActivityCommandFood() throws OmniException { @Test public void testActivityCommandLandmark() throws OmniException { TravelActivityList list = new TravelActivityList(); - String expectedOutput4 = "____________________________________________________________" + + String expectedOutput4 = "_______________________________________________________________________________" + System.lineSeparator() + "I added a new landmark" + System.lineSeparator() + "Landmark: description :4 Oct 2024 :2 days (test)" + System.lineSeparator() + - "____________________________________________________________"; + "_______________________________________________________________________________"; Parser.activityCommand("landmark description /date 2024-10-04 /duration 2 days /tag test", list); assertEquals(capturedOutputStream.toString().trim(), expectedOutput4); } @@ -766,10 +766,10 @@ public void testTotalExpenseCommand() throws OmniException { TravelActivityList newList = initialiseTestTravelActivityList(); Parser.totalExpenseCommand("totalexpense /type general", list); String result1 = "The total expense for all travel activities is: $0.0" + System.lineSeparator() + - "The total expense for TravelActivity travel activities is: $0.0" + System.lineSeparator(); + "The total expense for General travel activities is: $0.0" + System.lineSeparator(); assertEquals(capturedOutputStream.toString(), result1); String result2 = "The total expense for all travel activities is: $0.0" + System.lineSeparator() + - "The total expense for TravelActivity travel activities is: $0.0" + System.lineSeparator() + + "The total expense for General travel activities is: $0.0" + System.lineSeparator() + "The total expense for accommodation travel activities is: $0.0" + System.lineSeparator(); Parser.totalExpenseCommand("totalexpense /type accommodation", list); assertEquals(capturedOutputStream.toString(), result2); @@ -939,7 +939,7 @@ public void testDeleteCommandMethod() throws OmniException{ public void testCheckCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); String[] command1 = {"check"}; - assertThrows(OmniException.class, () -> Parser.checkCommand(command1, list)); + assertThrows(OmniException.class, () -> Parser.checkCommand(command1, list, "check 1")); list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"check", "1"}; @@ -950,7 +950,7 @@ public void testCheckCommandMethod() throws OmniException{ public void testUncheckCommandMethod() throws OmniException{ TravelActivityList list = new TravelActivityList(); String[] command1 = {"check"}; - assertThrows(OmniException.class, () -> Parser.uncheckCommand(command1, list)); + assertThrows(OmniException.class, () -> Parser.uncheckCommand(command1, list, "uncheck 1")); list.addTravelActivity(accommodationNew1); list.addTravelActivity(foodNew2); String[] command = {"uncheck", "1"}; @@ -978,7 +978,8 @@ public void testPrintDateTimeExceptionError() { @Test public void testHelpCommand() { - String result = "____________________________________________________________" + System.lineSeparator() + + String result = "_______________________________________________________________________________" + + System.lineSeparator() + "These are the available commands!" + System.lineSeparator() + System.lineSeparator() + "1. list : List out the current list for given date sorted\n" + "2. help: Get all commands for the chatbot\n" + @@ -1001,31 +1002,34 @@ public void testHelpCommand() { "19. removeexpense \n" + "20. totalexpense \n" + "21. change /from /to \n" + System.lineSeparator() + - "____________________________________________________________"; + "_______________________________________________________________________________"; Ui.helpCommand(); assertEquals(capturedOutputStream.toString().trim(), result); } @Test public void testPrintBye() { - String result = "____________________________________________________________" + System.lineSeparator() + + String result = "_______________________________________________________________________________" + + System.lineSeparator() + "Thank you for using Omnitravel" + System.lineSeparator() + "We hope to see you again! Goodbye!" + System.lineSeparator() + - "____________________________________________________________"; + "_______________________________________________________________________________"; Ui.printBye(); assertEquals(capturedOutputStream.toString().trim(), result); } @Test public void testPrintGreeting() { - String result = "____________________________________________________________" + System.lineSeparator() + + String result = "_______________________________________________________________________________" + + System.lineSeparator() + " ____ _ _ _ _____ ____ ____ _ _____ _\n" + "/ _ \\/ \\__/|/ \\ /|/ \\/__ __\\/ __\\/ _ \\/ \\ |\\/ __// \\\n" + "| / \\|| |\\/||| |\\ ||| | / \\ | \\/|| / \\|| | //| \\ | |\n" + "| \\_/|| | ||| | \\||| | | | | /| |-||| \\// | /_ | |_/\\\n" + "\\____/\\_/ \\|\\_/ \\|\\_/ \\_/ \\_/\\_\\\\_/ \\|\\__/ \\____\\\\____/)" + System.lineSeparator() + "Hello" + System.lineSeparator() + "How may I assist you?" + - System.lineSeparator() + "____________________________________________________________"; + System.lineSeparator() + + "_______________________________________________________________________________"; Ui.printGreeting(); assertEquals(capturedOutputStream.toString().trim(), result); } From 6470f7b5d520409b3da86df8aefb38c95b5e1ee5 Mon Sep 17 00:00:00 2001 From: ChinYanXu Date: Mon, 15 Apr 2024 03:35:16 +0800 Subject: [PATCH 8/8] Update chinyanxu.md --- docs/team/chinyanxu.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/team/chinyanxu.md b/docs/team/chinyanxu.md index a1bb6e4a2e..1c95847476 100644 --- a/docs/team/chinyanxu.md +++ b/docs/team/chinyanxu.md @@ -12,29 +12,29 @@ Given below are my contributions to the project. * New Feature: Added the find command [#25](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/25) * What it does: Enables the user to display all the travel activities stored in Omnitravel containing a certain - * keyword in their description +keyword in their description * Justification: User might only want to see a list of certain activities and this feature will enable them to do so. * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their - * search +search * New Feature: Added the findtag command [#89](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/89) * What it does: Enables the user to display all the travel activities stored in Omnitravel containing a certain tag * Justification: User might have tagged each activity to categorise them and might want to see which activity belongs - * to a tag. This feature enables them to do so. +to a tag. This feature enables them to do so. * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their - * search +search * New Feature: Added the findtype command [#91](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/91) * What it does: Enables the user to display all the travel activities stored in Omnitravel of a certain type * Justification: User might have sorted each activity into their respective types and might want to see which - * activity is under a type. This feature enables them to do so. +activity is under a type. This feature enables them to do so. * Highlights: User can use the `/exclude KEYWORD` optional inputs to further filter out what they want to see it their - * search +search #### Code contribution: [RepoSense link](https://nus-cs2113-ay2324s2.github.io/tp-dashboard/?search=chinyanxu&breakdown=true) * Enhancements implemented to existing features - * Added a way to delete travel activities from the list using keywords instead of just the index of the travel - * activity [#211](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/211) + * Added a way to delete travel activities from the list using keywords instead of just the index of the travel +activity [#211](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/211) * Documentation * User Guide: * Added documentation for feature `find` [#127](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/127) @@ -46,6 +46,6 @@ Given below are my contributions to the project. * Community: * Suggested fixes for other teams in the forum [#38](https://github.com/nus-cs2113-AY2324S2/forum/issues/38) * Contributions to team-based-tasks - * Contributed large portions of the JUnit tests + * Contributed large portions of the JUnit tests [#236](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/236) * Implemented a way to test text outputted to console [#92](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/92) - * Implemented a way to test if an exception is triggered + * Implemented a way to test if an exception is triggered [#236](https://github.com/AY2324S2-CS2113-T12-4/tp/pull/236)