use of org.traccar.TestIdentityManager in project traccar by tananaev.
the class ReportUtilsTest method testDetectStopsMoving.
@Test
public void testDetectStopsMoving() throws ParseException {
Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 5, 0), position("2016-01-01 00:01:00.000", 5, 0), position("2016-01-01 00:02:00.000", 3, 0), position("2016-01-01 00:03:00.000", 5, 0), position("2016-01-01 00:04:00.000", 5, 0), position("2016-01-01 00:05:00.000", 5, 0));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReport> result = ReportUtils.detectTripsAndStops(new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertTrue(result.isEmpty());
}
use of org.traccar.TestIdentityManager in project traccar by tananaev.
the class ReportUtilsTest method testDetectStopsWithTripCut.
@Test
public void testDetectStopsWithTripCut() throws ParseException {
Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 0, 0), position("2016-01-01 00:03:00.000", 0, 0), position("2016-01-01 00:04:00.000", 1, 0), position("2016-01-01 00:05:00.000", 2, 0));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReport> result = ReportUtils.detectTripsAndStops(new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getEndTime());
assertEquals(240000, itemStop.getDuration());
}
use of org.traccar.TestIdentityManager in project traccar by tananaev.
the class ReportUtilsTest method testDetectTripsSimple.
@Test
public void testDetectTripsSimple() throws ParseException {
List<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 0, 0), position("2016-01-01 00:01:00.000", 0, 0), position("2016-01-01 00:02:00.000", 10, 0), position("2016-01-01 00:03:00.000", 10, 1000), position("2016-01-01 00:04:00.000", 10, 2000), position("2016-01-01 00:05:00.000", 0, 3000), position("2016-01-01 00:06:00.000", 0, 3000), position("2016-01-01 00:07:00.000", 0, 3000));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
Collection<TripReport> trips = ReportUtils.detectTripsAndStops(new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
TripReport itemTrip = trips.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime());
assertEquals(180000, itemTrip.getDuration());
assertEquals(32.4, itemTrip.getAverageSpeed(), 0.01);
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
Collection<StopReport> stops = ReportUtils.detectTripsAndStops(new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
Iterator<StopReport> iterator = stops.iterator();
StopReport itemStop = iterator.next();
assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime());
assertEquals(120000, itemStop.getDuration());
itemStop = iterator.next();
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:07:00.000"), itemStop.getEndTime());
assertEquals(120000, itemStop.getDuration());
}
use of org.traccar.TestIdentityManager in project traccar by tananaev.
the class ReportUtilsTest method testDetectStopsStartedFromTrip.
@Test
public void testDetectStopsStartedFromTrip() throws ParseException {
Collection<Position> data = Arrays.asList(position("2016-01-01 00:00:00.000", 2, 0), position("2016-01-01 00:01:00.000", 1, 0), position("2016-01-01 00:02:00.000", 0, 0), position("2016-01-01 00:03:00.000", 0, 0), position("2016-01-01 00:04:00.000", 0, 0), position("2016-01-01 00:05:00.000", 0, 0));
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
Collection<StopReport> result = ReportUtils.detectTripsAndStops(new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
StopReport itemStop = result.iterator().next();
assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getStartTime());
assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime());
assertEquals(180000, itemStop.getDuration());
}
use of org.traccar.TestIdentityManager in project traccar by tananaev.
the class AlertEventHandlerTest method testAlertEventHandler.
@Test
public void testAlertEventHandler() {
AlertEventHandler alertEventHandler = new AlertEventHandler(new Config(), new TestIdentityManager());
Position position = new Position();
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
Map<Event, Position> events = alertEventHandler.analyzePosition(position);
assertNotNull(events);
Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_ALARM, event.getType());
}
Aggregations