aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/events/MotionEventHandlerTest.java
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-11 09:22:53 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-11 09:27:41 +0500
commit2e459d8d591ee9d3578a38d981e7c1c13eb3c389 (patch)
treed5d69d81dc796b54d67946b753e5f801fcb07913 /test/org/traccar/events/MotionEventHandlerTest.java
parent532e0a98d469573a575dc595554792cbbd4cd953 (diff)
downloadtrackermap-server-2e459d8d591ee9d3578a38d981e7c1c13eb3c389.tar.gz
trackermap-server-2e459d8d591ee9d3578a38d981e7c1c13eb3c389.tar.bz2
trackermap-server-2e459d8d591ee9d3578a38d981e7c1c13eb3c389.zip
Move state updates from ConnectionManager to proper event handlers
Diffstat (limited to 'test/org/traccar/events/MotionEventHandlerTest.java')
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java
index c44f3f4eb..9df573244 100644
--- a/test/org/traccar/events/MotionEventHandlerTest.java
+++ b/test/org/traccar/events/MotionEventHandlerTest.java
@@ -27,7 +27,7 @@ public class MotionEventHandlerTest extends BaseTest {
}
@Test
- public void testMotionEventHandler() throws Exception {
+ public void testMotionWithPosition() throws Exception {
TripsConfig tripsConfig = new TripsConfig(500, 300 * 1000, 300 * 1000, false, 0);
Position position = new Position();
@@ -64,4 +64,23 @@ public class MotionEventHandlerTest extends BaseTest {
assertNull(deviceState.getMotionPosition());
}
+ @Test
+ public void testMotionWithStatus() throws Exception {
+ TripsConfig tripsConfig = 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, tripsConfig);
+
+ assertNotNull(event);
+ assertEquals(Event.TYPE_DEVICE_MOVING, event.getType());
+ assertTrue(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+ }
+
}