Skip to content

Commit

Permalink
Merge b56fa19 into 15858fc
Browse files Browse the repository at this point in the history
  • Loading branch information
Kratious committed Sep 25, 2018
2 parents 15858fc + b56fa19 commit be88fd2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
45 changes: 45 additions & 0 deletions src/test/java/seedu/address/model/AddressBookTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static seedu.address.logic.commands.CommandTestUtil.VALID_ADDRESS_BOB;
import static seedu.address.logic.commands.CommandTestUtil.VALID_DESCRIPTION_YOUTH;
import static seedu.address.logic.commands.CommandTestUtil.VALID_HOUR_H2;
import static seedu.address.logic.commands.CommandTestUtil.VALID_REMARK_R2;
import static seedu.address.logic.commands.CommandTestUtil.VALID_TAG_HUSBAND;
import static seedu.address.testutil.TypicalEvents.BLOOD;
import static seedu.address.testutil.TypicalPersons.ALICE;
import static seedu.address.testutil.TypicalPersons.getTypicalAddressBook;
import static seedu.address.testutil.TypicalRecords.R1;
Expand All @@ -23,10 +25,12 @@
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.model.event.Event;
import seedu.address.model.event.exceptions.DuplicateEventException;
import seedu.address.model.person.Person;
import seedu.address.model.person.exceptions.DuplicatePersonException;
import seedu.address.model.record.Record;
import seedu.address.model.record.exceptions.DuplicateRecordException;
import seedu.address.testutil.EventBuilder;
import seedu.address.testutil.PersonBuilder;
import seedu.address.testutil.RecordBuilder;

Expand Down Expand Up @@ -100,6 +104,47 @@ public void getPersonList_modifyList_throwsUnsupportedOperationException() {
addressBook.getPersonList().remove(0);
}

//// Event Tests
@Test
public void resetData_withDuplicateEvents_throwsDuplicateEventsException() {
// Two events with the same identity fields
Event editedEvent = new EventBuilder(BLOOD).withDescription(VALID_DESCRIPTION_YOUTH).build();
List<Event> newEvents = Arrays.asList(BLOOD, editedEvent);
AddressBookStub newData = new AddressBookStub(null, newEvents, null);

thrown.expect(DuplicateEventException.class);
addressBook.resetData(newData);
}

@Test
public void hasEvent_nullEvent_throwsNullPointerException() {
thrown.expect(NullPointerException.class);
addressBook.hasEvent(null);
}

@Test
public void hasEvent_eventNotInAddressBook_returnsFalse() {
assertFalse(addressBook.hasEvent(BLOOD));
}

@Test
public void hasEvent_eventInAddressBook_returnsTrue() {
addressBook.addEvent(BLOOD);
assertTrue(addressBook.hasEvent(BLOOD));
}

@Test
public void hasEvent_eventWithSameIdentityFieldsInAddressBook_returnsTrue() {
addressBook.addEvent(BLOOD);
Event editedEvent = new EventBuilder(BLOOD).withDescription(VALID_DESCRIPTION_YOUTH).build();
assertTrue(addressBook.hasEvent(editedEvent));
}

@Test
public void getEventList_modifyList_throwsUnsupportedOperationException() {
thrown.expect(UnsupportedOperationException.class);
addressBook.getEventList().remove(0);
}

//// Record Tests
@Test
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/seedu/address/model/ModelManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ public void hasEvent_nullEvent_throwsNullPointerException() {
}

@Test
public void hasEvent_personNotInAddressBook_returnsFalse() {
public void hasEvent_eventNotInAddressBook_returnsFalse() {
assertFalse(modelManager.hasEvent(BLOOD));
}

@Test
public void hasEvent_personInAddressBook_returnsTrue() {
public void hasEvent_eventInAddressBook_returnsTrue() {
modelManager.addEvent(BLOOD);
assertTrue(modelManager.hasEvent(BLOOD));
}
Expand Down

0 comments on commit be88fd2

Please sign in to comment.