Search in sources :

Example 1 with IDEOpenInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval 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));
}
Also used : IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) EditorIntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 2 with IDEOpenInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval in project watchdog by TestRoots.

the class IntervalComparisonTest method testComparisonEqualIntervalsDifferentObjectsDifferentType.

@Test
public void testComparisonEqualIntervalsDifferentObjectsDifferentType() {
    Date start = new Date();
    UserActiveInterval interval1 = new UserActiveInterval(start);
    IDEOpenInterval interval2 = new IDEOpenInterval(start);
    interval1.close();
    interval2.close();
    interval2.setEndTime(interval1.getEnd());
    assertEquals(1, interval1.compareTo(interval2));
    assertEquals(-1, interval2.compareTo(interval1));
}
Also used : UserActiveInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.UserActiveInterval) Date(java.util.Date) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Test(org.junit.Test)

Example 3 with IDEOpenInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval in project watchdog by TestRoots.

the class IntervalComparisonTest method testComparisonTwoDifferentIntervalsDifferentType.

@Test
public void testComparisonTwoDifferentIntervalsDifferentType() {
    UserActiveInterval interval1 = new UserActiveInterval(new Date(1));
    IDEOpenInterval interval2 = new IDEOpenInterval(new Date(2));
    interval1.close();
    interval1.setEndTime(new Date(2));
    interval2.close();
    interval2.setEndTime(new Date(3));
    assertEquals(-1, interval1.compareTo(interval2));
    assertEquals(1, interval2.compareTo(interval1));
}
Also used : UserActiveInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.UserActiveInterval) Date(java.util.Date) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Test(org.junit.Test)

Example 4 with IDEOpenInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval 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));
}
Also used : IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) EditorIntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 5 with IDEOpenInterval

use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval 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;
}
Also used : Random(java.util.Random) IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) IDEOpenInterval(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval) Date(java.util.Date)

Aggregations

Date (java.util.Date)6 IDEOpenInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval)6 Test (org.junit.Test)5 IntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase)4 WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)3 EditorIntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase)2 UserActiveInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.UserActiveInterval)2 Random (java.util.Random)1 JsonTransferer (nl.tudelft.watchdog.core.logic.network.JsonTransferer)1 ServerCommunicationException (nl.tudelft.watchdog.core.logic.network.ServerCommunicationException)1 ServerReturnCodeException (nl.tudelft.watchdog.core.logic.network.ServerReturnCodeException)1 Ignore (org.junit.Ignore)1