Search in sources :

Example 16 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem 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)

Example 17 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class EventPersisterTestSingleEvent method test1WriteEvent.

@Test
public void test1WriteEvent() {
    event = EventPersisterTest.createRandomEvent();
    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 18 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class NetworkUtilsTest method createSampleIntervals.

private ArrayList<WatchDogItem> createSampleIntervals(IntervalBase interval) {
    ArrayList<WatchDogItem> intervals = new ArrayList<WatchDogItem>();
    interval.setStartTime(new Date(1));
    interval.setEndTime(new Date(2));
    intervals.add(interval);
    return intervals;
}
Also used : ArrayList(java.util.ArrayList) Date(java.util.Date) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Example 19 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalStatisticsBase method addIntervals.

private void addIntervals(IDEIntervalManagerBase intervalManager) {
    for (WatchDogItem item : intervalPersister.readItems()) {
        if (item instanceof IntervalBase) {
            IntervalBase interval = (IntervalBase) item;
            interval.setClosed();
            intervals.add(interval);
        }
    }
    intervals.addAll(intervalManager.getOpenIntervals());
}
Also used : IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) EditorIntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Example 20 with WatchDogItem

use of nl.tudelft.watchdog.core.logic.storage.WatchDogItem in project watchdog by TestRoots.

the class IntervalStatisticsBase method filterIntervals.

/**
 * Filters out and removes intervals which are older than 10 hours from
 * Database. Filters intervals for selected time span.
 */
private void filterIntervals() {
    ArrayList<IntervalBase> filteredIntervals = new ArrayList<IntervalBase>();
    ArrayList<WatchDogItem> intervalsToRemove = new ArrayList<WatchDogItem>();
    if (intervals.size() == 0) {
        return;
    }
    mostRecentDate = intervals.get(intervals.size() - 1).getEnd();
    DateTime thresholdDateDatabase = new DateTime(mostRecentDate);
    thresholdDateDatabase = thresholdDateDatabase.minusMinutes(FILTERED_INTERVALS_IN_MINUTES);
    DateTime thresholdDateView = new DateTime(mostRecentDate);
    thresholdDateView = thresholdDateView.minusMinutes(selectedInterval.minutes);
    for (IntervalBase interval : intervals) {
        if (intervalIsOlderThanThreshold(thresholdDateDatabase, interval)) {
            intervalsToRemove.add(interval);
            continue;
        }
        if (!intervalIsOlderThanThreshold(thresholdDateView, interval)) {
            IntervalBase clonedInterval = null;
            try {
                clonedInterval = (IntervalBase) interval.clone();
                adjustIntervalStartAndEndDate(thresholdDateView, interval, clonedInterval);
                filteredIntervals.add(clonedInterval);
            } catch (CloneNotSupportedException exception) {
            // intentionally empty
            }
        }
    }
    oldestDate = filteredIntervals.get(0).getStart();
    intervalPersister.removeItems(intervalsToRemove);
    intervals = filteredIntervals;
}
Also used : IntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase) EditorIntervalBase(nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase) ArrayList(java.util.ArrayList) DateTime(org.joda.time.DateTime) WatchDogItem(nl.tudelft.watchdog.core.logic.storage.WatchDogItem)

Aggregations

WatchDogItem (nl.tudelft.watchdog.core.logic.storage.WatchDogItem)43 Test (org.junit.Test)35 Date (java.util.Date)32 ArrayList (java.util.ArrayList)14 IntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase)10 Document (nl.tudelft.watchdog.core.logic.document.Document)6 BreakpointAddEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent)6 DebugEventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.DebugEventBase)6 TypingInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.TypingInterval)6 EditorWrapper (nl.tudelft.watchdog.eclipse.logic.document.EditorWrapper)6 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)6 BreakpointChangeEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointChangeEvent)5 EditorIntervalBase (nl.tudelft.watchdog.core.logic.interval.intervaltypes.EditorIntervalBase)5 BreakpointChangeType (nl.tudelft.watchdog.core.logic.breakpoint.BreakpointChangeType)4 EventBase (nl.tudelft.watchdog.core.logic.event.eventtypes.EventBase)4 IDEOpenInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.IDEOpenInterval)3 BreakpointRemoveEvent (nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointRemoveEvent)1 DebugInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.DebugInterval)1 ReadingInterval (nl.tudelft.watchdog.core.logic.interval.intervaltypes.ReadingInterval)1 JsonTransferer (nl.tudelft.watchdog.core.logic.network.JsonTransferer)1