forked from nus-cs2103-AY1617S1/addressbook-level4
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
abde360
commit e78bfa8
Showing
3 changed files
with
239 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
# A0126539Y | ||
###### /java/seedu/priorityq/logic/commands/LoadCommandTest.java | ||
``` java | ||
public class LoadCommandTest { | ||
|
||
@Test(expected = IllegalValueException.class) | ||
public void nullLocation() throws Exception { | ||
new LoadCommand(null); | ||
} | ||
|
||
@Test(expected = IllegalValueException.class) | ||
public void emptyStringLocation() throws Exception { | ||
new LoadCommand(""); | ||
} | ||
|
||
@Test(expected = InvalidPathException.class) | ||
public void invalidLocation() throws Exception{ | ||
new LoadCommand("invalid.json"); | ||
} | ||
} | ||
``` | ||
###### /java/seedu/priorityq/logic/commands/SaveCommandTest.java | ||
``` java | ||
public class SaveCommandTest { | ||
|
||
@Test(expected = IllegalValueException.class) | ||
public void nullLocation() throws Exception { | ||
new SaveCommand(null); | ||
} | ||
|
||
@Test(expected = IllegalValueException.class) | ||
public void emptyStringLocation() throws Exception { | ||
new SaveCommand(""); | ||
} | ||
|
||
@Test(expected = InvalidPathException.class) | ||
public void invalidLocation() throws Exception{ | ||
new SaveCommand("invalid.json"); | ||
} | ||
|
||
@Test | ||
public void saveCommand() { | ||
try { | ||
new SaveCommand("data/newLocation.xml"); | ||
} catch (Exception e) { | ||
fail(); | ||
} | ||
} | ||
} | ||
``` | ||
###### /java/seedu/priorityq/model/entry/EventTest.java | ||
``` java | ||
@Test | ||
public void inheritanceTest() { | ||
assertTrue(testEvent instanceof Entry); | ||
} | ||
|
||
@Test | ||
public void entryConstructor() { | ||
assertTrue(testEvent.equals(new Event((Entry)testEvent))); | ||
|
||
Entry task = new Task(title, null, tags, false, description, lastModifiedTime); | ||
assertFalse(new Task(task).equals(testEvent)); | ||
} | ||
|
||
@Test(expected = IllegalArgumentException.class) | ||
public void startDateAfterEnd() { | ||
new Event(title, endTime.plusMinutes(1), endTime, tags, isMarked, description, -1, lastModifiedTime); | ||
} | ||
|
||
@Test | ||
public void getAsTextEqualToString() { | ||
assertEquals(testEvent.getAsText(), testEvent.toString()); | ||
} | ||
|
||
@Test | ||
public void hashCodeTests() { | ||
Event copy = new Event(testEvent); | ||
assertNotEquals(testEvent.hashCode(), copy.hashCode()); | ||
|
||
// test consistency | ||
assertEquals(testEvent.hashCode(), testEvent.hashCode()); | ||
assertEquals(testEvent.hashCode(), testEvent.hashCode()); | ||
|
||
copy.setDescription("another description"); | ||
assertNotEquals(testEvent.hashCode(), copy.hashCode()); | ||
} | ||
|
||
@Test | ||
public void equals() throws Exception { | ||
// test null | ||
assertFalse(testEvent.equals(null)); | ||
|
||
// test other instance | ||
assertFalse(testEvent.equals(new Object())); | ||
|
||
// test reflexivity | ||
assertTrue(testEvent.equals(testEvent)); | ||
|
||
|
||
// test symmetricity | ||
Event copy = new Event(testEvent); | ||
assertTrue(testEvent.equals(copy)); | ||
assertTrue(copy.equals(testEvent)); | ||
|
||
// test transitivity | ||
Event copy2 = new Event(testEvent); | ||
assertTrue(copy.equals(copy2)); | ||
assertTrue(testEvent.equals(copy2)); | ||
|
||
copy.setTitle(new Title("some other title")); | ||
assertFalse(testEvent.equals(copy)); | ||
} | ||
|
||
@Test | ||
public void testRecurrence() throws InterruptedException { | ||
Event recurrenceBase = new Event(title, startTime, endTime, tags, isMarked, description, DAY_IN_MILLIS, lastModifiedTime); | ||
Event copy; | ||
LocalDateTime start; | ||
LocalDateTime end; | ||
|
||
copy = new Event(recurrenceBase); | ||
start = LocalDateTime.now().minusDays(1).plusMinutes(1); | ||
end = start.plusMinutes(5); | ||
copy.setStartTime(start); | ||
copy.setEndTime(end); | ||
copy = new Event(copy); | ||
assertEquals(copy.getStartTime(), start.plusDays(1)); | ||
assertEquals(copy.getEndTime(), end.plusDays(1)); | ||
|
||
|
||
copy = new Event(recurrenceBase); | ||
start = LocalDateTime.now().minusDays(5).plusMinutes(1); | ||
end = start.plusMinutes(5); | ||
copy.setStartTime(start); | ||
copy.setEndTime(end); | ||
copy = new Event(copy); | ||
System.out.println(copy.getStartTime()); | ||
System.out.println(start.plusDays(6)); | ||
assertEquals(copy.getStartTime(), start.plusDays(5)); | ||
assertEquals(copy.getEndTime(), end.plusDays(5)); | ||
} | ||
|
||
@Test | ||
public void getTimeObjectProperty() { | ||
testEvent.startTimeObjectProperty().equals(testEvent.startTime); | ||
testEvent.endTimeObjectProperty().equals(testEvent.endTime); | ||
testEvent.recursionObjectProperty().equals(testEvent.recursion); | ||
} | ||
``` | ||
###### /java/seedu/priorityq/model/entry/TaskTest.java | ||
``` java | ||
@Test | ||
public void inheritanceTest() { | ||
assertTrue(floating instanceof Entry); | ||
} | ||
|
||
@Test | ||
public void simpleConstructor() { | ||
new Task(title, uniqueTagList); | ||
} | ||
|
||
@Test | ||
public void constructor_nullDeadline() { | ||
new Task(title, null, uniqueTagList, false, description, lastModifiedTime); | ||
} | ||
|
||
@Test | ||
public void entryConstructor() { | ||
assertTrue(floating.equals(new Task((Entry)floating))); | ||
assertTrue(withDeadline.equals(new Task((Entry)withDeadline))); | ||
|
||
Entry event = new Event(title, LocalDateTime.MIN, LocalDateTime.MAX, uniqueTagList, false, description, 0, lastModifiedTime); | ||
assertFalse(new Task(event).equals(event)); | ||
} | ||
|
||
@Test | ||
public void getAsTextEqualToString() { | ||
assertEquals(floating.getAsText(), floating.toString()); | ||
} | ||
|
||
@Test | ||
public void hashCodeTests() { | ||
Task copy = new Task(floating); | ||
assertNotEquals(floating.hashCode(), copy.hashCode()); | ||
Task deadlineCopy = new Task(withDeadline); | ||
assertNotEquals(withDeadline.hashCode(), deadlineCopy.hashCode()); | ||
|
||
assertNotEquals(floating.hashCode(), withDeadline.hashCode()); | ||
|
||
// test consistency | ||
assertEquals(floating.hashCode(), floating.hashCode()); | ||
assertEquals(floating.hashCode(), floating.hashCode()); | ||
|
||
copy.setDescription("new description"); | ||
assertNotEquals(floating.hashCode(), copy.hashCode()); | ||
} | ||
|
||
@Test | ||
public void equals() throws Exception { | ||
// test null | ||
assertFalse(floating.equals(null)); | ||
assertFalse(withDeadline.equals(null)); | ||
|
||
// test other instance | ||
assertFalse(floating.equals(new Object())); | ||
assertFalse(withDeadline.equals(new Object())); | ||
|
||
// test reflexivity | ||
assertTrue(withDeadline.equals(withDeadline)); | ||
assertTrue(floating.equals(floating)); | ||
|
||
|
||
// test symmetricity | ||
Task copy = new Task(floating); | ||
assertTrue(floating.equals(copy)); | ||
assertTrue(copy.equals(floating)); | ||
|
||
Task copyDeadline = new Task(withDeadline); | ||
assertTrue(withDeadline.equals(copyDeadline)); | ||
assertTrue(copyDeadline.equals(withDeadline)); | ||
|
||
// test transitivity | ||
Task copy2 = new Task(title, null, uniqueTagList, false, description, lastModifiedTime); | ||
assertTrue(copy.equals(copy2)); | ||
assertTrue(floating.equals(copy2)); | ||
|
||
|
||
copy.setTitle(new Title("some other title")); | ||
assertFalse(withDeadline.equals(copy)); | ||
copy2.mark(); | ||
assertFalse(withDeadline.equals(copy2)); | ||
} | ||
``` |
Oops, something went wrong.