From 22583f0416b88eb3bda1c7937f33f525f1c2f7bf Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 22 Oct 2019 10:44:43 +0800 Subject: [PATCH 1/4] Split up tests for TaskTest --- src/main/java/Operations/CheckAnomaly.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/Operations/CheckAnomaly.java b/src/main/java/Operations/CheckAnomaly.java index 2c9b699f7e..73df88a95e 100644 --- a/src/main/java/Operations/CheckAnomaly.java +++ b/src/main/java/Operations/CheckAnomaly.java @@ -64,6 +64,7 @@ public static Boolean checkTime(Date at){ if( curr.get(i) instanceof Meeting && ((Meeting) curr.get(i)).checkDate().equals(at) ) { return true; } else if( curr.get(i) instanceof FixedDuration ) { + /* Date listDate = ((FixedDuration) curr.get(i)).checkDate(); if( listDate.getYear() == at.getYear() && listDate.getMonth() == at.getMonth() && listDate.getDay() == at.getDay() ) { double checkTime = listDate.getTime(); @@ -73,6 +74,8 @@ public static Boolean checkTime(Date at){ return true; } } + + */ } } return false; From 233591a3b468ec094bdaccab77ab3917fa12ef41 Mon Sep 17 00:00:00 2001 From: Caleb Date: Fri, 25 Oct 2019 12:46:54 +0800 Subject: [PATCH 2/4] Split up tests for TaskTest --- src/main/java/RoomShare.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/RoomShare.java b/src/main/java/RoomShare.java index 455581c577..daa89f8cc5 100644 --- a/src/main/java/RoomShare.java +++ b/src/main/java/RoomShare.java @@ -198,5 +198,6 @@ public void run() throws RoomShareException { */ public static void main(String[] args) throws RoomShareException { new RoomShare().run(); + return; } } From e589cfff484153a631a55ec58cd7139eb7892378 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 29 Oct 2019 11:10:14 +0800 Subject: [PATCH 3/4] Nil --- src/main/java/Model_Classes/Task.java | 13 ++++++++----- src/main/java/Operations/subTaskCreator.java | 15 +++++++++++++++ src/main/java/RoomShare.java | 6 +----- 3 files changed, 24 insertions(+), 10 deletions(-) create mode 100644 src/main/java/Operations/subTaskCreator.java diff --git a/src/main/java/Model_Classes/Task.java b/src/main/java/Model_Classes/Task.java index 3745357c43..ee22d5d419 100644 --- a/src/main/java/Model_Classes/Task.java +++ b/src/main/java/Model_Classes/Task.java @@ -3,11 +3,10 @@ import Enums.Priority; import Enums.RecurrenceScheduleType; -import java.time.LocalDateTime; -import java.time.format.DateTimeFormatter; -import java.util.ArrayList; -import java.util.Arrays; +import java.awt.font.TextAttribute; import java.util.Date; +import java.awt.*; +import java.util.Map; /** * Parent class for all other types of tasks @@ -100,7 +99,11 @@ public void setPriority(Priority p) { * @return */ public String toString() { - return getStatusIcon() + getDescription() + " " + "(" + getUser() + ")"; + Font font = new Font("helvetica", Font.PLAIN, 12); + Map attributes = font.getAttributes(); + attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON); + Font newFont = new Font(attributes); + return getStatusIcon() + getDescription() + " " + "(" + getUser() + ")" + newFont; } public RecurrenceScheduleType getRecurrenceSchedule() { diff --git a/src/main/java/Operations/subTaskCreator.java b/src/main/java/Operations/subTaskCreator.java new file mode 100644 index 0000000000..68d2ec0b71 --- /dev/null +++ b/src/main/java/Operations/subTaskCreator.java @@ -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); + } + } +} diff --git a/src/main/java/RoomShare.java b/src/main/java/RoomShare.java index 512aac3ce7..a15f48dfde 100644 --- a/src/main/java/RoomShare.java +++ b/src/main/java/RoomShare.java @@ -178,11 +178,7 @@ public void run() throws RoomShareException { 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); } From fbda53484590a6f87c6c8445fdba0e85cb419b94 Mon Sep 17 00:00:00 2001 From: Caleb Date: Tue, 29 Oct 2019 11:46:45 +0800 Subject: [PATCH 4/4] Added CheckAnomalyTest & test.txt --- src/test/java/CheckAnomalyTest.java | 37 ++++++++++++++++++----------- test.txt | 2 ++ 2 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 test.txt diff --git a/src/test/java/CheckAnomalyTest.java b/src/test/java/CheckAnomalyTest.java index a31a397b66..228d4df28a 100644 --- a/src/test/java/CheckAnomalyTest.java +++ b/src/test/java/CheckAnomalyTest.java @@ -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)); } } \ No newline at end of file diff --git a/test.txt b/test.txt new file mode 100644 index 0000000000..2e1f4eb693 --- /dev/null +++ b/test.txt @@ -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## \ No newline at end of file