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());
}
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());
}
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;
}
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());
}
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;
}
Aggregations