diff --git a/docs/UserGuide.md b/docs/UserGuide.md index 20aeefa891a..50ed7a8ab54 100644 --- a/docs/UserGuide.md +++ b/docs/UserGuide.md @@ -76,6 +76,8 @@ This guide explains how you can use ProjectPRO to add contacts and manage your g Here are some annotations used in this guide: + +

:heavycheckmark: Acceptable values
@@ -619,12 +621,14 @@ You list all available time slots of your contacts. - Provide the full name of the contact using the `n/` prefix.

-

Acceptable values

-

NAME +

Acceptable values

+

NAME must be alphanumeric and cannot be blank.

+

+ **Example(s):** - `listtime n/Alex Yeoh` This lists all time slots when Alex Yeoh is available from your contact list. diff --git a/src/main/java/seedu/address/logic/commands/FindFreeTimeCommand.java b/src/main/java/seedu/address/logic/commands/FindFreeTimeCommand.java index 8aa119f5f23..0b160eb3b30 100644 --- a/src/main/java/seedu/address/logic/commands/FindFreeTimeCommand.java +++ b/src/main/java/seedu/address/logic/commands/FindFreeTimeCommand.java @@ -79,22 +79,24 @@ public boolean equals(Object other) { } // instanceof handles nulls - if (!(other instanceof GroupPersonCommand)) { + if (!(other instanceof FindFreeTimeCommand)) { return false; } - GroupPersonCommand otherGroupPersonCommand = (GroupPersonCommand) other; + FindFreeTimeCommand otherFindFreeTimeCommand = (FindFreeTimeCommand) other; // to check - return this.equals(otherGroupPersonCommand); + return this.duration.getDurationInMin() == otherFindFreeTimeCommand.duration.getDurationInMin() + && this.groupName.equals(otherFindFreeTimeCommand.groupName); } // to fix @Override - public java.lang.String toString() { + public String toString() { return new ToStringBuilder(this) - .add("toAddToGroup", "") - .toString(); + .add("group name", groupName) + .add("duration", duration.toString()) + .toString(); } } diff --git a/src/main/java/seedu/address/model/Duration.java b/src/main/java/seedu/address/model/Duration.java index 10275962bdc..76c5482c210 100644 --- a/src/main/java/seedu/address/model/Duration.java +++ b/src/main/java/seedu/address/model/Duration.java @@ -19,4 +19,9 @@ public int getDurationInMin() { return this.duration; } + public String toString() { + return Integer.toString(duration); + } + + } diff --git a/src/main/java/seedu/address/model/group/Group.java b/src/main/java/seedu/address/model/group/Group.java index f6c850b52c9..09bc81f3c08 100644 --- a/src/main/java/seedu/address/model/group/Group.java +++ b/src/main/java/seedu/address/model/group/Group.java @@ -231,6 +231,7 @@ public TimeIntervalList findFreeTime(Duration duration) throws CommandException freeTime = freeTime.findOverlap(second, duration); } } + return freeTime; } diff --git a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java index dd9cf6d820e..0b41ee7dc67 100644 --- a/src/test/java/seedu/address/logic/commands/CommandTestUtil.java +++ b/src/test/java/seedu/address/logic/commands/CommandTestUtil.java @@ -3,6 +3,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; import static seedu.address.logic.parser.CliSyntax.PREFIX_ADDRESS; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DURATION; import static seedu.address.logic.parser.CliSyntax.PREFIX_EMAIL; import static seedu.address.logic.parser.CliSyntax.PREFIX_FREETIME; import static seedu.address.logic.parser.CliSyntax.PREFIX_GROUPREMARK; @@ -95,6 +96,20 @@ public class CommandTestUtil { public static final String VALID_GROUP_REMARK_OTHERS = "gU4&😊!"; public static final String GROUP_REMARK_OTHERS_DESC = " " + PREFIX_GROUPREMARK + VALID_GROUP_REMARK_OTHERS; + public static final String DURATION_THIRTY = "30"; + public static final String VALID_DURATION_THIRTY = " " + PREFIX_DURATION + DURATION_THIRTY; + public static final String INVALID_DURATION_NEGATIVE = "-1"; + public static final String INVALID_DURATION_NEGATIVE_DESC = " " + PREFIX_DURATION + INVALID_DURATION_NEGATIVE; + public static final String INVALID_DURATION_ZERO = "0"; + public static final String INVALID_DURATION_ZERO_DESC = " " + PREFIX_DURATION + INVALID_DURATION_ZERO; + public static final String INVALID_DURATION_MAX = "10080"; + public static final String INVALID_DURATION_MAX_DESC = " " + PREFIX_DURATION + INVALID_DURATION_MAX; + + public static final String INVALID_DURATION_CHAR = "aaa"; + public static final String INVALID_DURATION_CHAR_DESC = " " + PREFIX_DURATION + INVALID_DURATION_CHAR; + + + /** diff --git a/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandIntegrationTest.java b/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandIntegrationTest.java new file mode 100644 index 00000000000..386ecffaccc --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandIntegrationTest.java @@ -0,0 +1,317 @@ +package seedu.address.logic.commands; + +import static org.junit.jupiter.api.Assertions.fail; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandFailure; +import static seedu.address.logic.commands.CommandTestUtil.assertCommandSuccess; +import static seedu.address.logic.commands.FindFreeTimeCommand.MESSAGE_NOT_ALL_FREE; +import static seedu.address.logic.commands.FindFreeTimeCommand.MESSAGE_SUCCESS; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.Messages; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.model.AddressBook; +import seedu.address.model.Duration; +import seedu.address.model.Model; +import seedu.address.model.ModelManager; +import seedu.address.model.UserPrefs; +import seedu.address.model.group.Group; +import seedu.address.model.person.Person; +import seedu.address.testutil.GroupBuilder; +import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.TypicalTimeIntervals; + + +public class FindFreeTimeCommandIntegrationTest { + + // success -> no changes to model and expected message + // failure -> command on actualModel throws expected error message + + + // group don't exist + @Test + public void execute_groupNotExist_unSuccessful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withName("Nicholas").build(); + ab.addGroup(group); + ab.addPerson(person); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS", new Duration(60)); + + assertCommandFailure(command, actualModel, Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND); + } + + // group exist but no people + @Test + public void execute_groupExistIsEmpty_unSuccessful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withName("Nicholas").build(); + ab.addGroup(group); + ab.addPerson(person); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(60)); + + assertCommandFailure(command, actualModel, "Group is empty"); + } + + // group exist got people but no time + @Test + public void execute_groupExistContactNotFree_unSuccessful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withName("Nicholas").build(); + try { + group.addPerson(person); + person.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(person); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(60)); + String message = String.format(MESSAGE_NOT_ALL_FREE, person.getName().toString()); + + assertCommandFailure(command, actualModel, message); + } + + // group exist got people got time but no overlap + @Test + public void execute_groupExistContactNoOverlap_unSuccessful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_TWO_NO_OVERLAP); // 1100 - 1200 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A); // 1000 - 1100 + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(60)); + String message = MESSAGE_SUCCESS; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + } + + // group exist got people got time got overlap but don't fit duration + @Test + public void execute_groupExistContactOverlapNoFitDuration_unSuccessful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_ONE_NO_OVERLAP); // 1000 - 1100 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A); // 1000 - 1100 + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(61)); + String message = MESSAGE_SUCCESS; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + } + + + + // group exist got people got time got overlap and fit duration + @Test + public void execute_groupExistContactOverlapFitDuration_successful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_ONE_NO_OVERLAP); // 1000 - 1100 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A); // 1000 - 1100 + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(60)); + String message = MESSAGE_SUCCESS + + "1. MON 1000 - MON 1100 \n"; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + } + + // multiple overlaps on the same day + @Test + public void execute_groupExistContactMultipleOverlapFitDuration_successful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A); // 1030 - 1130 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A); // 1100 - 1200 + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A); // 1200 - 1300 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_HALFOVERLAP_A); // 1230 - 1330 + + + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(30)); + String message = MESSAGE_SUCCESS + + "1. MON 1100 - MON 1130 \n" + + "2. MON 1230 - MON 1300 \n"; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + } + + + // multiple overlaps across days + @Test + public void execute_groupExistContactMultipleOverlapDifferentDaysFitDuration_successful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_MONTUE_ONE); // MON 1100 - TUE 1400 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_MONWED_ONE); // MON 1200 - WED 1500 + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_THUSAT_TWO); // THU 1200 - SAT 1800 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_SATSUN_TWO); // SAT 1200 - SUN 1800 + + + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(360)); + String message = MESSAGE_SUCCESS + + "1. MON 1200 - TUE 1400 \n" + + "2. SAT 1200 - SAT 1800 \n"; + FindFreeTimeCommand commandAnother = new FindFreeTimeCommand("CS2100", new Duration(361)); + String messageAnother = MESSAGE_SUCCESS + + "1. MON 1200 - TUE 1400 \n"; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + + assertCommandSuccess(commandAnother, actualModel, + messageAnother, expectedModel); + } + + // multiple overlaps across days and only the 14h timeslot + @Test + public void execute_groupExistContactOverlapDifferentDaysFitDuration_successful() { + AddressBook ab = new AddressBook(); + Group group = new GroupBuilder().withName("CS2100").build(); + Person personOne = new PersonBuilder().withName("Nicholas").build(); + Person personTwo = new PersonBuilder().withName("Zhen Dong").build(); + + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_MONTUE_ONE); // MON 1100 - TUE 1400 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_MONWED_ONE); // MON 1200 - WED 1500 + personOne.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_THUSAT_TWO); // THU 1200 - SAT 1800 + personTwo.addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_SATSUN_TWO); // SAT 1200 - SUN 1800 + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + personOne.addGroup(group); + personTwo.addGroup(group); + } catch (CommandException e) { + fail(); + } + ab.addGroup(group); + ab.addPerson(personOne); + + Model actualModel = new ModelManager(ab, new UserPrefs()); + Model expectedModel = new ModelManager(ab, new UserPrefs()); + + FindFreeTimeCommand command = new FindFreeTimeCommand("CS2100", new Duration(840)); + String message = MESSAGE_SUCCESS + + "1. MON 1200 - TUE 1400 \n"; + + // inbetween 6h and 26h + FindFreeTimeCommand commandAnother = new FindFreeTimeCommand("CS2100", new Duration(1559)); + String messageAnother = MESSAGE_SUCCESS + + "1. MON 1200 - TUE 1400 \n"; + + FindFreeTimeCommand commandExceed = new FindFreeTimeCommand("CS2100", new Duration(1561)); + String messageExceed = MESSAGE_SUCCESS; + + assertCommandSuccess(command, actualModel, + message, expectedModel); + + assertCommandSuccess(commandAnother, actualModel, + messageAnother, expectedModel); + + assertCommandSuccess(commandExceed, actualModel, + messageExceed, expectedModel); + + } + + + + +} diff --git a/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandTest.java b/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandTest.java new file mode 100644 index 00000000000..46a5496359b --- /dev/null +++ b/src/test/java/seedu/address/logic/commands/FindFreeTimeCommandTest.java @@ -0,0 +1,525 @@ +package seedu.address.logic.commands; + +import static java.util.Objects.requireNonNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; +import static seedu.address.logic.commands.FindFreeTimeCommand.MESSAGE_NOT_ALL_FREE; +import static seedu.address.logic.commands.FindFreeTimeCommand.MESSAGE_SUCCESS; +import static seedu.address.testutil.Assert.assertThrows; + +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.function.Predicate; + +import org.junit.jupiter.api.Test; + +import javafx.collections.ObservableList; +import javafx.util.Pair; +import seedu.address.commons.core.GuiSettings; +import seedu.address.logic.Messages; +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.logic.parser.exceptions.ParseException; +import seedu.address.model.Duration; +import seedu.address.model.Model; +import seedu.address.model.ReadOnlyAddressBook; +import seedu.address.model.ReadOnlyUserPrefs; +import seedu.address.model.TimeInterval; +import seedu.address.model.TimeIntervalList; +import seedu.address.model.group.Group; +import seedu.address.model.group.GroupList; +import seedu.address.model.group.GroupRemark; +import seedu.address.model.person.Name; +import seedu.address.model.person.Person; +import seedu.address.testutil.GroupBuilder; +import seedu.address.testutil.PersonBuilder; +import seedu.address.testutil.TypicalTimeIntervals; + + + + +public class FindFreeTimeCommandTest { + + @Test + public void constructor_nullArguments_throwsNullPointerException() { + assertThrows(NullPointerException.class, () -> new FindFreeTimeCommand(null, null)); + } + + // Group does not exist + @Test + public void execute_groupDoesNotExist_unSuccesful() { + ModelStubGroup model = new ModelStubGroup("CS2100"); + + Command command = new FindFreeTimeCommand("CS2103", new Duration(60)); + + assertThrows(CommandException.class, Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND, () -> command.execute(model)); + } + + // One person in group not free + @Test + public void execute_contactNotFree_unSuccessful() { + Person person = new PersonBuilder().withName("John") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A) + .build(); + + Group groupOne = new GroupBuilder().withName("CS2102").build(); + try { + groupOne.addPerson(person); + } catch (CommandException e) { + fail(); + } + ModelStubGroup model = new ModelStubGroup("CS2102"); + Group groupTwo = new GroupBuilder().withName("CS2100").withListOfGroupMates("Kailash").build(); + model.addGroup(groupTwo); + + Command command = new FindFreeTimeCommand("CS2100", new Duration(60)); + + String message = String.format(MESSAGE_NOT_ALL_FREE, "Kailash"); + + assertThrows(CommandException.class, String.format(message), () -> command.execute(model)); + + } + + // Group exist but empty + @Test + public void execute_groupIsEmpty_unSuccessful() { + Group group = new GroupBuilder().withName("CS2100").build(); + + ModelStubGroup model = new ModelStubGroup(group); + String message = "Group is empty"; + + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(60)); + + assertThrows(CommandException.class, message, () -> command.execute(model)); + + } + + // One person exactly fit duration + @Test + public void execute_personIsFree_successful() { + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A).build(); + try { + group.addPerson(person); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + String message = MESSAGE_SUCCESS + "1. MON 1000 - MON 1100 \n"; + + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(60)); + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + // One person more than duration + @Test + public void execute_personNotFree_unSuccessful() { + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A).build(); + try { + group.addPerson(person); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + String message = MESSAGE_SUCCESS; + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(61)); + + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + + // One person less than duration + + + @Test + public void execute_personFree_successful() { + Group group = new GroupBuilder().withName("CS2100").build(); + Person person = new PersonBuilder().withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A).build(); + try { + group.addPerson(person); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + String message = MESSAGE_SUCCESS + + "1. MON 1000 - MON 1100 \n"; + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(59)); + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + + // time interval end and start are the same, 1030 - 1100 and 1100 - 1130 + // can't have a meeting from 1100 - 1100 + @Test + public void execute_overlapStartEndSame_unSuccessful() { + Person personOne = new PersonBuilder().withName("Zhen Dong") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A) + .build(); // 10 - 11 + Person personTwo = new PersonBuilder().withName("Kailash") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A) + .build(); // 11 - 12 + + Group group = new GroupBuilder().withName("CS2100").build(); + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(1)); + String message = MESSAGE_SUCCESS; + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + // time interval overlap for 2 people + @Test + public void execute_overlapTwo_successful() { + Person personOne = new PersonBuilder().withName("Zhen Dong") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A) + .build(); // 1030 - 1130 + personOne + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A); // 1200 - 1300 + + Person personTwo = new PersonBuilder().withName("Kailash") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A) + .build(); // 11 - 12 + personTwo + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_HALFOVERLAP_A); // 1230 - 1300 + + Group group = new GroupBuilder().withName("CS2100").build(); + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(30)); + String message = MESSAGE_SUCCESS + + "1. MON 1100 - MON 1130 \n" + + "2. MON 1230 - MON 1300 \n"; + + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + // Have group and people with time but duration too long + // time interval overlap for 2 people + @Test + public void execute_overlapTwo_unSuccessful() { + Person personOne = new PersonBuilder().withName("Zhen Dong") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A) + .build(); // 1030 - 1130 + personOne + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A); // 1200 - 1300 + + Person personTwo = new PersonBuilder().withName("Kailash") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A) + .build(); // 11 - 12 + personTwo + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_HALFOVERLAP_A); // 1230 - 1300 + + Group group = new GroupBuilder().withName("CS2100").build(); + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(31)); + String message = MESSAGE_SUCCESS; + + try { + CommandResult result = command.execute(model); + assertEquals(message, result.getFeedbackToUser()); + } catch (CommandException | ParseException e) { + fail(); + } + + } + + + + // One person missing time interval + @Test + public void execute_missingInterval_unSuccessful() { + Person personOne = new PersonBuilder().withName("Zhen Dong") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A) + .build(); // 1030 - 1130 + personOne + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A); // 1200 - 1300 + + Person personTwo = new PersonBuilder().withName("Kailash") + .withTimeInterval(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A) + .build(); // 11 - 12 + personTwo + .addFreeTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_HALFOVERLAP_A); // 1230 - 1300 + + Person personThree = new PersonBuilder().withName("Nicholas").build(); + + Group group = new GroupBuilder().withName("CS2100").build(); + + try { + group.addPerson(personOne); + group.addPerson(personTwo); + group.addPerson(personThree); + } catch (CommandException e) { + fail(); + } + + ModelStubGroup model = new ModelStubGroup(group); + Command command = new FindFreeTimeCommand(group.getGroupName(), new Duration(30)); + String message = String.format(MESSAGE_NOT_ALL_FREE, personThree.getName().toString()); + + + assertThrows(CommandException.class, message, () -> command.execute(model)); + + } + + + + + + + + private abstract class ModelStub implements Model { + + @Override + public void setUserPrefs(ReadOnlyUserPrefs userPrefs) { + throw new AssertionError("This method should not be called"); + } + + @Override + public ReadOnlyUserPrefs getUserPrefs() { + throw new AssertionError("This method should not be called"); + } + + @Override + public GuiSettings getGuiSettings() { + throw new AssertionError("This method should not be called"); + } + + @Override + public void setGuiSettings(GuiSettings guiSettings) { + throw new AssertionError("This method should not be called"); + } + + @Override + public Path getAddressBookFilePath() { + throw new AssertionError("This method should not be called"); + } + + @Override + public void setAddressBookFilePath(Path addressBookFilePath) { + throw new AssertionError("This method should not be called"); + } + + @Override + public void setAddressBook(ReadOnlyAddressBook addressBook) { + throw new AssertionError("This method should not be called"); + } + + @Override + public ReadOnlyAddressBook getAddressBook() { + throw new AssertionError("This method should not be called"); + } + + + @Override + public void addPerson(Person person) { + throw new AssertionError("This method should not be called"); + } + + @Override + public Person deletePerson(String personName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public boolean hasPerson(Person person) { + throw new AssertionError("This method should not be called"); + } + + @Override + public boolean hasPerson(Name personName) { + throw new AssertionError("This method should not be called"); + } + + @Override + public Pair groupPerson(String personName, String groupName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public Pair ungroupPerson(String personName, String groupName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public String addTimeToPerson(Name toAddPerson, ArrayList toAddTime) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public TimeIntervalList getTimeFromPerson(Name personName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public String deleteTimeFromPerson(Name personName, ArrayList toDeleteTime) { + throw new AssertionError("This method should not be called"); + } + + @Override + public void addGroup(Group g) { + throw new AssertionError("This method should not be called"); + } + + @Override + public Group deleteGroup(String groupName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public boolean hasGroup(Group group) { + throw new AssertionError("This method should not be called"); + } + + @Override + public Group findGroup(String groupName) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public Group addGroupRemark(String groupName, GroupRemark groupRemark) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public String addTimeToGroup(Group toAdd, ArrayList toAddTime) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public String deleteTimeFromGroup(Group group, ArrayList toDeleteTime) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public TimeIntervalList getTimeFromGroup(Group group) throws CommandException { + throw new AssertionError("This method should not be called"); + } + + @Override + public ObservableList getFilteredPersonList() { + throw new AssertionError("This method should not be called"); + } + + @Override + public ObservableList getFilteredGroupList() { + throw new AssertionError("This method should not be called"); + } + + @Override + public void updateFilteredPersonList(Predicate predicate) { + throw new AssertionError("This method should not be called"); + } + + @Override + public void updateFilteredGroupList(Predicate predicate) { + throw new AssertionError("This method should not be called"); + } + + @Override + public boolean hasEmail(Person toAdd) { + throw new AssertionError("This method should not be called"); + } + + @Override + public boolean hasPhone(Person toAdd) { + throw new AssertionError("This method should not be called"); + } + } + + private class ModelStubGroup extends ModelStub { + + private final Group validGroup; + + private final GroupList groupList = new GroupList(); + + ModelStubGroup(String groupName) { + validGroup = new GroupBuilder().withName(groupName).build(); + groupList.add(validGroup); + } + ModelStubGroup(Group group) { + requireNonNull(group); + validGroup = group; + groupList.add(validGroup); + } + + public void addPersonToGroup(Person person) throws CommandException { + validGroup.addPerson(person); + } + + public void addGroup(Group group) { + requireNonNull(group); + groupList.add(group); + } + + + public Group findGroup(String groupName) throws CommandException { + for (Group group : groupList) { + if (group.nameEquals(groupName)) { + return group; + } + } + throw new CommandException(Messages.MESSAGE_NO_GROUP_WITH_NAME_FOUND); + + } + + + + + } + +} diff --git a/src/test/java/seedu/address/logic/parser/FindFreeTimeCommandParserTest.java b/src/test/java/seedu/address/logic/parser/FindFreeTimeCommandParserTest.java new file mode 100644 index 00000000000..fe4367f6a23 --- /dev/null +++ b/src/test/java/seedu/address/logic/parser/FindFreeTimeCommandParserTest.java @@ -0,0 +1,82 @@ +package seedu.address.logic.parser; + +import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT; +import static seedu.address.logic.commands.CommandTestUtil.GROUP_DESC_BOB; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_DURATION_MAX_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_DURATION_NEGATIVE_DESC; +import static seedu.address.logic.commands.CommandTestUtil.INVALID_DURATION_ZERO_DESC; +import static seedu.address.logic.commands.CommandTestUtil.VALID_DURATION_THIRTY; +import static seedu.address.logic.commands.CommandTestUtil.VALID_GROUP_BOB; +import static seedu.address.logic.parser.CliSyntax.PREFIX_DURATION; +import static seedu.address.logic.parser.CliSyntax.PREFIX_GROUPTAG; +import static seedu.address.logic.parser.CommandParserTestUtil.assertParseFailure; +import static seedu.address.logic.parser.CommandParserTestUtil.assertParseSuccess; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.Command; +import seedu.address.logic.commands.FindFreeTimeCommand; +import seedu.address.model.Duration; + +public class FindFreeTimeCommandParserTest { + private final FindFreeTimeCommandParser parser = new FindFreeTimeCommandParser(); + + @Test + public void parse_allFieldsPresent_success() { + Command command = new FindFreeTimeCommand(VALID_GROUP_BOB, new Duration(30)); + String userInput = GROUP_DESC_BOB + VALID_DURATION_THIRTY; + assertParseSuccess(parser, userInput, command); + } + + // group missing + @Test + public void parse_groupFieldMissing_unSuccessful() { + String userInput = GROUP_DESC_BOB; + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindFreeTimeCommand.MESSAGE_USAGE); + assertParseFailure(parser, userInput, expectedMessage); + } + + // duration missing + @Test + public void parse_durationFieldMissing_unSuccessful() { + String userInput = VALID_DURATION_THIRTY; + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindFreeTimeCommand.MESSAGE_USAGE); + assertParseFailure(parser, userInput, expectedMessage); + } + + // duration and group empty with prefix + @Test + public void parse_emptyPrefix_unSuccessful() { + String userInput = PREFIX_GROUPTAG.getPrefix() + PREFIX_DURATION.getPrefix(); + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, FindFreeTimeCommand.MESSAGE_USAGE); + assertParseFailure(parser, userInput, expectedMessage); + } + + // duration is 0 + @Test + public void parse_zeroDuration_unSuccessful() { + String userInput = GROUP_DESC_BOB + INVALID_DURATION_ZERO_DESC; + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, + "You can't have a meeting without specifying a duration"); + assertParseFailure(parser, userInput, expectedMessage); + } + + // duration < 0 + @Test + public void parse_negativeDuration_unSuccessful() { + String userInput = GROUP_DESC_BOB + INVALID_DURATION_NEGATIVE_DESC; + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, + "Duration specified is less than 0"); + assertParseFailure(parser, userInput, expectedMessage); + } + + // duration exceeds number of minutes in a week + @Test + public void parse_exceedMaxDuration_unSuccessful() { + String userInput = GROUP_DESC_BOB + INVALID_DURATION_MAX_DESC; + String expectedMessage = String.format(MESSAGE_INVALID_COMMAND_FORMAT, + String.format("The value you entered, %d is beyond the time you have in a week", 10080)); + assertParseFailure(parser, userInput, expectedMessage); + } + +} diff --git a/src/test/java/seedu/address/model/TimeIntervalListTest.java b/src/test/java/seedu/address/model/TimeIntervalListTest.java new file mode 100644 index 00000000000..5cd74941903 --- /dev/null +++ b/src/test/java/seedu/address/model/TimeIntervalListTest.java @@ -0,0 +1,94 @@ +package seedu.address.model; + +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; + +import org.junit.jupiter.api.Test; + +import seedu.address.logic.commands.exceptions.CommandException; +import seedu.address.testutil.TypicalTimeIntervals; + + +public class TimeIntervalListTest { + + @Test + public void addTime_arrayList_true() { + TimeIntervalList list = new TimeIntervalList(); + TimeInterval timeIntervalFirst = TypicalTimeIntervals.TIME_INTERVAL_MONTUE_ONE; // MON 1100 - TUE 1400 + TimeInterval timeIntervalSecond = TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_B; // MON 0500 - MON 1200; + list.addTime(timeIntervalFirst); + ArrayList toAdd = new ArrayList<>(); + toAdd.add(timeIntervalSecond); + + ArrayList toAddNoClash = new ArrayList<>(); + TimeInterval timeIntervalThird = TypicalTimeIntervals.TIME_INTERVAL_THUSAT_TWO; + toAddNoClash.add(timeIntervalThird); + + StringBuilder errorMessage = new StringBuilder("There is a clash in these input timings with " + + "your existing timings:\n"); + errorMessage.append("MON 0500 - MON 1200 \n"); + + StringBuilder passMessage = new StringBuilder("These times have been added:\n"); + passMessage.append("THU 1200 - SAT 1800 \n"); + + assertTrue(list.addTime(toAdd).equals(errorMessage.toString())); + assertTrue(list.addTime(toAddNoClash).equals(passMessage.toString())); + } + + @Test + public void deleteTime_arrayList_true() { + TimeIntervalList list = new TimeIntervalList(); + TimeInterval timeIntervalFirst = TypicalTimeIntervals.TIME_INTERVAL_MONTUE_ONE; // MON 1100 - TUE 1400 + TimeInterval timeIntervalSecond = TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_B; // MON 0500 - MON 1200; + list.addTime(timeIntervalFirst); + ArrayList toAdd = new ArrayList<>(); + toAdd.add(timeIntervalFirst); + + ArrayList toAddNoMatch = new ArrayList<>(); + toAdd.add(timeIntervalSecond); + + StringBuilder errorMessage = new StringBuilder("These times were not in the list:\n"); + errorMessage.append("MON 0500 - MON 1200 \n"); + errorMessage.append("These times have been deleted:\n"); + errorMessage.append("MON 1100 - TUE 1400 \n"); + StringBuilder passMessage = new StringBuilder("These times have been deleted:\n"); + + try { + assertTrue(list.deleteTime(toAdd).equals(errorMessage.toString())); + assertTrue(list.deleteTime(toAddNoMatch).equals(passMessage.toString())); + } catch (CommandException ignore) { + // do nothing + } + + } + + + @Test + public void execute_findOverlap_true() { + TimeIntervalList firstList = new TimeIntervalList(); + TimeIntervalList secondList = new TimeIntervalList(); + + Duration duration = new Duration(30); + + firstList.addTime(TypicalTimeIntervals.TIME_INTERVAL_TWO_OVERLAP_A); // MON 1030 - MON 1130 + secondList.addTime(TypicalTimeIntervals.TIME_INTERVAL_THREE_OVERLAP_A); // MON 1100 - MON 1200 + + firstList.addTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_OVERLAP_A); // MON 1200 - MON 1300 + secondList.addTime(TypicalTimeIntervals.TIME_INTERVAL_FIVE_HALFOVERLAP_A); // MON 1230 - MON 1330 + + TimeIntervalList expectedList = new TimeIntervalList(); + TimeInterval expectedTimeFirst = TypicalTimeIntervals.TIME_INTERVAL_OVERLAPONE; // MON 1100 - MON 1130 + TimeInterval expectedTimeSecond = TypicalTimeIntervals.TIME_INTERVAL_OVERLAPTWO; // MON 1230 - MON 1300 + expectedList.addTime(expectedTimeFirst); + expectedList.addTime(expectedTimeSecond); + + assertTrue(firstList.findOverlap(secondList, duration).equals(expectedList)); + } + + + + + + +} diff --git a/src/test/java/seedu/address/model/TimeIntervalTest.java b/src/test/java/seedu/address/model/TimeIntervalTest.java index f46fc7a31ce..8024a23a6d3 100644 --- a/src/test/java/seedu/address/model/TimeIntervalTest.java +++ b/src/test/java/seedu/address/model/TimeIntervalTest.java @@ -160,14 +160,29 @@ public void isValidTimeIntervalLogic_inValidInputEndBeforeStartB_returnFalse() { assertFalse(TimeInterval.isValidTimeIntervalLogic(start, end)); } + @Test + public void execute_sameDay_returnTrue() { + TimeInterval timeInterval = TypicalTimeIntervals.TIME_INTERVAL_ONE_OVERLAP_A; // MON 1000 - MON 1100 + Duration durationWithin = new Duration(59); + Duration durationEqual = new Duration(60); + Duration durationExceed = new Duration(61); + assertTrue(timeInterval.allows(durationWithin)); + assertTrue(timeInterval.allows(durationEqual)); + assertFalse(timeInterval.allows(durationExceed)); + } + @Test + public void execute_differentDay_returnTrue() { + TimeInterval timeInterval = TypicalTimeIntervals.TIME_INTERVAL_MONTUE_ONE; // MON 1100 - TUE 1400 is 27 Hours + Duration durationWithin = new Duration(1619); + Duration durationEqual = new Duration(1620); + Duration durationExceed = new Duration(1621); + assertTrue(timeInterval.allows(durationWithin)); + assertTrue(timeInterval.allows(durationEqual)); + assertFalse(timeInterval.allows(durationExceed)); - - - - - + } diff --git a/src/test/java/seedu/address/model/TimeTest.java b/src/test/java/seedu/address/model/TimeTest.java new file mode 100644 index 00000000000..6368e293a2b --- /dev/null +++ b/src/test/java/seedu/address/model/TimeTest.java @@ -0,0 +1,89 @@ +package seedu.address.model; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.time.DayOfWeek; +import java.time.LocalTime; + +import org.junit.jupiter.api.Test; + +import seedu.address.testutil.TypicalTimeIntervals; + + + +public class TimeTest { + + @Test + public void is_validTime_true() { + String timeStringInvalid = "I am not valid"; + String timeStringValid = "mon 1200"; + assertFalse(Time.isValidTime(timeStringInvalid)); + assertTrue(Time.isValidTime(timeStringValid)); + } + + @Test + public void getDuration_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + Time timeSecond = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getEnd(); // MON 2300 + assertTrue(time.getDurationInMin() == 2760); + assertTrue(timeSecond.getDurationInMin() == 2820); + } + + @Test + public void compareTo_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + Time timeSecond = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getEnd(); // MON 2300 + assertTrue(time.compareTo(timeSecond) < 0); + } + + + @Test + public void toString_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + assertTrue(time.toString().equals("MON 2200")); + } + + @Test + public void equals_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + assertTrue(time.equals(time)); + } + + @Test + public void decodeDay_true() { + String mon = "mon"; + String tue = "TUE"; + String wed = "wEd"; + String thu = "THUR"; + String fri = "FRIDAY"; + String sat = "TURDAY"; + String sun = "SuN"; + + assertTrue(Time.decodeDay(mon).equals(DayOfWeek.MONDAY)); + assertTrue(Time.decodeDay(tue).equals(DayOfWeek.TUESDAY)); + assertTrue(Time.decodeDay(wed).equals(DayOfWeek.WEDNESDAY)); + assertTrue(Time.decodeDay(thu).equals(DayOfWeek.THURSDAY)); + assertTrue(Time.decodeDay(fri).equals(DayOfWeek.FRIDAY)); + assertTrue(Time.decodeDay(sat).equals(DayOfWeek.SATURDAY)); + assertTrue(Time.decodeDay(sun).equals(DayOfWeek.SUNDAY)); + } + + @Test + public void getDay_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + assertTrue(time.getDay().equals(DayOfWeek.MONDAY)); + + } + + @Test + public void getTime_true() { + Time time = TypicalTimeIntervals.TIME_INTERVAL_FOUR_NO_OVERLAP.getStart(); // MON 2200 + assertTrue(time.getTime().equals(LocalTime.of(22, 00))); + + } + + + + +} diff --git a/src/test/java/seedu/address/testutil/TypicalTimeIntervals.java b/src/test/java/seedu/address/testutil/TypicalTimeIntervals.java index 6c30524c25f..698ae8292bd 100644 --- a/src/test/java/seedu/address/testutil/TypicalTimeIntervals.java +++ b/src/test/java/seedu/address/testutil/TypicalTimeIntervals.java @@ -76,11 +76,18 @@ public class TypicalTimeIntervals { .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(12, 00)).build(), new TimeBuilder().withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(13, 00)) .build()).build(); + public static final TimeInterval TIME_INTERVAL_FIVE_HALFOVERLAP_A = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour( + DayOfWeek.MONDAY, LocalTime.of(12, 30)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(13, 30)) + .build()).build(); public static final TimeInterval TIME_INTERVAL_ONE_OVERLAP_B = new TimeIntervalBuilder() .withStartTimeAndEndTime(new TimeBuilder() - .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(5, 00)).build(), + .withDayAndHour( + DayOfWeek.MONDAY, LocalTime.of(5, 00)).build(), new TimeBuilder().withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(12, 00)) .build()).build(); @@ -101,4 +108,39 @@ public class TypicalTimeIntervals { .withDayAndHour(DayOfWeek.WEDNESDAY, LocalTime.of(6, 00)).build(), new TimeBuilder().withDayAndHour(DayOfWeek.FRIDAY, LocalTime.of(8, 00)) .build()).build(); + + public static final TimeInterval TIME_INTERVAL_MONTUE_ONE = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(11, 00)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.TUESDAY, LocalTime.of(14, 00)) + .build()).build(); + + public static final TimeInterval TIME_INTERVAL_MONWED_ONE = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(12, 00)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.WEDNESDAY, LocalTime.of(15, 00)) + .build()).build(); + + + public static final TimeInterval TIME_INTERVAL_THUSAT_TWO = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.THURSDAY, LocalTime.of(12, 00)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.SATURDAY, LocalTime.of(18, 00)) + .build()).build(); + public static final TimeInterval TIME_INTERVAL_SATSUN_TWO = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.SATURDAY, LocalTime.of(12, 00)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.SUNDAY, LocalTime.of(18, 00)) + .build()).build(); + + public static final TimeInterval TIME_INTERVAL_OVERLAPONE = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(11, 00)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(11, 30)) + .build()).build(); + public static final TimeInterval TIME_INTERVAL_OVERLAPTWO = new TimeIntervalBuilder() + .withStartTimeAndEndTime(new TimeBuilder() + .withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(12, 30)).build(), + new TimeBuilder().withDayAndHour(DayOfWeek.MONDAY, LocalTime.of(13, 00)) + .build()).build(); }