use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalJsonConverterTest method testJsonDebugIntervalRepresentation.
@Test
public void testJsonDebugIntervalRepresentation() {
IntervalBase interval = new DebugInterval(new Date());
ArrayList<WatchDogItem> intervals = createSampleIntervals(interval);
assertEquals("[{\"it\":\"db\",\"ts\":1,\"te\":2,\"ss\":\"\"," + pasteWDVAndClient() + "}]", transferer.toJson(intervals));
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalJsonConverterTest method testJsonSessionIntervalRepresentation.
/**
* Tests the format of the returned Json representation.
*/
@Test
public void testJsonSessionIntervalRepresentation() {
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.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalPersisterTest method createRandomInterval.
public static IntervalBase createRandomInterval() {
IntervalBase interval = new IDEOpenInterval(new Date());
interval.setSessionSeed("444");
interval.setStartTime(new Date(interval.getStart().getTime() + (new Random()).nextInt(100000)));
interval.setEndTime(new Date(interval.getStart().getTime() + (new Random()).nextInt(100000)));
return interval;
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalPersisterTest method testInteraction.
private void testInteraction(int items) {
List<IntervalBase> generatedIntervals = generateIntervalList(items);
// Shuffle the generated intervals to test for
// correct ordering of returned values
Collections.shuffle(generatedIntervals);
Collections.sort(generatedIntervals);
for (IntervalBase intervalBase : generatedIntervals) {
persister.save(intervalBase);
}
List<WatchDogItem> readIntervals = new ArrayList<WatchDogItem>(persister.readItems());
assertEquals(readIntervals.size(), items);
// Test order of returned results
assertEquals(readIntervals, generatedIntervals);
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalPersisterTestSingleInterval method test1WriteInterval.
@Test
public void test1WriteInterval() {
interval = IntervalPersisterTest.createRandomInterval();
interval.close();
persister.save(interval);
WatchDogItem savedItem = new ArrayList<>(persister.readItems()).get(0);
assertTrue(savedItem instanceof IntervalBase);
IntervalBase savedInterval = (IntervalBase) savedItem;
assertEquals(interval.getType(), savedInterval.getType());
assertEquals(interval.getStart(), savedInterval.getStart());
assertEquals(interval.getEnd(), savedInterval.getEnd());
assertEquals(interval.getDuration(), savedInterval.getDuration());
assertEquals(interval.isClosed(), savedInterval.isClosed());
}
Aggregations