Skip to content

Commit

Permalink
Merge pull request #19 from AY1920S1-CS2113T-F14-3/master
Browse files Browse the repository at this point in the history
getting test.txt data set
  • Loading branch information
TehZiHuai authored Oct 29, 2019
2 parents c4918f5 + 7836cf2 commit 14df2cb
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 19 deletions.
15 changes: 15 additions & 0 deletions src/main/java/Operations/subTaskCreator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package Operations;

import CustomExceptions.RoomShareException;
import Enums.ExceptionType;
import Model_Classes.Assignment;

public class subTaskCreator {
public subTaskCreator(int index, String subTasks) throws RoomShareException {
if (TaskList.currentList().get(index) instanceof Assignment) {
((Assignment) TaskList.currentList().get(index)).setSubTasks(subTasks);
} else {
throw new RoomShareException(ExceptionType.subTask);
}
}
}
6 changes: 1 addition & 5 deletions src/main/java/RoomShare.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,7 @@ public void run() throws RoomShareException, IOException, InterruptedException {
try {
int index = parser.getIndexSubtask();
String subTasks = parser.getCommandLine();
if (TaskList.currentList().get(index) instanceof Assignment) {
((Assignment) TaskList.currentList().get(index)).setSubTasks(subTasks);
} else {
throw new RoomShareException(ExceptionType.subTask);
}
new subTaskCreator(index, subTasks);
} catch (RoomShareException e) {
ui.showError(e);
}
Expand Down
37 changes: 23 additions & 14 deletions src/test/java/CheckAnomalyTest.java
Original file line number Diff line number Diff line change
@@ -1,45 +1,54 @@
import CustomExceptions.RoomShareException;
import Enums.TimeUnit;
import Model_Classes.Meeting;
import Operations.CheckAnomaly;
import Operations.Storage;
import Operations.TaskList;
import Operations.Parser;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.sql.Time;
import java.util.Date;

public class CheckAnomalyTest {
private static final Parser parser = new Parser();
private static final Storage storage = new Storage();
private static Meeting meeting;
private static Meeting meeting1, meeting2, meeting3, meeting4, meeting5;
private static Date at1, at2, at3, at4, at5;
private static TaskList taskList;

static {
try {
at1 = parser.formatDateCustom_1("12/12/2019 12:00");
at2 = parser.formatDateCustom_1("20/12/2019 12:00");
at1 = parser.formatDateCustom_1("12/12/2019 17:00");
at2 = parser.formatDateCustom_1("12/12/2019 19:00");
at3 = parser.formatDateCustom_1("12/12/2019 10:00");
at4 = parser.formatDateCustom_1("20/12/2019 13:00");
at5 = parser.formatDateCustom_1("21/12/2019 13:00");
taskList = new TaskList(storage.loadFile("data.txt"));
Meeting event = new Meeting("test2", at2);
taskList = new TaskList(storage.loadFile("test.txt"));
meeting1 = new Meeting("test1", at1, 2, TimeUnit.hours);
meeting2 = new Meeting("test2", at2);
meeting3 = new Meeting("test3", at3);
meeting4 = new Meeting("test4", at4, 2, TimeUnit.hours);
meeting5 = new Meeting("test5", at5);
} catch (RoomShareException e) {
e.printStackTrace();
}
}

/*
@Test
public void timeCheckFixedTest() { assertEquals(true, new CheckAnomaly().checkTime(new Meeting()); }
public void durationClashOverlap() { assertEquals(true, new CheckAnomaly().checkTask(meeting1)); }

@Test
public void timeCheckOnlyDateTrueTest() {
assertEquals(true, new CheckAnomaly().checkTime(at1));
}
public void durationClashIntersect() { assertEquals(true, new CheckAnomaly().checkTask(meeting2)); }

@Test
public void timeCheckOnlyDateFalseTest() {
assertEquals(false, new CheckAnomaly().checkTime(at5));
}
*/
public void fixedClashIntersect() { assertEquals(true, new CheckAnomaly().checkTask(meeting3)); }

@Test
public void fixedClashOverlap() { assertEquals(true, new CheckAnomaly().checkTask(meeting4)); }

@Test
public void noClash() { assertEquals(false, new CheckAnomaly().checkTask(meeting5)); }
}
2 changes: 2 additions & 0 deletions test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
M#n#low#test1#12/12/2019 18:00#none#everyone#F#2#hours##
M#n#low#test2#12/12/2019 10:00#none#everyone#N#0#unDefined##

0 comments on commit 14df2cb

Please sign in to comment.