Search in sources :

Example 1 with EventBase

use of nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase 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());
}
Also used : EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Example 2 with EventBase

use of nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase in project watchdog by TestRoots.

the class EventPersisterDuplicatesTest method createEvent.

private static EventBase createEvent() {
    EventBase event = new BreakpointAddEvent(1, BreakpointType.LINE, new Date(1));
    event.setSessionSeed("444");
    return event;
}
Also used : EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) BreakpointAddEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent) Date(java.util.Date)

Example 3 with EventBase

use of nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase in project watchdog by TestRoots.

the class EventPersisterTest method testInteraction.

private void testInteraction(int items) {
    List<EventBase> generatedEvents = generateEventList(items);
    // Shuffle the generated events to test for
    // correct ordering of returned values
    Collections.shuffle(generatedEvents);
    Collections.sort(generatedEvents);
    for (EventBase event : generatedEvents) {
        persister.save(event);
    }
    List<WatchDogItem> readEvents = new ArrayList<WatchDogItem>(persister.readItems());
    assertEquals(readEvents.size(), items);
    // Test order of returned results
    assertEquals(readEvents, generatedEvents);
}
Also used : EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) ArrayList(java.util.ArrayList) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Example 4 with EventBase

use of nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase in project watchdog by TestRoots.

the class EventPersisterTest method createRandomEvent.

public static EventBase createRandomEvent() {
    EventBase event = new BreakpointAddEvent(new Random().nextInt(100000), BreakpointType.LINE, new Date());
    event.setSessionSeed("444");
    event.setTimestamp(new Date(event.getTimestamp().getTime() + (new Random()).nextInt(100000)));
    return event;
}
Also used : EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) Random(java.util.Random) BreakpointAddEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent) Date(java.util.Date)

Example 5 with EventBase

use of nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase in project watchdog by TestRoots.

the class EventPersisterTestSingleEvent method test2CompareEventAfterWrite.

@Test
public void test2CompareEventAfterWrite() {
    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());
}
Also used : EventBase(nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem) Test(org.junit.Test)

Aggregations

EventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase)8 WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)5 Date (java.util.Date)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 BreakpointAddEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent)2 Task (org.jfree.data.gantt.Task)2 Calendar (java.util.Calendar)1 Collections (java.util.Collections)1 List (java.util.List)1 Random (java.util.Random)1 Collectors (java.util.stream.Collectors)1 TrackingEventType (nl.tudelft.watchdog.core.logic.event.eventtypes.TrackingEventType)1 DebugInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.DebugInterval)1 PersisterBase (nl.tudelft.watchdog.core.logic.storage.PersisterBase)1 GanttCategoryDataset (org.jfree.data.gantt.GanttCategoryDataset)1 TaskSeries (org.jfree.data.gantt.TaskSeries)1 TaskSeriesCollection (org.jfree.data.gantt.TaskSeriesCollection)1