aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/events/MotionEventHandlerTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-11 23:37:16 +1200
committerGitHub <noreply@github.com>2017-08-11 23:37:16 +1200
commit30e8409375f9992a5248f7e2597691c0ee08188c (patch)
treeea51b7d111cfae849d23941ad82045139e87520b /test/org/traccar/events/MotionEventHandlerTest.java
parent3562e0d927d539a1e9730c48ed376ee84ebc2b25 (diff)
parent26db3ccc2ed5d43a0e791a29d5cc4afca192e4b7 (diff)
downloadtrackermap-server-30e8409375f9992a5248f7e2597691c0ee08188c.tar.gz
trackermap-server-30e8409375f9992a5248f7e2597691c0ee08188c.tar.bz2
trackermap-server-30e8409375f9992a5248f7e2597691c0ee08188c.zip
Merge pull request #3431 from Abyss777/delayed_overspeed
Implement delayed overspeed events
Diffstat (limited to 'test/org/traccar/events/MotionEventHandlerTest.java')
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java31
1 files changed, 26 insertions, 5 deletions
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java
index c44f3f4eb..6b7b9daee 100644
--- a/test/org/traccar/events/MotionEventHandlerTest.java
+++ b/test/org/traccar/events/MotionEventHandlerTest.java
@@ -27,8 +27,9 @@ public class MotionEventHandlerTest extends BaseTest {
}
@Test
- public void testMotionEventHandler() throws Exception {
- TripsConfig tripsConfig = new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0);
+ public void testMotionWithPosition() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0));
Position position = new Position();
position.setTime(date("2017-01-01 00:00:00"));
@@ -43,11 +44,11 @@ public class MotionEventHandlerTest extends BaseTest {
nextPosition.set(Position.KEY_MOTION, true);
nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200);
- Event event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig);
+ Event event = motionEventHandler.updateMotionState(deviceState, nextPosition);
assertNull(event);
nextPosition.set(Position.KEY_TOTAL_DISTANCE, 600);
- event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig);
+ event = motionEventHandler.updateMotionState(deviceState, nextPosition);
assertNotNull(event);
assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
assertTrue(deviceState.getMotionState());
@@ -57,7 +58,27 @@ public class MotionEventHandlerTest extends BaseTest {
deviceState.setMotionPosition(position);
nextPosition.setTime(date("2017-01-01 00:06:00"));
nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200);
- event = MotionEventHandler.updateMotionState(deviceState, nextPosition, tripsConfig);
+ event = motionEventHandler.updateMotionState(deviceState, nextPosition);
+ assertNotNull(event);
+ assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
+ assertTrue(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+ }
+
+ @Test
+ public void testMotionWithStatus() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0));
+
+ Position position = new Position();
+ position.setTime(new Date(System.currentTimeMillis() - 360000));
+ position.set(Position.KEY_MOTION, true);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setMotionState(false);
+ deviceState.setMotionPosition(position);
+
+ Event event = motionEventHandler.updateMotionState(deviceState);
+
assertNotNull(event);
assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
assertTrue(deviceState.getMotionState());