aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java30
-rw-r--r--test/org/traccar/protocol/Vt200ProtocolDecoderTest.java7
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java12
3 files changed, 39 insertions, 10 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());
+ }
+
}
diff --git a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
index 37d9c46d9..42ed4a652 100644
--- a/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/Vt200ProtocolDecoderTest.java
@@ -13,6 +13,9 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"286310373094563082002701033d010817143327c68a14841e00c27f550e9a000000000c000000084700200120007d01af260b29"));
+ verifyAttributes(decoder, binary(
+ "2863103730945630880062033d862631037309456f222014604362936f010817140954010817144135076b00002a3800003b7d6127cc91040000000000000000000000005a0000088e000001ce02630000263b000009b401ff00000cb40000069c02af000018190200000102019729"));
+
verifyPosition(decoder, binary(
"286310373094562086002101033d010817143328441790420114817637207d090a00000847002001207f00d6f229"));
@@ -25,7 +28,7 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"28631037309456108800002e29"));
- verifyNull(decoder, binary(
+ verifyAttributes(decoder, binary(
"2863103730945630880062033c862631037309456f222014604362936f01081713365601081713571904c800001b2c000034f66827f0840000000000000000000000000047000006e7000001b9022a000023ff000007f2018a00000a10000003f300cd00000d8d0300000302002729"));
verifyNull(decoder, binary(
@@ -40,7 +43,7 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest {
verifyNull(decoder, binary(
"286310373094563089001200032f2107171740144417075001147188872c29"));
- verifyNull(decoder, binary(
+ verifyAttributes(decoder, binary(
"2863103730945630880062032f862631037309456f222014604362936f21071717373221071717401400a100000cd700000004020d3c8e0000000000000000000000000000000000000000000000000000000000000000000a000000040000000e009700000cc9000000000000e929"));
verifyPosition(decoder, binary(
diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java
index 14d8d87e0..c74109550 100644
--- a/test/org/traccar/reports/ReportUtilsTest.java
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -79,7 +79,7 @@ public class ReportUtilsTest extends BaseTest {
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);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false);
Collection<TripReport> trips = ReportUtils.detectTrips(data, tripsConfig, false, 0.01);
@@ -127,7 +127,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 1, 0),
position("2016-01-01 00:05:00.000", 0, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false);
Collection<StopReport> result = ReportUtils.detectStops(data, tripsConfig, false, 0.01);
@@ -153,7 +153,7 @@ public class ReportUtilsTest extends BaseTest {
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);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false);
Collection<StopReport> result = ReportUtils.detectStops(data, tripsConfig, false, 0.01);
@@ -179,7 +179,7 @@ public class ReportUtilsTest extends BaseTest {
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);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false);
Collection<StopReport> result = ReportUtils.detectStops(data, tripsConfig, false, 0.01);
@@ -205,7 +205,7 @@ public class ReportUtilsTest extends BaseTest {
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);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false);
Collection<StopReport> result = ReportUtils.detectStops(data, tripsConfig, false, 0.01);
@@ -227,7 +227,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:24:00.000", 5, 800),
position("2016-01-01 00:25:00.000", 5, 900));
- TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000);
+ TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false);
Collection<TripReport> trips = ReportUtils.detectTrips(data, tripsConfig, false, 0.01);