From 03d407f70b562c718ca6a7f6dc036f76a5fcfed0 Mon Sep 17 00:00:00 2001 From: Antonia Devina Date: Mon, 7 Nov 2016 20:55:48 +0800 Subject: [PATCH] test cases --- src/test/java/guitests/GapCommandTest.java | 78 +++++++++---------- .../model/task/DateTimeInfoTest.java | 14 ---- .../flexitrack/testutil/TypicalTestTasks.java | 48 ++++++------ 3 files changed, 63 insertions(+), 77 deletions(-) diff --git a/src/test/java/guitests/GapCommandTest.java b/src/test/java/guitests/GapCommandTest.java index ffcf640098b9..7ece445d2395 100644 --- a/src/test/java/guitests/GapCommandTest.java +++ b/src/test/java/guitests/GapCommandTest.java @@ -35,14 +35,14 @@ public static void setupMoreEvents(){ String tempPreferencesFile = saveFolder.getRoot().getPath() + "TempPreferences.json"; logic = new LogicManager(model, new StorageManager(tempFlexiTrackerFile, tempPreferencesFile)); - TestTask[] typicalTask = td.getTypicalSortedTasks(); - for (TestTask task: typicalTask){ - try { - model.addTask(new Task(task)); - } catch (DuplicateTaskException e) { - assert true; - } - } +// TestTask[] typicalTask = td.getTypicalSortedTasks(); +// for (TestTask task: typicalTask){ +// try { +// model.addTask(new Task(task)); +// } catch (DuplicateTaskException e) { +// assert true; +// } +// } TestTask[] typicalEvent = td.getTypicalEventTasks(); for (TestTask task: typicalEvent){ @@ -59,32 +59,32 @@ public void gap_hour_success() throws Exception { // using the word String gapUserCommand = "gap hour"; String messageShown = "The earliest 1 hour free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 11:00" + " to: " + "Nov 08 2016 15:00" - + "\nBetween: " + "Nov 08 2016 16:00" + " to: " + "Nov 09 2016 14:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 11:00" + " to: " + "Nov 08 2017 15:00" + + "\nBetween: " + "Nov 08 2017 16:00" + " to: " + "Nov 09 2017 14:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // using a single letter to represent the time gapUserCommand = "gap 3h"; messageShown = "The earliest 3 hours free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 11:00" + " to: " + "Nov 08 2016 15:00" - + "\nBetween: " + "Nov 08 2016 16:00" + " to: " + "Nov 09 2016 14:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 11:00" + " to: " + "Nov 08 2017 15:00" + + "\nBetween: " + "Nov 08 2017 16:00" + " to: " + "Nov 09 2017 14:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // using the complete word with s gapUserCommand = "gap 7 hours"; messageShown = "The earliest 7 hours free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 16:00" + " to: " + "Nov 09 2016 14:00" - + "\nBetween: " + "Nov 09 2016 16:00" + " to: " + "Nov 12 2016 10:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 16:00" + " to: " + "Nov 09 2017 14:00" + + "\nBetween: " + "Nov 09 2017 16:00" + " to: " + "Nov 12 2017 10:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // specify the number of time slot found gapUserCommand = "gap 4h n/2"; messageShown = "The earliest 4 hours free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 11:00" + " to: " + "Nov 08 2016 15:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 11:00" + " to: " + "Nov 08 2017 15:00"; assertGapCommandSuccess(gapUserCommand, messageShown); } @@ -93,53 +93,53 @@ public void gap_minute_success() throws Exception { // using a single letter to represent minute String gapUserCommand = "gap 40m"; String messageShown = "The earliest 40 minutes free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 11:00" + " to: " + "Nov 08 2016 15:00" - + "\nBetween: " + "Nov 08 2016 16:00" + " to: " + "Nov 09 2016 14:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 11:00" + " to: " + "Nov 08 2017 15:00" + + "\nBetween: " + "Nov 08 2017 16:00" + " to: " + "Nov 09 2017 14:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // using the proper word + s gapUserCommand = "gap 30minutes"; messageShown = "The earliest 30 minutes free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 08 2016 11:00" + " to: " + "Nov 08 2016 15:00" - + "\nBetween: " + "Nov 08 2016 16:00" + " to: " + "Nov 09 2016 14:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 08 2017 11:00" + " to: " + "Nov 08 2017 15:00" + + "\nBetween: " + "Nov 08 2017 16:00" + " to: " + "Nov 09 2017 14:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // using the proper word with specified number of time slot gapUserCommand = "gap minute n/1"; messageShown = "The earliest 1 minute free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00"; assertGapCommandSuccess(gapUserCommand, messageShown); } @Test public void gap_day_success() throws Exception { // using a single letter to represent day - String gapUserCommand = "gap 2d"; + String gapUserCommand = "gap 2d n/4"; String messageShown = "The earliest 2 days free time are found... " - + "\nBetween: " + "Nov 09 2016 16:00" + " to: " + "Nov 12 2016 10:00" - + "\nBetween: " + "Nov 12 2016 14:00" + " to: " + "Nov 18 2016 09:00" - + "\nBetween: " + "Nov 20 2016 14:00" + " to: " + "Nov 22 2016 19:00"; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 09 2017 16:00" + " to: " + "Nov 12 2017 10:00" + + "\nBetween: " + "Nov 12 2017 14:00" + " to: " + "Nov 18 2017 09:00" + + "\nBetween: " + "Nov 20 2017 14:00" + " to: " + "Nov 22 2017 19:00"; assertGapCommandSuccess(gapUserCommand, messageShown); // using the proper word + s gapUserCommand = "gap 3 days"; messageShown = "The earliest 3 days free time are found... " - + "\nBetween: " + "Nov 12 2016 14:00" + " to: " + "Nov 18 2016 09:00" - + "\nBetween: " + "Nov 22 2016 21:00" + " to: " + "Nov 16 2017 19:00" - + "\nFree from: " + "Nov 16 2017 20:15" + " onwards. "; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 12 2017 14:00" + " to: " + "Nov 18 2017 09:00" + + "\nFree from: " + "Nov 22 2017 21:00" + " onwards. "; assertGapCommandSuccess(gapUserCommand, messageShown); // using the proper word with specified number of time slot gapUserCommand = "gap day n/6"; messageShown = "The earliest 1 day free time are found... " - + "\nBetween: now " + " to: " + "Nov 08 2016 09:00" - + "\nBetween: " + "Nov 09 2016 16:00" + " to: " + "Nov 12 2016 10:00" - + "\nBetween: " + "Nov 12 2016 14:00" + " to: " + "Nov 18 2016 09:00" - + "\nBetween: " + "Nov 20 2016 14:00" + " to: " + "Nov 22 2016 19:00" - + "\nBetween: " + "Nov 22 2016 21:00" + " to: " + "Nov 16 2017 19:00" - + "\nFree from: " + "Nov 16 2017 20:15" + " onwards. "; + + "\nBetween: now " + " to: " + "Nov 08 2017 09:00" + + "\nBetween: " + "Nov 09 2017 16:00" + " to: " + "Nov 12 2017 10:00" + + "\nBetween: " + "Nov 12 2017 14:00" + " to: " + "Nov 18 2017 09:00" + + "\nBetween: " + "Nov 20 2017 14:00" + " to: " + "Nov 22 2017 19:00" + + "\nFree from: " + "Nov 22 2017 21:00" + " onwards. "; assertGapCommandSuccess(gapUserCommand, messageShown); } diff --git a/src/test/java/seedu/flexitrack/model/task/DateTimeInfoTest.java b/src/test/java/seedu/flexitrack/model/task/DateTimeInfoTest.java index 6adf82a93bbe..725d0d639a6f 100644 --- a/src/test/java/seedu/flexitrack/model/task/DateTimeInfoTest.java +++ b/src/test/java/seedu/flexitrack/model/task/DateTimeInfoTest.java @@ -37,20 +37,6 @@ public void DateTimeInfo_ValidInputWithSpecificHours_returnsDate() { DateTimeInfoAndAssertCorrect(validInput, expectedSetTime); } - @Test - public void DateTimeInfo_RelaxValidInputWithNoSpecificHoursAndMinutes_returnsDate() { - final String validInput = "mon"; - final String expectedSetTime = "Nov 07 2016 08:00"; - DateTimeInfoAndAssertCorrect(validInput, expectedSetTime); - } - - @Test - public void DateTimeInfo_RelaxValidInputWithSpecificHours_returnsDate() { - final String validInput = "tuesday 10am"; - final String expectedSetTime = "Nov 08 2016 10:00"; - DateTimeInfoAndAssertCorrect(validInput, expectedSetTime); - } - @Test public void DateTimeInfo_RelativeValidInputWithNoSpecificHoursAndMinutes_returnsDate() { Calendar calendar = Calendar.getInstance(); diff --git a/src/test/java/seedu/flexitrack/testutil/TypicalTestTasks.java b/src/test/java/seedu/flexitrack/testutil/TypicalTestTasks.java index 5bd7bc0b6522..ddf28cd77c2a 100644 --- a/src/test/java/seedu/flexitrack/testutil/TypicalTestTasks.java +++ b/src/test/java/seedu/flexitrack/testutil/TypicalTestTasks.java @@ -74,30 +74,30 @@ public TypicalTestTasks() { // @@author A0127686R // Additional Event Task - lecture1 = new TaskBuilder().withName("lecture 1").withStartTime("Nov 08 2016 09:00") - .withEndTime("Nov 08 2016 11:00").withDueDate("Feb 29 2000 00:00").build(); - lecture2 = new TaskBuilder().withName("lecture 2").withStartTime("Nov 08 2016 15:00") - .withEndTime("Nov 08 2016 16:00").withDueDate("Feb 29 2000 00:00").build(); - lecture3 = new TaskBuilder().withName("lecture 3").withStartTime("Nov 09 2016 14:00") - .withEndTime("Nov 09 2016 16:00").withDueDate("Feb 29 2000 00:00").build(); - lecture4 = new TaskBuilder().withName("lecture 4").withStartTime("Nov 12 2016 10:00") - .withEndTime("Nov 12 2016 12:00").withDueDate("Feb 29 2000 00:00").build(); - lecture5 = new TaskBuilder().withName("lecture 5").withStartTime("Nov 12 2016 13:00") - .withEndTime("Nov 12 2016 14:00").withDueDate("Feb 29 2000 00:00").build(); - exam1 = new TaskBuilder().withName("exam 1").withStartTime("Nov 20 2016 09:00") - .withEndTime("Nov 20 2016 10:30").withDueDate("Feb 29 2000 00:00").build(); - exam2 = new TaskBuilder().withName("exam 2").withStartTime("Nov 20 2016 12:00") - .withEndTime("Nov 20 2016 14:00").withDueDate("Feb 29 2000 00:00").build(); - exam3 = new TaskBuilder().withName("exam 3").withStartTime("Nov 22 2016 19:00") - .withEndTime("Nov 22 2016 21:00").withDueDate("Feb 29 2000 00:00").build(); - study1 = new TaskBuilder().withName("study 1").withStartTime("Nov 18 2016 09:00") - .withEndTime("Nov 18 2016 23:00").withDueDate("Feb 29 2000 00:00").build(); - study2 = new TaskBuilder().withName("study 2").withStartTime("Nov 19 2016 06:00") - .withEndTime("Nov 19 2016 10:00").withDueDate("Feb 29 2000 00:00").build(); - past1 = new TaskBuilder().withName("past 1").withStartTime("Nov 01 2016 09:00") - .withEndTime("Nov 01 2016 11:00").withDueDate("Feb 29 2000 00:00").build(); - past2 = new TaskBuilder().withName("past 2").withStartTime("Oct 20 2016 15:00") - .withEndTime("Oct 20 2016 16:00").withDueDate("Feb 29 2000 00:00").build(); + lecture1 = new TaskBuilder().withName("lecture 1").withStartTime("Nov 08 2017 09:00") + .withEndTime("Nov 08 2017 11:00").withDueDate("Feb 29 2000 00:00").build(); + lecture2 = new TaskBuilder().withName("lecture 2").withStartTime("Nov 08 2017 15:00") + .withEndTime("Nov 08 2017 16:00").withDueDate("Feb 29 2000 00:00").build(); + lecture3 = new TaskBuilder().withName("lecture 3").withStartTime("Nov 09 2017 14:00") + .withEndTime("Nov 09 2017 16:00").withDueDate("Feb 29 2000 00:00").build(); + lecture4 = new TaskBuilder().withName("lecture 4").withStartTime("Nov 12 2017 10:00") + .withEndTime("Nov 12 2017 12:00").withDueDate("Feb 29 2000 00:00").build(); + lecture5 = new TaskBuilder().withName("lecture 5").withStartTime("Nov 12 2017 13:00") + .withEndTime("Nov 12 2017 14:00").withDueDate("Feb 29 2000 00:00").build(); + exam1 = new TaskBuilder().withName("exam 1").withStartTime("Nov 20 2017 09:00") + .withEndTime("Nov 20 2017 10:30").withDueDate("Feb 29 2000 00:00").build(); + exam2 = new TaskBuilder().withName("exam 2").withStartTime("Nov 20 2017 12:00") + .withEndTime("Nov 20 2017 14:00").withDueDate("Feb 29 2000 00:00").build(); + exam3 = new TaskBuilder().withName("exam 3").withStartTime("Nov 22 2017 19:00") + .withEndTime("Nov 22 2017 21:00").withDueDate("Feb 29 2000 00:00").build(); + study1 = new TaskBuilder().withName("study 1").withStartTime("Nov 18 2017 09:00") + .withEndTime("Nov 18 2017 23:00").withDueDate("Feb 29 2000 00:00").build(); + study2 = new TaskBuilder().withName("study 2").withStartTime("Nov 19 2017 06:00") + .withEndTime("Nov 19 2017 10:00").withDueDate("Feb 29 2000 00:00").build(); + past1 = new TaskBuilder().withName("past 1").withStartTime("Nov 01 2017 09:00") + .withEndTime("Nov 01 2017 11:00").withDueDate("Feb 29 2000 00:00").build(); + past2 = new TaskBuilder().withName("past 2").withStartTime("Oct 20 2017 15:00") + .withEndTime("Oct 20 2017 16:00").withDueDate("Feb 29 2000 00:00").build(); } catch (IllegalValueException e) { e.printStackTrace();