aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/FilterHandlerTest.java84
-rw-r--r--test/org/traccar/ProtocolTest.java1
-rw-r--r--test/org/traccar/TestIdentityManager.java6
-rw-r--r--test/org/traccar/WebDataHandlerTest.java12
-rw-r--r--test/org/traccar/config/ConfigTest.java (renamed from test/org/traccar/ConfigTest.java)4
-rw-r--r--test/org/traccar/handler/ComputedAttributesTest.java (renamed from test/org/traccar/processing/ComputedAttributesTest.java)31
-rw-r--r--test/org/traccar/handler/DistanceHandlerTest.java (renamed from test/org/traccar/DistanceHandlerTest.java)7
-rw-r--r--test/org/traccar/handler/FilterHandlerTest.java88
-rw-r--r--test/org/traccar/handler/MotionHandlerTest.java (renamed from test/org/traccar/MotionHandlerTest.java)4
-rw-r--r--test/org/traccar/handler/events/AlertEventHandlerTest.java (renamed from test/org/traccar/events/AlertEventHandlerTest.java)8
-rw-r--r--test/org/traccar/handler/events/CommandResultEventHandlerTest.java (renamed from test/org/traccar/events/CommandResultEventHandlerTest.java)2
-rw-r--r--test/org/traccar/handler/events/IgnitionEventHandlerTest.java (renamed from test/org/traccar/events/IgnitionEventHandlerTest.java)11
-rw-r--r--test/org/traccar/handler/events/MotionEventHandlerTest.java (renamed from test/org/traccar/events/MotionEventHandlerTest.java)8
-rw-r--r--test/org/traccar/handler/events/OverspeedEventHandlerTest.java (renamed from test/org/traccar/events/OverspeedEventHandlerTest.java)20
-rw-r--r--test/org/traccar/protocol/BoxProtocolDecoderTest.java5
-rw-r--r--test/org/traccar/protocol/CguardProtocolDecoderTest.java9
-rw-r--r--test/org/traccar/protocol/FifotrackProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/ItsProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java3
-rw-r--r--test/org/traccar/protocol/SuntechProtocolDecoderTest.java6
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java40
21 files changed, 214 insertions, 141 deletions
diff --git a/test/org/traccar/FilterHandlerTest.java b/test/org/traccar/FilterHandlerTest.java
deleted file mode 100644
index 818583eb7..000000000
--- a/test/org/traccar/FilterHandlerTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.traccar;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.traccar.model.Position;
-
-import java.util.Date;
-
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-
-public class FilterHandlerTest extends BaseTest {
-
- private FilterHandler filtingHandler;
- private FilterHandler passingHandler;
-
- @Before
- public void setUp() {
- passingHandler = new FilterHandler();
- filtingHandler = new FilterHandler();
- filtingHandler.setFilterInvalid(true);
- filtingHandler.setFilterZero(true);
- filtingHandler.setFilterDuplicate(true);
- filtingHandler.setFilterFuture(5 * 60);
- filtingHandler.setFilterApproximate(true);
- filtingHandler.setFilterStatic(true);
- filtingHandler.setFilterDistance(10);
- filtingHandler.setFilterMaxSpeed(500);
- filtingHandler.setSkipLimit(10);
- }
-
- @After
- public void tearDown() {
- filtingHandler = null;
- passingHandler = null;
- }
-
- private Position createPosition(
- long deviceId,
- Date time,
- boolean valid,
- double latitude,
- double longitude,
- double altitude,
- double speed,
- double course) {
-
- Position p = new Position();
- p.setDeviceId(deviceId);
- p.setTime(time);
- p.setValid(valid);
- p.setLatitude(latitude);
- p.setLongitude(longitude);
- p.setAltitude(altitude);
- p.setSpeed(speed);
- p.setCourse(course);
- return p;
- }
-
- @Test
- public void testFilterInvalid() throws Exception {
-
- Position position = createPosition(0, new Date(), true, 10, 10, 10, 10, 10);
-
- assertNotNull(filtingHandler.handlePosition(position));
- assertNotNull(passingHandler.handlePosition(position));
-
- position = createPosition(0, new Date(Long.MAX_VALUE), true, 10, 10, 10, 10, 10);
-
- assertNull(filtingHandler.handlePosition(position));
- assertNotNull(passingHandler.handlePosition(position));
-
- position = createPosition(0, new Date(), false, 10, 10, 10, 10, 10);
-
- assertNull(filtingHandler.handlePosition(position));
- assertNotNull(passingHandler.handlePosition(position));
-
- position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
- filtingHandler.setSkipAttributes(true);
- assertNotNull(filtingHandler.handlePosition(position));
- }
-
-}
diff --git a/test/org/traccar/ProtocolTest.java b/test/org/traccar/ProtocolTest.java
index 181af885d..4d48bb763 100644
--- a/test/org/traccar/ProtocolTest.java
+++ b/test/org/traccar/ProtocolTest.java
@@ -173,6 +173,7 @@ public class ProtocolTest extends BaseTest {
} else {
+ assertNotNull(position.getServerTime());
assertNotNull(position.getFixTime());
assertTrue("year > 1999", position.getFixTime().after(new Date(915148800000L)));
assertTrue("time < +25 hours",
diff --git a/test/org/traccar/TestIdentityManager.java b/test/org/traccar/TestIdentityManager.java
index 1b3f95ad8..0f7405dbd 100644
--- a/test/org/traccar/TestIdentityManager.java
+++ b/test/org/traccar/TestIdentityManager.java
@@ -63,4 +63,10 @@ public final class TestIdentityManager implements IdentityManager {
return defaultValue;
}
+ @Override
+ public double lookupAttributeDouble(
+ long deviceId, String attributeName, double defaultValue, boolean lookupConfig) {
+ return defaultValue;
+ }
+
}
diff --git a/test/org/traccar/WebDataHandlerTest.java b/test/org/traccar/WebDataHandlerTest.java
index 9b003a425..cfbd71f23 100644
--- a/test/org/traccar/WebDataHandlerTest.java
+++ b/test/org/traccar/WebDataHandlerTest.java
@@ -1,6 +1,8 @@
package org.traccar;
import org.junit.Test;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.model.Position;
import static org.junit.Assert.assertEquals;
@@ -10,14 +12,16 @@ public class WebDataHandlerTest extends ProtocolTest {
@Test
public void testFormatRequest() throws Exception {
- Position p = position("2016-01-01 01:02:03.000", true, 20, 30);
+ Config config = new Config();
+ config.setString(Keys.FORWARD_URL, "http://localhost/?fixTime={fixTime}&gprmc={gprmc}&name={name}");
- WebDataHandler handler = new WebDataHandler(
- Context.getIdentityManager(), null, null, "http://localhost/?fixTime={fixTime}&gprmc={gprmc}&name={name}", false);
+ Position position = position("2016-01-01 01:02:03.000", true, 20, 30);
+
+ WebDataHandler handler = new WebDataHandler(config, Context.getIdentityManager(), null, null);
assertEquals(
"http://localhost/?fixTime=1451610123000&gprmc=$GPRMC,010203.000,A,2000.0000,N,03000.0000,E,0.00,0.00,010116,,*05&name=test",
- handler.formatRequest(p));
+ handler.formatRequest(position));
}
diff --git a/test/org/traccar/ConfigTest.java b/test/org/traccar/config/ConfigTest.java
index fa404b827..13d0ffb04 100644
--- a/test/org/traccar/ConfigTest.java
+++ b/test/org/traccar/config/ConfigTest.java
@@ -1,8 +1,8 @@
-package org.traccar;
+package org.traccar.config;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
-import org.traccar.Config;
+import org.traccar.config.Config;
public class ConfigTest {
diff --git a/test/org/traccar/processing/ComputedAttributesTest.java b/test/org/traccar/handler/ComputedAttributesTest.java
index 160067915..a76d8169b 100644
--- a/test/org/traccar/processing/ComputedAttributesTest.java
+++ b/test/org/traccar/handler/ComputedAttributesTest.java
@@ -1,8 +1,9 @@
-package org.traccar.processing;
+package org.traccar.handler;
import java.util.Date;
import org.junit.Test;
+import org.traccar.config.Config;
import org.traccar.model.Attribute;
import org.traccar.model.Position;
@@ -12,9 +13,11 @@ public class ComputedAttributesTest {
@Test
public void testComputedAttributes() {
- Position position = new Position();
- ComputedAttributesHandler computedAttributesHandler = new ComputedAttributesHandler();
+
+ ComputedAttributesHandler handler = new ComputedAttributesHandler(new Config(), null, null);
+
Date date = new Date();
+ Position position = new Position();
position.setTime(date);
position.setSpeed(42);
position.setValid(false);
@@ -27,40 +30,40 @@ public class ComputedAttributesTest {
Attribute attribute = new Attribute();
attribute.setExpression("adc1");
- assertEquals(128, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(128, handler.computeAttribute(attribute, position));
attribute.setExpression("!booleanFlag");
- assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(false, handler.computeAttribute(attribute, position));
attribute.setExpression("adc2 * 2 + 50");
- assertEquals(250, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(250, handler.computeAttribute(attribute, position));
attribute.setExpression("(bitFlag & 4) != 0");
- assertEquals(true, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(true, handler.computeAttribute(attribute, position));
attribute.setExpression("if (event == 42) \"lowBattery\"");
- assertEquals("lowBattery", computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals("lowBattery", handler.computeAttribute(attribute, position));
attribute.setExpression("speed > 5 && valid");
- assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(false, handler.computeAttribute(attribute, position));
attribute.setExpression("fixTime");
- assertEquals(date, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(date, handler.computeAttribute(attribute, position));
attribute.setExpression("math:pow(adc1, 2)");
- assertEquals(16384.0, computedAttributesHandler.computeAttribute(attribute, position));
+ assertEquals(16384.0, handler.computeAttribute(attribute, position));
// modification tests
attribute.setExpression("adc1 = 256");
- computedAttributesHandler.computeAttribute(attribute, position);
+ handler.computeAttribute(attribute, position);
assertEquals(128, position.getInteger("adc1"));
attribute.setExpression("result = \"fail\"");
- computedAttributesHandler.computeAttribute(attribute, position);
+ handler.computeAttribute(attribute, position);
assertEquals("success", position.getString("result"));
attribute.setExpression("fixTime = \"2017-10-18 10:00:01\"");
- computedAttributesHandler.computeAttribute(attribute, position);
+ handler.computeAttribute(attribute, position);
assertEquals(date, position.getFixTime());
}
diff --git a/test/org/traccar/DistanceHandlerTest.java b/test/org/traccar/handler/DistanceHandlerTest.java
index c97135074..f7c6e42cd 100644
--- a/test/org/traccar/DistanceHandlerTest.java
+++ b/test/org/traccar/handler/DistanceHandlerTest.java
@@ -1,6 +1,7 @@
-package org.traccar;
+package org.traccar.handler;
import org.junit.Test;
+import org.traccar.config.Config;
import org.traccar.model.Position;
import static org.junit.Assert.assertEquals;
@@ -8,9 +9,9 @@ import static org.junit.Assert.assertEquals;
public class DistanceHandlerTest {
@Test
- public void testCalculateDistance() throws Exception {
+ public void testCalculateDistance() {
- DistanceHandler distanceHandler = new DistanceHandler(false, 0, 0);
+ DistanceHandler distanceHandler = new DistanceHandler(new Config(), null);
Position position = distanceHandler.handlePosition(new Position());
diff --git a/test/org/traccar/handler/FilterHandlerTest.java b/test/org/traccar/handler/FilterHandlerTest.java
new file mode 100644
index 000000000..ad8d244a6
--- /dev/null
+++ b/test/org/traccar/handler/FilterHandlerTest.java
@@ -0,0 +1,88 @@
+package org.traccar.handler;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.traccar.BaseTest;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
+import org.traccar.model.Position;
+
+import java.util.Date;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+public class FilterHandlerTest extends BaseTest {
+
+ private FilterHandler passingHandler = new FilterHandler(new Config());
+ private FilterHandler filteringHandler;
+
+ @Before
+ public void before() {
+ Config config = new Config();
+ config.setString(Keys.FILTER_INVALID, String.valueOf(true));
+ config.setString(Keys.FILTER_ZERO, String.valueOf(true));
+ config.setString(Keys.FILTER_DUPLICATE, String.valueOf(true));
+ config.setString(Keys.FILTER_FUTURE, String.valueOf(5 * 60));
+ config.setString(Keys.FILTER_APPROXIMATE, String.valueOf(true));
+ config.setString(Keys.FILTER_STATIC, String.valueOf(true));
+ config.setString(Keys.FILTER_DISTANCE, String.valueOf(10));
+ config.setString(Keys.FILTER_MAX_SPEED, String.valueOf(500));
+ config.setString(Keys.FILTER_SKIP_LIMIT, String.valueOf(10));
+ config.setString(Keys.FILTER_SKIP_ATTRIBUTES_ENABLE, String.valueOf(true));
+ filteringHandler = new FilterHandler(config);
+ }
+
+ private Position createPosition(
+ long deviceId,
+ Date time,
+ boolean valid,
+ double latitude,
+ double longitude,
+ double altitude,
+ double speed,
+ double course) {
+
+ Position position = new Position();
+ position.setDeviceId(deviceId);
+ position.setTime(time);
+ position.setValid(valid);
+ position.setLatitude(latitude);
+ position.setLongitude(longitude);
+ position.setAltitude(altitude);
+ position.setSpeed(speed);
+ position.setCourse(course);
+ return position;
+ }
+
+ @Test
+ public void testFilter() {
+
+ Position position = createPosition(0, new Date(), true, 10, 10, 10, 10, 10);
+
+ assertNotNull(filteringHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
+
+ position = createPosition(0, new Date(Long.MAX_VALUE), true, 10, 10, 10, 10, 10);
+
+ assertNull(filteringHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
+
+ position = createPosition(0, new Date(), false, 10, 10, 10, 10, 10);
+
+ assertNull(filteringHandler.handlePosition(position));
+ assertNotNull(passingHandler.handlePosition(position));
+
+ }
+
+ @Test
+ public void testSkipAttributes() {
+
+ Position position = createPosition(0, new Date(), true, 10, 10, 10, 0, 10);
+ position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
+
+ assertNotNull(filteringHandler.handlePosition(position));
+
+ }
+
+}
diff --git a/test/org/traccar/MotionHandlerTest.java b/test/org/traccar/handler/MotionHandlerTest.java
index fc6dce033..9e0859664 100644
--- a/test/org/traccar/MotionHandlerTest.java
+++ b/test/org/traccar/handler/MotionHandlerTest.java
@@ -1,4 +1,4 @@
-package org.traccar;
+package org.traccar.handler;
import static org.junit.Assert.assertEquals;
@@ -8,7 +8,7 @@ import org.traccar.model.Position;
public class MotionHandlerTest {
@Test
- public void testCalculateMotion() throws Exception {
+ public void testCalculateMotion() {
MotionHandler motionHandler = new MotionHandler(0.01);
diff --git a/test/org/traccar/events/AlertEventHandlerTest.java b/test/org/traccar/handler/events/AlertEventHandlerTest.java
index 4e11398e1..3f0823245 100644
--- a/test/org/traccar/events/AlertEventHandlerTest.java
+++ b/test/org/traccar/handler/events/AlertEventHandlerTest.java
@@ -1,4 +1,4 @@
-package org.traccar.events;
+package org.traccar.handler.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
@@ -7,15 +7,17 @@ import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
+import org.traccar.TestIdentityManager;
+import org.traccar.config.Config;
import org.traccar.model.Event;
import org.traccar.model.Position;
public class AlertEventHandlerTest extends BaseTest {
@Test
- public void testAlertEventHandler() throws Exception {
+ public void testAlertEventHandler() {
- AlertEventHandler alertEventHandler = new AlertEventHandler();
+ AlertEventHandler alertEventHandler = new AlertEventHandler(new Config(), new TestIdentityManager());
Position position = new Position();
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
diff --git a/test/org/traccar/events/CommandResultEventHandlerTest.java b/test/org/traccar/handler/events/CommandResultEventHandlerTest.java
index 602108d1a..0ccf9f6b4 100644
--- a/test/org/traccar/events/CommandResultEventHandlerTest.java
+++ b/test/org/traccar/handler/events/CommandResultEventHandlerTest.java
@@ -1,4 +1,4 @@
-package org.traccar.events;
+package org.traccar.handler.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
diff --git a/test/org/traccar/events/IgnitionEventHandlerTest.java b/test/org/traccar/handler/events/IgnitionEventHandlerTest.java
index 7c4ac21b9..dade20fb8 100644
--- a/test/org/traccar/events/IgnitionEventHandlerTest.java
+++ b/test/org/traccar/handler/events/IgnitionEventHandlerTest.java
@@ -1,26 +1,27 @@
-package org.traccar.events;
+package org.traccar.handler.events;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
+import org.traccar.TestIdentityManager;
import org.traccar.model.Event;
import org.traccar.model.Position;
public class IgnitionEventHandlerTest extends BaseTest {
@Test
- public void testIgnitionEventHandler() throws Exception {
+ public void testIgnitionEventHandler() {
- IgnitionEventHandler ignitionEventHandler = new IgnitionEventHandler();
+ IgnitionEventHandler ignitionEventHandler = new IgnitionEventHandler(new TestIdentityManager());
Position position = new Position();
position.set(Position.KEY_IGNITION, true);
position.setValid(true);
Map<Event, Position> events = ignitionEventHandler.analyzePosition(position);
- assertEquals(events, null);
+ assertNull(events);
}
}
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/handler/events/MotionEventHandlerTest.java
index 3fc63adf0..f57c16635 100644
--- a/test/org/traccar/events/MotionEventHandlerTest.java
+++ b/test/org/traccar/handler/events/MotionEventHandlerTest.java
@@ -1,4 +1,4 @@
-package org.traccar.events;
+package org.traccar.handler.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -31,7 +31,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionWithPosition() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(
- new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
+ null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
Position position = new Position();
position.setTime(date("2017-01-01 00:00:00"));
@@ -72,7 +72,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionWithStatus() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(
- new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
+ null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01));
Position position = new Position();
position.setTime(new Date(System.currentTimeMillis() - 360000));
@@ -93,7 +93,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testStopWithPositionIgnition() throws Exception {
MotionEventHandler motionEventHandler = new MotionEventHandler(
- new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false, 0.01));
+ null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false, 0.01));
Position position = new Position();
position.setTime(date("2017-01-01 00:00:00"));
diff --git a/test/org/traccar/events/OverspeedEventHandlerTest.java b/test/org/traccar/handler/events/OverspeedEventHandlerTest.java
index 98fd0f87a..515f37b5d 100644
--- a/test/org/traccar/events/OverspeedEventHandlerTest.java
+++ b/test/org/traccar/handler/events/OverspeedEventHandlerTest.java
@@ -1,4 +1,4 @@
-package org.traccar.events;
+package org.traccar.handler.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
@@ -14,6 +14,8 @@ import java.util.TimeZone;
import org.junit.Test;
import org.traccar.BaseTest;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
import org.traccar.model.DeviceState;
import org.traccar.model.Event;
import org.traccar.model.Position;
@@ -26,8 +28,12 @@ public class OverspeedEventHandlerTest extends BaseTest {
return dateFormat.parse(time);
}
- private void testOverspeedWithPosition(boolean notRepeat, long geofenceId) throws Exception {
- OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat, false);
+ private void testOverspeedWithPosition(boolean notRepeat, long geofenceId) throws ParseException {
+ Config config = new Config();
+ config.setString(Keys.EVENT_OVERSPEED_NOT_REPEAT, String.valueOf(notRepeat));
+ config.setString(Keys.EVENT_OVERSPEED_MINIMAL_DURATION, String.valueOf(15));
+ config.setString(Keys.EVENT_OVERSPEED_PREFER_LOWEST, String.valueOf(false));
+ OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(config, null, null);
Position position = new Position();
position.setTime(date("2017-01-01 00:00:00"));
@@ -85,8 +91,12 @@ public class OverspeedEventHandlerTest extends BaseTest {
assertEquals(0, deviceState.getOverspeedGeofenceId());
}
- private void testOverspeedWithStatus(boolean notRepeat) throws Exception {
- OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat, false);
+ private void testOverspeedWithStatus(boolean notRepeat) {
+ Config config = new Config();
+ config.setString(Keys.EVENT_OVERSPEED_NOT_REPEAT, String.valueOf(notRepeat));
+ config.setString(Keys.EVENT_OVERSPEED_MINIMAL_DURATION, String.valueOf(15));
+ config.setString(Keys.EVENT_OVERSPEED_PREFER_LOWEST, String.valueOf(false));
+ OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(config, null, null);
Position position = new Position();
position.setTime(new Date(System.currentTimeMillis() - 30000));
diff --git a/test/org/traccar/protocol/BoxProtocolDecoderTest.java b/test/org/traccar/protocol/BoxProtocolDecoderTest.java
index f117d1ede..d661a10f2 100644
--- a/test/org/traccar/protocol/BoxProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/BoxProtocolDecoderTest.java
@@ -10,7 +10,7 @@ public class BoxProtocolDecoderTest extends ProtocolTest {
public void testDecode() throws Exception {
BoxProtocolDecoder decoder = new BoxProtocolDecoder(null);
-
+
verifyNull(decoder, text(
"H,BT,358281002435893,081028142432,F5813D19,6D6E6DC2"));
@@ -18,6 +18,9 @@ public class BoxProtocolDecoderTest extends ProtocolTest {
"H,BT,N878123,080415081234,D63E6DD9,6D6E6DC2,8944100300825505377"));
verifyPosition(decoder, text(
+ "L,190227043304,G,25.68773,48.59788,71,53,261.42,1,23;A,0.03;D,0.06;I,0"));
+
+ verifyPosition(decoder, text(
"L,081028142429,G,52.51084,-1.70849,0,170,0,1,0"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/CguardProtocolDecoderTest.java b/test/org/traccar/protocol/CguardProtocolDecoderTest.java
index 1be301069..a386b6b47 100644
--- a/test/org/traccar/protocol/CguardProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/CguardProtocolDecoderTest.java
@@ -14,6 +14,15 @@ public class CguardProtocolDecoderTest extends ProtocolTest {
"IDRO:354868050655283"));
verifyPosition(decoder, text(
+ "NV:190225 144543:55.776505:37.729000:0:10:0:0"));
+
+ verifyAttributes(decoder, text(
+ "BC:190225 144543:CSQ1:64:NSQ1:0:NSQ2:1:BAT1:100"));
+
+ verifyAttributes(decoder, text(
+ "BC:190225 142653:CSQ1:80:NSQ1:0:NSQ2:1:BAT1:3.53"));
+
+ verifyPosition(decoder, text(
"NV:170409 031456:56.808553:60.595476:0:NAN:0"));
verifyAttributes(decoder, text(
diff --git a/test/org/traccar/protocol/FifotrackProtocolDecoderTest.java b/test/org/traccar/protocol/FifotrackProtocolDecoderTest.java
index 989b6b673..1dcfc89c4 100644
--- a/test/org/traccar/protocol/FifotrackProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/FifotrackProtocolDecoderTest.java
@@ -10,6 +10,9 @@ public class FifotrackProtocolDecoderTest extends ProtocolTest {
FifotrackProtocolDecoder decoder = new FifotrackProtocolDecoder(null);
+ verifyNull(decoder, text(
+ "$$79,868345037864709,382,D05,190220085833,22.643210,114.018176,1,1,1,13152,23FFD339*25"));
+
verifyPosition(decoder, text(
"$$105,866104023179743,AB,A00,,161007085534,A,54.738791,25.271918,0,350,151,0,17929,0000,0,,246|1|65|96DB,936|0*0B"));
diff --git a/test/org/traccar/protocol/ItsProtocolDecoderTest.java b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
index 4cadfc996..0281320a9 100644
--- a/test/org/traccar/protocol/ItsProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/ItsProtocolDecoderTest.java
@@ -11,6 +11,9 @@ public class ItsProtocolDecoderTest extends ProtocolTest {
ItsProtocolDecoder decoder = new ItsProtocolDecoder(null);
verifyPosition(decoder, text(
+ "$NRM,ROADRPA,1.7AIS,NR,01,L,869867036345389,,1,25022019,051716,25.12891000,N,75.85587833,E,7.6,350.00,14,284.8,1.00,1.00,AIRTEL,1,1,28.0,4.2,0,C,13,404,70,4E3B,3C84,11,4E3B,39B8,08,4E3B,3965,07,4E3B,48B5,07,4E3B,3C85,0000,00,000551,71978C6B"));
+
+ verifyPosition(decoder, text(
"$,1,CHVTS,CHVTS1.0,DT,16,L,861359039868243,861359039868243,1,05022019,071225,19.965062,N,73.736088,E,0,050,03,0632,6.67,6.75,Idea Cel,1,1,23.96,4.0,0,W,28,404,004,4e2b,49e,4e2bea86727ab3d6704e2bea7714e2be9d72,0000,00,001133,232"));
verifyPosition(decoder, text(
diff --git a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
index 553e7eb16..248920e21 100644
--- a/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/OwnTracksProtocolDecoderTest.java
@@ -12,6 +12,9 @@ public class OwnTracksProtocolDecoderTest extends ProtocolTest {
OwnTracksProtocolDecoder decoder = new OwnTracksProtocolDecoder(null);
verifyPosition(decoder, request(HttpMethod.POST, "/",
+ buffer("{\"_type\":\"location\",\"acc\":15,\"alt\":440,\"batt\":46,\"conn\":\"w\",\"lat\":46.0681247,\"lon\":11.1512805,\"t\":\"u\",\"tid\":\"5t\",\"tst\":1551874878,\"vac\":2,\"vel\":0}")));
+
+ verifyPosition(decoder, request(HttpMethod.POST, "/",
buffer("{\"lon\":2.29513,\"lat\":48.85833,\"tst\":1497349316,\"_type\":\"location\",\"tid\":\"JJ\"}")));
verifyPosition(decoder, request(HttpMethod.POST, "/",
diff --git a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
index 2681e6143..355cda783 100644
--- a/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
+++ b/test/org/traccar/protocol/SuntechProtocolDecoderTest.java
@@ -33,6 +33,12 @@ public class SuntechProtocolDecoderTest extends ProtocolTest {
decoder.setHbm(true);
+ verifyPosition(decoder, text(
+ "ST300STT;007238270;40;313;20190220;12:05:04;c99e48;+04.644623;-074.076922;010.390;202.77;20;1;997100;14.10;100000;2;8384;003634;4.1;1"));
+
+ verifyPosition(decoder, text(
+ "ST300STT;109002029;08;1080;20190220;13:00:55;85405;+04.645710;-074.078525;007.760;005.19;10;1;6520802;13.86;100100;4;1716;0000039863;4.1;1;0.00;0000;0000;0;0"));
+
verifyAttribute(decoder, text(
"ST300ALT;007239104;40;313;20190112;01:07:16;c99139;+04.703287;-074.148897;000.000;189.72;21;1;425512;12.61;100000;33;003188;4.1;1"),
Position.KEY_HOURS, 3188 * 60000L);
diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java
index a8ff653c9..01b9c276f 100644
--- a/test/org/traccar/reports/ReportUtilsTest.java
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -17,6 +17,7 @@ import java.util.TimeZone;
import org.junit.Test;
import org.traccar.BaseTest;
+import org.traccar.TestIdentityManager;
import org.traccar.model.Position;
import org.traccar.reports.model.StopReport;
import org.traccar.reports.model.TripReport;
@@ -79,7 +80,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
- Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -93,7 +95,8 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
- Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -131,7 +134,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01);
- Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -145,7 +149,8 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
- trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+ trips = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -159,7 +164,8 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(3000, itemTrip.getDistance(), 0.01);
- Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -199,7 +205,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
- Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -213,7 +220,8 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(10, itemTrip.getMaxSpeed(), 0.01);
assertEquals(7000, itemTrip.getDistance(), 0.01);
- Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());
@@ -247,7 +255,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -273,7 +282,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -299,7 +309,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertFalse(result.isEmpty());
@@ -325,7 +336,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
- Collection<StopReport> result = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> result = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(result);
assertTrue(result.isEmpty());
@@ -347,7 +359,8 @@ public class ReportUtilsTest extends BaseTest {
TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01);
- Collection<TripReport> trips = ReportUtils.detectTripsAndStops(data, tripsConfig, false, TripReport.class);
+ Collection<TripReport> trips = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class);
assertNotNull(trips);
assertFalse(trips.isEmpty());
@@ -361,7 +374,8 @@ public class ReportUtilsTest extends BaseTest {
assertEquals(7, itemTrip.getMaxSpeed(), 0.01);
assertEquals(600, itemTrip.getDistance(), 0.01);
- Collection<StopReport> stops = ReportUtils.detectTripsAndStops(data, tripsConfig, false, StopReport.class);
+ Collection<StopReport> stops = ReportUtils.detectTripsAndStops(
+ new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class);
assertNotNull(stops);
assertFalse(stops.isEmpty());