use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase 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));
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IntervalPersisterTestSingleInterval method test3CompareIntervalAfterWriteDemonstratesCloseIsNotPersisted.
@Test
public void test3CompareIntervalAfterWriteDemonstratesCloseIsNotPersisted() {
WatchDogItem savedItem = new ArrayList<>(persister.readItems()).get(0);
assertTrue(savedItem instanceof IntervalBase);
IntervalBase savedInterval = (IntervalBase) savedItem;
assertEquals(interval.getDuration(), savedInterval.getDuration());
assertEquals(interval.isClosed(), savedInterval.isClosed());
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase 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.interval.intervaltypes.IntervalBase in project watchdog by TestRoots.
the class IDEIntervalManagerBase method closeAllIntervals.
/**
* Closes all currently open intervals with the supplied closing date.
*/
public void closeAllIntervals(Date closingDate) {
closeInterval(editorInterval, closingDate);
ArrayList<IntervalBase> copiedIntervals = new ArrayList<IntervalBase>(intervals);
Iterator<IntervalBase> iterator = copiedIntervals.listIterator();
while (iterator.hasNext()) {
// we need to remove the interval first from the list in order to
// avoid ConcurrentListModification Exceptions.
IntervalBase interval = iterator.next();
iterator.remove();
closeInterval(interval, closingDate);
}
intervals.clear();
}
use of nl.tudelft.watchdog.core.logic.interval.intervaltypes.IntervalBase 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