aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/events
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-15 16:04:41 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-15 16:04:41 +0500
commit4d7805f783f00914a289b2447521a2f467de87bc (patch)
tree819d1a56dbbdd9c3badb379337da16d9dd487a54 /test/org/traccar/events
parent9b9c715cf0d9604be71a35e5e6e5428a3a891ba9 (diff)
parent5606c72b19568ddf50e2fa35f35e05358bb671e4 (diff)
downloadtraccar-server-4d7805f783f00914a289b2447521a2f467de87bc.tar.gz
traccar-server-4d7805f783f00914a289b2447521a2f467de87bc.tar.bz2
traccar-server-4d7805f783f00914a289b2447521a2f467de87bc.zip
Merge remote-tracking branch 'upstream/master' into new_trips_detector
Diffstat (limited to 'test/org/traccar/events')
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java
index 0543d86fe..902be8b87 100644
--- a/test/org/traccar/events/MotionEventHandlerTest.java
+++ b/test/org/traccar/events/MotionEventHandlerTest.java
@@ -1,6 +1,7 @@
package org.traccar.events;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
@@ -29,7 +30,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionWithPosition() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(
- new TripsConfig(500, 300 * 1000, 300 * 1000, 0));
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false));
Position position = new Position();
position.setTime(date("2017-01-01 00:00:00"));
@@ -68,7 +69,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionWithStatus() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(
- new TripsConfig(500, 300 * 1000, 300 * 1000, 0));
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false));
Position position = new Position();
position.setTime(new Date(System.currentTimeMillis() - 360000));
@@ -85,4 +86,29 @@ public class MotionEventHandlerTest extends BaseTest {
assertNull(deviceState.getMotionPosition());
}
+ @Test
+ public void testStopWithPositionIgnition() throws Exception {
+ MotionEventHandler motionEventHandler = new MotionEventHandler(
+ new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true));
+
+ Position position = new Position();
+ position.setTime(date("2017-01-01 00:00:00"));
+ position.set(Position.KEY_MOTION, false);
+ position.set(Position.KEY_IGNITION, true);
+ DeviceState deviceState = new DeviceState();
+ deviceState.setMotionState(true);
+ deviceState.setMotionPosition(position);
+
+ Position nextPosition = new Position();
+ nextPosition.setTime(date("2017-01-01 00:02:00"));
+ nextPosition.set(Position.KEY_MOTION, false);
+ nextPosition.set(Position.KEY_IGNITION, false);
+
+ Event event = motionEventHandler.updateMotionState(deviceState, nextPosition);
+ assertNotNull(event);
+ assertEquals(Event.TYPE_DEVICE_STOPPED, event.getType());
+ assertFalse(deviceState.getMotionState());
+ assertNull(deviceState.getMotionPosition());
+ }
+
}