Skip to content

Commit

Permalink
Update data loading tests
Browse files Browse the repository at this point in the history
  • Loading branch information
INCENDE committed Oct 25, 2016
1 parent 8c6de35 commit 1f081df
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/test/java/seedu/agendum/storage/StorageManagerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import seedu.agendum.commons.events.model.ChangeSaveLocationRequestEvent;
import seedu.agendum.commons.events.model.LoadDataRequestEvent;
import seedu.agendum.commons.events.model.ToDoListChangedEvent;
import seedu.agendum.commons.events.storage.DataLoadingExceptionEvent;
import seedu.agendum.commons.events.storage.DataSavingExceptionEvent;
import seedu.agendum.commons.exceptions.DataConversionException;
import seedu.agendum.commons.exceptions.FileDeletionException;
Expand Down Expand Up @@ -97,17 +98,20 @@ public void handleSaveLocationChangedEvent_validFilePath() {

@Test
public void handleLoadDataRequestEvent_validPathToFile_invalidFile() throws IOException, FileDeletionException {
EventsCollector eventCollector = new EventsCollector();
String validPath = "data/testLoad.xml";
assert !FileUtil.isFileExists(validPath);

// File does not exist
//thrown.expect(NoSuchElementException.class);
storageManager.handleLoadDataRequestEvent(new LoadDataRequestEvent(validPath));
DataLoadingExceptionEvent dlee = (DataLoadingExceptionEvent)eventCollector.get(0);
assertTrue(dlee.exception instanceof NoSuchElementException);

// File in wrong format
FileUtil.createFile(new File(validPath));
//thrown.expect(DataConversionException.class);
storageManager.handleLoadDataRequestEvent(new LoadDataRequestEvent(validPath));
dlee = (DataLoadingExceptionEvent)eventCollector.get(1);
assertTrue(dlee.exception instanceof DataConversionException);
FileUtil.deleteFile(validPath);
}

Expand Down

0 comments on commit 1f081df

Please sign in to comment.