use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.
the class EventPersisterDuplicatesTest method test1AddEvent.
@Test
public void test1AddEvent() {
event = createEvent();
persister.save(event);
WatchDogItem item = new ArrayList<>(persister.readItems()).get(0);
assertTrue(item instanceof EventBase);
EventBase savedEvent = (EventBase) item;
assertEquals(event.getType(), savedEvent.getType());
assertEquals(event.getTimestamp(), savedEvent.getTimestamp());
}
use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.
the class IntervalJsonConverterTest method testContainsIDEHost.
/**
* Tests the format of the returned Json representation, manually setting an
* IDE host.
*/
@Test
public void testContainsIDEHost() {
IntervalBase interval = new IDEOpenInterval(new Date());
ArrayList<WatchDogItem> intervals = createSampleIntervals(interval);
assertEquals("[{\"it\":\"eo\",\"ts\":1,\"te\":2,\"ss\":\"\"," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.
the class IntervalJsonConverterTest method createSampleIntervals.
private ArrayList<WatchDogItem> createSampleIntervals(IntervalBase interval) {
ArrayList<WatchDogItem> intervals = new ArrayList<WatchDogItem>();
interval.close();
sleepABit();
interval.setStartTime(new Date(1));
interval.setEndTime(new Date(2));
interval.setSessionSeed("");
intervals.add(interval);
return intervals;
}
use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.
the class IntervalJsonConverterTest method testJsonTypingIntervalDiffsModification.
@Test
public void testJsonTypingIntervalDiffsModification() {
ITextEditor editor = Mockito.mock(ITextEditor.class);
TypingInterval interval = new TypingInterval(new EditorWrapper(editor), new Date(1));
interval.setDocument(new Document("Project", "filepath", "Production.java", "blah-document"));
interval.setEndingDocument(new Document("Project", "filepath", "Production.java", "blah-documens"));
interval.close();
sleepABit();
ArrayList<WatchDogItem> intervals = new ArrayList<>();
intervals.add(interval);
assertEquals("[{\"endingDocument\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"diff\":1,\"modCountDiff\":0,\"charLengthDiff\":0,\"doc\":{\"pn\":\"f6f4da8d93e88a08220e03b7810451d3ba540a34\",\"fn\":\"e4afa075bb910c8ecb427e9950426a4599b21d7e\",\"sloc\":1,\"dt\":\"un\"},\"it\":\"ty\",\"ts\":1," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.
the class IntervalPersisterTestSingleInterval method test3CompareIntervalAfterWriteDemonstratesCloseIsNotPersisted.
@Test
public void test3CompareIntervalAfterWriteDemonstratesCloseIsNotPersisted() {
WatchDogItem savedItem = new ArrayList<>(persister.readItems()).get(0);
assertTrue(savedItem instanceof IntervalBase);
IntervalBase savedInterval = (IntervalBase) savedItem;
assertEquals(interval.getDuration(), savedInterval.getDuration());
assertEquals(interval.isClosed(), savedInterval.isClosed());
}
Aggregations