diff options
Diffstat (limited to 'src/test')
368 files changed, 1946 insertions, 1123 deletions
diff --git a/src/test/java/org/traccar/BaseTest.java b/src/test/java/org/traccar/BaseTest.java index 0b2c616ce..c784150dd 100644 --- a/src/test/java/org/traccar/BaseTest.java +++ b/src/test/java/org/traccar/BaseTest.java @@ -1,34 +1,69 @@ package org.traccar; -import io.netty.buffer.ByteBuf; +import io.netty.channel.Channel; +import org.traccar.config.Config; +import org.traccar.database.CommandsManager; import org.traccar.database.MediaManager; +import org.traccar.database.StatisticsManager; +import org.traccar.model.Device; +import org.traccar.session.ConnectionManager; +import org.traccar.session.DeviceSession; +import org.traccar.session.cache.CacheManager; -import java.util.HashMap; -import java.util.Map; +import java.net.SocketAddress; +import java.util.HashSet; -public class BaseTest { - - public static class MockMediaManager extends MediaManager { - Map<String, ByteBuf> files = new HashMap<>(); +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; - MockMediaManager() { - super(""); - } +public class BaseTest { - @Override - public String writeFile(String uniqueId, ByteBuf buf, String extension) { - String fileName = uniqueId + "/mock." + extension; - files.put(fileName, buf); - return fileName; - } + protected <T extends BaseProtocolDecoder> T inject(T decoder) throws Exception { + var config = new Config(); + decoder.setConfig(config); + var device = mock(Device.class); + when(device.getId()).thenReturn(1L); + var cacheManager = mock(CacheManager.class); + when(cacheManager.getConfig()).thenReturn(config); + when(cacheManager.getObject(eq(Device.class), anyLong())).thenReturn(device); + decoder.setCacheManager(cacheManager); + var connectionManager = mock(ConnectionManager.class); + var uniqueIdsProvided = new HashSet<Boolean>(); + when(connectionManager.getDeviceSession(any(), any(), any(), any())).thenAnswer(invocation -> { + var mock = new DeviceSession(1L, "", mock(Protocol.class), mock(Channel.class), mock(SocketAddress.class)); + if (uniqueIdsProvided.isEmpty()) { + if (invocation.getArguments().length > 3) { + uniqueIdsProvided.add(true); + return mock; + } + return null; + } else { + return mock; + } + }); + decoder.setConnectionManager(connectionManager); + decoder.setStatisticsManager(mock(StatisticsManager.class)); + decoder.setMediaManager(mock(MediaManager.class)); + decoder.setCommandsManager(mock(CommandsManager.class)); + return decoder; + } - public ByteBuf readFile(String fileName) { - return files.get(fileName); - } + protected <T extends BaseFrameDecoder> T inject(T decoder) throws Exception { + return decoder; } - static { - Context.init(new TestIdentityManager(), new MockMediaManager()); + protected <T extends BaseProtocolEncoder> T inject(T encoder) throws Exception { + var device = mock(Device.class); + when(device.getId()).thenReturn(1L); + when(device.getUniqueId()).thenReturn("123456789012345"); + var cacheManager = mock(CacheManager.class); + when(cacheManager.getConfig()).thenReturn(mock(Config.class)); + when(cacheManager.getObject(eq(Device.class), anyLong())).thenReturn(device); + encoder.setCacheManager(cacheManager); + return encoder; } } diff --git a/src/test/java/org/traccar/ProtocolTest.java b/src/test/java/org/traccar/ProtocolTest.java index c40a15dcc..5e37f44b9 100644 --- a/src/test/java/org/traccar/ProtocolTest.java +++ b/src/test/java/org/traccar/ProtocolTest.java @@ -4,14 +4,17 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufUtil; import io.netty.buffer.Unpooled; import io.netty.handler.codec.http.DefaultFullHttpRequest; +import io.netty.handler.codec.http.DefaultFullHttpResponse; import io.netty.handler.codec.http.DefaultHttpHeaders; import io.netty.handler.codec.http.HttpHeaders; import io.netty.handler.codec.http.HttpMethod; +import io.netty.handler.codec.http.HttpResponseStatus; import io.netty.handler.codec.http.HttpVersion; import org.traccar.helper.DataConverter; import org.traccar.model.CellTower; import org.traccar.model.Command; import org.traccar.model.Position; +import org.traccar.model.WifiAccessPoint; import java.nio.charset.StandardCharsets; import java.text.DateFormat; @@ -89,6 +92,10 @@ public class ProtocolTest extends BaseTest { return new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, method, url, Unpooled.buffer(), headers, new DefaultHttpHeaders()); } + protected DefaultFullHttpResponse response(ByteBuf data) { + return new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.OK, data); + } + protected void verifyNotNull(BaseProtocolDecoder decoder, Object object) throws Exception { assertNotNull(decoder.decode(null, null, object)); } @@ -304,12 +311,20 @@ public class ProtocolTest extends BaseTest { assertTrue(attributes.get(Position.KEY_RESULT) instanceof String); } - if (position.getNetwork() != null && position.getNetwork().getCellTowers() != null) { - for (CellTower cellTower : position.getNetwork().getCellTowers()) { - checkInteger(cellTower.getMobileCountryCode(), 0, 999); - checkInteger(cellTower.getMobileNetworkCode(), 0, 999); - checkInteger(cellTower.getLocationAreaCode(), 1, 65535); - checkInteger(cellTower.getCellId(), 0, 268435455); + if (position.getNetwork() != null) { + if (position.getNetwork().getCellTowers() != null) { + for (CellTower cellTower : position.getNetwork().getCellTowers()) { + checkInteger(cellTower.getMobileCountryCode(), 0, 999); + checkInteger(cellTower.getMobileNetworkCode(), 0, 999); + checkInteger(cellTower.getLocationAreaCode(), 1, 65535); + checkInteger(cellTower.getCellId(), 0, 268435455); + } + } + + if (position.getNetwork().getWifiAccessPoints() != null) { + for (WifiAccessPoint wifiAccessPoint : position.getNetwork().getWifiAccessPoints()) { + assertTrue(wifiAccessPoint.getMacAddress().matches("((\\p{XDigit}{2}):){5}(\\p{XDigit}{2})")); + } } } diff --git a/src/test/java/org/traccar/TestIdentityManager.java b/src/test/java/org/traccar/TestIdentityManager.java deleted file mode 100644 index 7d2865e74..000000000 --- a/src/test/java/org/traccar/TestIdentityManager.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.traccar; - -import org.traccar.database.IdentityManager; -import org.traccar.model.Device; -import org.traccar.model.Position; - -public final class TestIdentityManager implements IdentityManager { - - private static Device createDevice() { - Device device = new Device(); - device.setId(1); - device.setName("test"); - device.setUniqueId("123456789012345"); - return device; - } - - @Override - public long addUnknownDevice(String uniqueId) { - return 1; - } - - @Override - public Device getById(long id) { - return createDevice(); - } - - @Override - public Device getByUniqueId(String uniqueId) { - return createDevice(); - } - - @Override - public String getDevicePassword(long id, String protocol, String defaultPassword) { - return defaultPassword; - } - - @Override - public Position getLastPosition(long deviceId) { - return null; - } - - @Override - public boolean isLatestPosition(Position position) { - return true; - } - - @Override - public boolean lookupAttributeBoolean( - long deviceId, String attributeName, boolean defaultValue, boolean lookupServer, boolean lookupConfig) { - return defaultValue; - } - - @Override - public String lookupAttributeString( - long deviceId, String attributeName, String defaultValue, boolean lookupServer, boolean lookupConfig) { - if (attributeName.equals("filter.skipAttributes")) { - return "alarm,result"; - } - return defaultValue; - } - - @Override - public int lookupAttributeInteger( - long deviceId, String attributeName, int defaultValue, boolean lookupServer, boolean lookupConfig) { - return defaultValue; - } - - @Override - public long lookupAttributeLong( - long deviceId, String attributeName, long defaultValue, boolean lookupServer, boolean lookupConfig) { - return defaultValue; - } - - @Override - public double lookupAttributeDouble( - long deviceId, String attributeName, double defaultValue, boolean lookupServer, boolean lookupConfig) { - return defaultValue; - } - -} diff --git a/src/test/java/org/traccar/WebDataHandlerTest.java b/src/test/java/org/traccar/WebDataHandlerTest.java deleted file mode 100644 index cfbd71f23..000000000 --- a/src/test/java/org/traccar/WebDataHandlerTest.java +++ /dev/null @@ -1,28 +0,0 @@ -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; - -public class WebDataHandlerTest extends ProtocolTest { - - @Test - public void testFormatRequest() throws Exception { - - Config config = new Config(); - config.setString(Keys.FORWARD_URL, "http://localhost/?fixTime={fixTime}&gprmc={gprmc}&name={name}"); - - 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(position)); - - } - -} diff --git a/src/test/java/org/traccar/calendar/CalendarTest.java b/src/test/java/org/traccar/calendar/CalendarTest.java index 56406d4b8..def67ff76 100644 --- a/src/test/java/org/traccar/calendar/CalendarTest.java +++ b/src/test/java/org/traccar/calendar/CalendarTest.java @@ -1,5 +1,9 @@ package org.traccar.calendar; +import net.fortuna.ical4j.data.ParserException; +import org.junit.Test; +import org.traccar.model.Calendar; + import java.io.IOException; import java.sql.SQLException; import java.text.DateFormat; @@ -7,11 +11,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import org.junit.Test; -import org.traccar.model.Calendar; - -import net.fortuna.ical4j.data.ParserException; - import static org.junit.Assert.assertTrue; public class CalendarTest { diff --git a/src/test/java/org/traccar/config/ConfigTest.java b/src/test/java/org/traccar/config/ConfigTest.java index 13d0ffb04..8ba6dace6 100644 --- a/src/test/java/org/traccar/config/ConfigTest.java +++ b/src/test/java/org/traccar/config/ConfigTest.java @@ -1,8 +1,8 @@ package org.traccar.config; import org.junit.Test; + import static org.junit.Assert.assertEquals; -import org.traccar.config.Config; public class ConfigTest { diff --git a/src/test/java/org/traccar/database/DataManagerTest.java b/src/test/java/org/traccar/database/DataManagerTest.java deleted file mode 100644 index 23043e96e..000000000 --- a/src/test/java/org/traccar/database/DataManagerTest.java +++ /dev/null @@ -1,81 +0,0 @@ -package org.traccar.database; - -import org.junit.Test; -import org.traccar.model.Attribute; -import org.traccar.model.Device; -import org.traccar.model.Driver; -import org.traccar.model.Geofence; -import org.traccar.model.Group; -import org.traccar.model.ManagedUser; -import org.traccar.model.Position; -import org.traccar.model.User; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class DataManagerTest { - - @Test - public void constructObjectQuery() { - assertEquals("SELECT * FROM tc_users", - DataManager.constructObjectQuery(DataManager.ACTION_SELECT_ALL, User.class, false)); - assertEquals("DELETE FROM tc_groups WHERE id = :id", - DataManager.constructObjectQuery(DataManager.ACTION_DELETE, Group.class, false)); - assertEquals("SELECT * FROM tc_positions WHERE id = :id", - DataManager.constructObjectQuery(DataManager.ACTION_SELECT, Position.class, false)); - - String insertDevice = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Device.class, false); - assertFalse(insertDevice.contains("class")); - assertFalse(insertDevice.contains("id")); - assertFalse(insertDevice.contains("status")); - assertFalse(insertDevice.contains("geofenceIds")); - - String updateDeviceStatus = DataManager.constructObjectQuery("update", Device.class, true); - assertTrue(updateDeviceStatus.contains("lastUpdate")); - - String updateUser = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, false); - assertFalse(updateUser.contains("class")); - assertFalse(updateUser.contains("password")); - assertFalse(updateUser.contains("salt")); - - String updateUserPassword = DataManager.constructObjectQuery(DataManager.ACTION_UPDATE, User.class, true); - assertFalse(updateUserPassword.contains("name")); - assertTrue(updateUserPassword.contains("hashedPassword")); - assertTrue(updateUserPassword.contains("salt")); - - String insertPosition = DataManager.constructObjectQuery(DataManager.ACTION_INSERT, Position.class, false); - assertFalse(insertPosition.contains("type")); - assertFalse(insertPosition.contains("outdated")); - - } - - @Test - public void constructPermissionsQuery() { - assertEquals("SELECT userId, deviceId FROM tc_user_device", - DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, Device.class)); - - assertEquals("SELECT userId, managedUserId FROM tc_user_user", - DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, User.class, ManagedUser.class)); - - assertEquals("SELECT deviceId, driverId FROM tc_device_driver", - DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Device.class, Driver.class)); - - assertEquals("SELECT groupId, geofenceId FROM tc_group_geofence", - DataManager.constructPermissionQuery(DataManager.ACTION_SELECT_ALL, Group.class, Geofence.class)); - - assertEquals("INSERT INTO tc_user_device (userId, deviceId) VALUES (:userId, :deviceId)", - DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, User.class, Device.class)); - - assertEquals("DELETE FROM tc_user_user WHERE userId = :userId AND managedUserId = :managedUserId", - DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, User.class, ManagedUser.class)); - - assertEquals("INSERT INTO tc_device_geofence (deviceId, geofenceId) VALUES (:deviceId, :geofenceId)", - DataManager.constructPermissionQuery(DataManager.ACTION_INSERT, Device.class, Geofence.class)); - - assertEquals("DELETE FROM tc_group_attribute WHERE groupId = :groupId AND attributeId = :attributeId", - DataManager.constructPermissionQuery(DataManager.ACTION_DELETE, Group.class, Attribute.class)); - - } - -} diff --git a/src/test/java/org/traccar/forward/PositionForwarderUrlTest.java b/src/test/java/org/traccar/forward/PositionForwarderUrlTest.java new file mode 100644 index 000000000..522958052 --- /dev/null +++ b/src/test/java/org/traccar/forward/PositionForwarderUrlTest.java @@ -0,0 +1,42 @@ +package org.traccar.forward; + +import org.junit.Test; +import org.traccar.ProtocolTest; +import org.traccar.config.Config; +import org.traccar.config.Keys; +import org.traccar.model.Device; +import org.traccar.model.Position; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +public class PositionForwarderUrlTest extends ProtocolTest { + + @Test + public void testFormatRequest() throws Exception { + + Config config = new Config(); + config.setString(Keys.FORWARD_URL, "http://localhost/?fixTime={fixTime}&gprmc={gprmc}&name={name}"); + + Position position = position("2016-01-01 01:02:03.000", true, 20, 30); + + var device = mock(Device.class); + when(device.getId()).thenReturn(1L); + when(device.getName()).thenReturn("test"); + when(device.getUniqueId()).thenReturn("123456789012345"); + when(device.getStatus()).thenReturn(Device.STATUS_ONLINE); + + PositionData positionData = new PositionData(); + positionData.setPosition(position); + positionData.setDevice(device); + + PositionForwarderUrl forwarder = new PositionForwarderUrl(config, 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", + forwarder.formatRequest(positionData)); + + } + +} diff --git a/src/test/java/org/traccar/geocoder/GeocoderTest.java b/src/test/java/org/traccar/geocoder/GeocoderTest.java index 380980d2b..ff33b1f1c 100644 --- a/src/test/java/org/traccar/geocoder/GeocoderTest.java +++ b/src/test/java/org/traccar/geocoder/GeocoderTest.java @@ -1,10 +1,12 @@ package org.traccar.geocoder; -import java.util.Locale; - import org.junit.Ignore; import org.junit.Test; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; +import java.util.Locale; + import static org.junit.Assert.assertEquals; public class GeocoderTest { @@ -13,10 +15,12 @@ public class GeocoderTest { Locale.setDefault(Locale.US); } + private final Client client = ClientBuilder.newClient(); + @Ignore @Test public void testGoogle() { - Geocoder geocoder = new GoogleGeocoder(null, null, 0, new AddressFormat()); + Geocoder geocoder = new GoogleGeocoder(client, null, null, 0, new AddressFormat()); String address = geocoder.getAddress(31.776797, 35.211489, null); assertEquals("1 Ibn Shaprut St, Jerusalem, Jerusalem District, IL", address); } @@ -24,7 +28,7 @@ public class GeocoderTest { @Ignore @Test public void testNominatim() { - Geocoder geocoder = new NominatimGeocoder(null, null, null, 0, new AddressFormat()); + Geocoder geocoder = new NominatimGeocoder(client, null, null, null, 0, new AddressFormat()); String address = geocoder.getAddress(40.7337807, -73.9974401, null); assertEquals("35 West 9th Street, NYC, New York, US", address); } @@ -32,7 +36,7 @@ public class GeocoderTest { @Ignore @Test public void testGisgraphy() { - Geocoder geocoder = new GisgraphyGeocoder(null, 0, new AddressFormat()); + Geocoder geocoder = new GisgraphyGeocoder(client, null, 0, new AddressFormat()); String address = geocoder.getAddress(48.8530000, 2.3400000, null); assertEquals("Rue du Jardinet, Paris, ÃŽle-de-France, FR", address); } @@ -41,7 +45,7 @@ public class GeocoderTest { @Test public void testOpenCage() { Geocoder geocoder = new OpenCageGeocoder( - "http://api.opencagedata.com/geocode/v1", "SECRET", 0, new AddressFormat()); + client, "http://api.opencagedata.com/geocode/v1", "SECRET", null, 0, new AddressFormat()); String address = geocoder.getAddress(34.116302, -118.051519, null); assertEquals("Charleston Road, California, US", address); } @@ -49,7 +53,7 @@ public class GeocoderTest { @Ignore @Test public void testGeocodeFarm() { - Geocoder geocoder = new GeocodeFarmGeocoder(null, null, 0, new AddressFormat()); + Geocoder geocoder = new GeocodeFarmGeocoder(client, null, null, 0, new AddressFormat()); String address = geocoder.getAddress(34.116302, -118.051519, null); assertEquals("Estrella Avenue, Arcadia, California, United States", address); } @@ -57,7 +61,7 @@ public class GeocoderTest { @Ignore @Test public void testGeocodeXyz() { - Geocoder geocoder = new GeocodeXyzGeocoder(null, 0, new AddressFormat()); + Geocoder geocoder = new GeocodeXyzGeocoder(client, null, 0, new AddressFormat()); String address = geocoder.getAddress(34.116302, -118.051519, null); assertEquals("605 ESTRELLA AVE, ARCADIA, California United States of America, US", address); } @@ -65,7 +69,7 @@ public class GeocoderTest { @Ignore @Test public void testBan() { - Geocoder geocoder = new BanGeocoder(0, new AddressFormat("%f [%d], %c")); + Geocoder geocoder = new BanGeocoder(client, 0, new AddressFormat("%f [%d], %c")); String address = geocoder.getAddress(48.8575, 2.2944, null); assertEquals("8 Avenue Gustave Eiffel 75007 Paris [75, Paris, ÃŽle-de-France], FR", address); } @@ -73,7 +77,7 @@ public class GeocoderTest { @Ignore @Test public void testHere() { - Geocoder geocoder = new HereGeocoder(null, "", "", null, 0, new AddressFormat()); + Geocoder geocoder = new HereGeocoder(client, null, "", "", null, 0, new AddressFormat()); String address = geocoder.getAddress(48.8575, 2.2944, null); assertEquals("6 Avenue Gustave Eiffel, Paris, ÃŽle-de-France, FRA", address); } @@ -81,7 +85,7 @@ public class GeocoderTest { @Ignore @Test public void testMapmyIndia() { - Geocoder geocoder = new MapmyIndiaGeocoder("", "", 0, new AddressFormat("%f")); + Geocoder geocoder = new MapmyIndiaGeocoder(client, "", "", 0, new AddressFormat("%f")); String address = geocoder.getAddress(28.6129602407977, 77.2294557094574, null); assertEquals("New Delhi, Delhi. 1 m from India Gate pin-110001 (India)", address); } @@ -89,7 +93,7 @@ public class GeocoderTest { @Ignore @Test public void testPositionStack() { - Geocoder geocoder = new PositionStackGeocoder("", 0, new AddressFormat("%f")); + Geocoder geocoder = new PositionStackGeocoder(client, "", 0, new AddressFormat("%f")); String address = geocoder.getAddress(28.6129602407977, 77.2294557094574, null); assertEquals("India Gate, New Delhi, India", address); } @@ -97,7 +101,7 @@ public class GeocoderTest { @Ignore @Test public void testMapbox() { - Geocoder geocoder = new MapboxGeocoder("", 0, new AddressFormat("%f")); + Geocoder geocoder = new MapboxGeocoder(client, "", 0, new AddressFormat("%f")); String address = geocoder.getAddress(40.733, -73.989, null); assertEquals("120 East 13th Street, New York, New York 10003, United States", address); } @@ -105,9 +109,17 @@ public class GeocoderTest { @Ignore @Test public void testMapTiler() { - Geocoder geocoder = new MapTilerGeocoder("mnbnwLErpdspq13f0kC6", 0, new AddressFormat()); + Geocoder geocoder = new MapTilerGeocoder(client, "", 0, new AddressFormat()); String address = geocoder.getAddress(40.733, -73.989, null); assertEquals("East 13th Street, New York City, New York, United States", address); } + @Ignore + @Test + public void testGeoapify() { + Geocoder geocoder = new GeoapifyGeocoder(client, "", null, 0, new AddressFormat()); + String address = geocoder.getAddress(40.733, -73.989, null); + assertEquals("114 East 13th Street, New York, New York, US", address); + } + } diff --git a/src/test/java/org/traccar/geofence/GeofenceCircleTest.java b/src/test/java/org/traccar/geofence/GeofenceCircleTest.java index 259a8fb77..9a02cec76 100644 --- a/src/test/java/org/traccar/geofence/GeofenceCircleTest.java +++ b/src/test/java/org/traccar/geofence/GeofenceCircleTest.java @@ -1,10 +1,11 @@ package org.traccar.geofence; -import java.text.ParseException; - import org.junit.Test; +import java.text.ParseException; + import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; public class GeofenceCircleTest { @@ -12,17 +13,15 @@ public class GeofenceCircleTest { @Test public void testCircleWkt() throws ParseException { String test = "CIRCLE (55.75414 37.6204, 100)"; - GeofenceGeometry geofenceGeometry = new GeofenceCircle(); - geofenceGeometry.fromWkt(test); + GeofenceGeometry geofenceGeometry = new GeofenceCircle(test); assertEquals(geofenceGeometry.toWkt(), test); } @Test public void testContainsCircle() throws ParseException { - String test = "CIRCLE (55.75414 37.6204, 100)"; - GeofenceGeometry geofenceGeometry = new GeofenceCircle(); - geofenceGeometry.fromWkt(test); - assertTrue(geofenceGeometry.containsPoint(55.75477, 37.62025)); - assertTrue(!geofenceGeometry.containsPoint(55.75545, 37.61921)); + GeofenceGeometry geofenceGeometry = new GeofenceCircle("CIRCLE (55.75414 37.6204, 100)"); + assertTrue(geofenceGeometry.containsPoint(null, null, 55.75477, 37.62025)); + assertFalse(geofenceGeometry.containsPoint(null, null, 55.75545, 37.61921)); } + } diff --git a/src/test/java/org/traccar/geofence/GeofencePolygonTest.java b/src/test/java/org/traccar/geofence/GeofencePolygonTest.java index cc9c46c94..5baecd771 100644 --- a/src/test/java/org/traccar/geofence/GeofencePolygonTest.java +++ b/src/test/java/org/traccar/geofence/GeofencePolygonTest.java @@ -1,9 +1,9 @@ package org.traccar.geofence; -import java.text.ParseException; - import org.junit.Test; +import java.text.ParseException; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -19,41 +19,34 @@ public class GeofencePolygonTest { @Test public void testPolygonWkt() throws ParseException { String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; - GeofenceGeometry geofenceGeometry = new GeofencePolygon(); - geofenceGeometry.fromWkt(test); + GeofenceGeometry geofenceGeometry = new GeofencePolygon(test); assertEquals(geofenceGeometry.toWkt(), test); } @Test public void testContainsPolygon() throws ParseException { - String test = "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"; - GeofenceGeometry geofenceGeometry = new GeofencePolygon(); - geofenceGeometry.fromWkt(test); - assertTrue(geofenceGeometry.containsPoint(55.75476, 37.61915)); - assertFalse(geofenceGeometry.containsPoint(55.75545, 37.61921)); - + GeofenceGeometry geofenceGeometry = new GeofencePolygon( + "POLYGON ((55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165))"); + assertTrue(geofenceGeometry.containsPoint(null, null, 55.75476, 37.61915)); + assertFalse(geofenceGeometry.containsPoint(null, null, 55.75545, 37.61921)); } @Test public void testContainsPolygon180() throws ParseException { - String test = "POLYGON ((66.9494 179.838, 66.9508 -179.8496, 66.8406 -180.0014))"; - GeofenceGeometry geofenceGeometry = new GeofencePolygon(); - geofenceGeometry.fromWkt(test); - assertTrue(geofenceGeometry.containsPoint(66.9015, -180.0096)); - assertTrue(geofenceGeometry.containsPoint(66.9015, 179.991)); - assertFalse(geofenceGeometry.containsPoint(66.8368, -179.8792)); - + GeofenceGeometry geofenceGeometry = new GeofencePolygon( + "POLYGON ((66.9494 179.838, 66.9508 -179.8496, 66.8406 -180.0014))"); + assertTrue(geofenceGeometry.containsPoint(null, null, 66.9015, -180.0096)); + assertTrue(geofenceGeometry.containsPoint(null, null, 66.9015, 179.991)); + assertFalse(geofenceGeometry.containsPoint(null, null, 66.8368, -179.8792)); } @Test public void testContainsPolygon0() throws ParseException { - String test = "POLYGON ((51.1966 -0.6207, 51.1897 0.4147, 50.9377 0.5136, 50.8675 -0.6082))"; - GeofenceGeometry geofenceGeometry = new GeofencePolygon(); - geofenceGeometry.fromWkt(test); - assertTrue(geofenceGeometry.containsPoint(51.0466, -0.0165)); - assertTrue(geofenceGeometry.containsPoint(51.0466, 0.018)); - assertFalse(geofenceGeometry.containsPoint(50.9477, 0.5836)); - + GeofenceGeometry geofenceGeometry = new GeofencePolygon( + "POLYGON ((51.1966 -0.6207, 51.1897 0.4147, 50.9377 0.5136, 50.8675 -0.6082))"); + assertTrue(geofenceGeometry.containsPoint(null, null, 51.0466, -0.0165)); + assertTrue(geofenceGeometry.containsPoint(null, null, 51.0466, 0.018)); + assertFalse(geofenceGeometry.containsPoint(null, null, 50.9477, 0.5836)); } } diff --git a/src/test/java/org/traccar/geofence/GeofencePolylineTest.java b/src/test/java/org/traccar/geofence/GeofencePolylineTest.java index 1e9dcb7c3..b7ee14510 100644 --- a/src/test/java/org/traccar/geofence/GeofencePolylineTest.java +++ b/src/test/java/org/traccar/geofence/GeofencePolylineTest.java @@ -1,47 +1,59 @@ package org.traccar.geofence; -import java.text.ParseException; - import org.junit.Test; +import org.traccar.config.Config; +import org.traccar.config.Keys; +import org.traccar.model.Geofence; + +import java.text.ParseException; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class GeofencePolylineTest { @Test public void testPolylineWkt() throws ParseException { String test = "LINESTRING (55.75474 37.61823, 55.75513 37.61888, 55.7535 37.6222, 55.75315 37.62165)"; - GeofenceGeometry geofenceGeometry = new GeofencePolyline(); - geofenceGeometry.fromWkt(test); + GeofenceGeometry geofenceGeometry = new GeofencePolyline(test); assertEquals(geofenceGeometry.toWkt(), test); } @Test public void testContainsPolyline1Interval() throws ParseException { - String test = "LINESTRING (56.83777 60.59833, 56.83766 60.5968)"; - GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 35); - assertTrue(geofenceGeometry.containsPoint(56.83801, 60.59748)); - ((GeofencePolyline) geofenceGeometry).setDistance(15); - assertTrue(!geofenceGeometry.containsPoint(56.83801, 60.59748)); + GeofenceGeometry geofenceGeometry = new GeofencePolyline( + "LINESTRING (56.83777 60.59833, 56.83766 60.5968)"); + Config config = mock(Config.class); + when(config.getDouble(Keys.GEOFENCE_POLYLINE_DISTANCE)).thenReturn(35.0); + assertTrue(geofenceGeometry.containsPoint(config, mock(Geofence.class), 56.83801, 60.59748)); + when(config.getDouble(Keys.GEOFENCE_POLYLINE_DISTANCE)).thenReturn(15.0); + assertFalse(geofenceGeometry.containsPoint(config, mock(Geofence.class), 56.83801, 60.59748)); } @Test public void testContainsPolyline3Intervals() throws ParseException { - String test = "LINESTRING (56.836 60.6126, 56.8393 60.6114, 56.83887 60.60811, 56.83782 60.5988)"; - GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 15); - assertTrue(geofenceGeometry.containsPoint(56.83847, 60.60458)); - assertTrue(!geofenceGeometry.containsPoint(56.83764, 60.59725)); - assertTrue(!geofenceGeometry.containsPoint(56.83861, 60.60822)); + GeofenceGeometry geofenceGeometry = new GeofencePolyline( + "LINESTRING (56.836 60.6126, 56.8393 60.6114, 56.83887 60.60811, 56.83782 60.5988)"); + Config config = mock(Config.class); + when(config.getDouble(Keys.GEOFENCE_POLYLINE_DISTANCE)).thenReturn(15.0); + assertTrue(geofenceGeometry.containsPoint(config, mock(Geofence.class), 56.83847, 60.60458)); + assertFalse(geofenceGeometry.containsPoint(config, mock(Geofence.class), 56.83764, 60.59725)); + assertFalse(geofenceGeometry.containsPoint(config, mock(Geofence.class), 56.83861, 60.60822)); } @Test public void testContainsPolylineNear180() throws ParseException { - String test = "LINESTRING (66.9494 179.838, 66.9508 -179.8496)"; - GeofenceGeometry geofenceGeometry = new GeofencePolyline(test, 25); - assertTrue(geofenceGeometry.containsPoint(66.95, 180.0)); - assertTrue(!geofenceGeometry.containsPoint(66.96, 180.0)); - assertTrue(!geofenceGeometry.containsPoint(66.9509, -179.83)); + GeofenceGeometry geofenceGeometry = new GeofencePolyline( + "LINESTRING (66.9494 179.838, 66.9508 -179.8496)"); + Config config = mock(Config.class); + when(config.getDouble(Keys.GEOFENCE_POLYLINE_DISTANCE)).thenReturn(25.0); + assertTrue(geofenceGeometry.containsPoint(config, mock(Geofence.class), 66.95, 180.0)); + assertFalse(geofenceGeometry.containsPoint(config, mock(Geofence.class), 66.96, 180.0)); + assertFalse(geofenceGeometry.containsPoint(config, mock(Geofence.class), 66.9509, -179.83)); } + } diff --git a/src/test/java/org/traccar/geolocation/GeolocationProviderTest.java b/src/test/java/org/traccar/geolocation/GeolocationProviderTest.java index 2729052d6..876b6b688 100644 --- a/src/test/java/org/traccar/geolocation/GeolocationProviderTest.java +++ b/src/test/java/org/traccar/geolocation/GeolocationProviderTest.java @@ -6,19 +6,20 @@ import org.traccar.BaseTest; import org.traccar.model.CellTower; import org.traccar.model.Network; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class GeolocationProviderTest extends BaseTest { + private final Client client = ClientBuilder.newClient(); + @Ignore @Test - public void test() throws Exception { - testLocationProvider(); - } - - public void testLocationProvider() throws Exception { - MozillaGeolocationProvider provider = new MozillaGeolocationProvider(null); + public void testMozilla() throws Exception { + MozillaGeolocationProvider provider = new MozillaGeolocationProvider(client, null); Network network = new Network(CellTower.from(208, 1, 2, 1234567)); diff --git a/src/test/java/org/traccar/handler/ComputedAttributesTest.java b/src/test/java/org/traccar/handler/ComputedAttributesTest.java index a76d8169b..2668c4f14 100644 --- a/src/test/java/org/traccar/handler/ComputedAttributesTest.java +++ b/src/test/java/org/traccar/handler/ComputedAttributesTest.java @@ -1,12 +1,12 @@ 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; +import java.util.Date; + import static org.junit.Assert.assertEquals; public class ComputedAttributesTest { @@ -14,7 +14,7 @@ public class ComputedAttributesTest { @Test public void testComputedAttributes() { - ComputedAttributesHandler handler = new ComputedAttributesHandler(new Config(), null, null); + ComputedAttributesHandler handler = new ComputedAttributesHandler(new Config(), null); Date date = new Date(); Position position = new Position(); diff --git a/src/test/java/org/traccar/handler/DistanceHandlerTest.java b/src/test/java/org/traccar/handler/DistanceHandlerTest.java index f7c6e42cd..a18b14edd 100644 --- a/src/test/java/org/traccar/handler/DistanceHandlerTest.java +++ b/src/test/java/org/traccar/handler/DistanceHandlerTest.java @@ -3,15 +3,17 @@ package org.traccar.handler; import org.junit.Test; import org.traccar.config.Config; import org.traccar.model.Position; +import org.traccar.session.cache.CacheManager; import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; public class DistanceHandlerTest { @Test public void testCalculateDistance() { - DistanceHandler distanceHandler = new DistanceHandler(new Config(), null); + DistanceHandler distanceHandler = new DistanceHandler(new Config(), mock(CacheManager.class)); Position position = distanceHandler.handlePosition(new Position()); diff --git a/src/test/java/org/traccar/handler/FilterHandlerTest.java b/src/test/java/org/traccar/handler/FilterHandlerTest.java index ad8d244a6..a1102da88 100644 --- a/src/test/java/org/traccar/handler/FilterHandlerTest.java +++ b/src/test/java/org/traccar/handler/FilterHandlerTest.java @@ -5,70 +5,81 @@ import org.junit.Test; import org.traccar.BaseTest; import org.traccar.config.Config; import org.traccar.config.Keys; +import org.traccar.model.Device; import org.traccar.model.Position; +import org.traccar.session.cache.CacheManager; import java.util.Date; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class FilterHandlerTest extends BaseTest { - private FilterHandler passingHandler = new FilterHandler(new Config()); + private FilterHandler passingHandler; 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); + public void passingHandler() { + var config = mock(Config.class); + when(config.getBoolean(Keys.FILTER_ENABLE)).thenReturn(true); + var cacheManager = mock(CacheManager.class); + when(cacheManager.getConfig()).thenReturn(config); + passingHandler = new FilterHandler(config, cacheManager, null); } - private Position createPosition( - long deviceId, - Date time, - boolean valid, - double latitude, - double longitude, - double altitude, - double speed, - double course) { + @Before + public void filteringHandler() { + var config = mock(Config.class); + when(config.getBoolean(Keys.FILTER_ENABLE)).thenReturn(true); + when(config.getBoolean(Keys.FILTER_INVALID)).thenReturn(true); + when(config.getBoolean(Keys.FILTER_ZERO)).thenReturn(true); + when(config.getBoolean(Keys.FILTER_DUPLICATE)).thenReturn(true); + when(config.getLong(Keys.FILTER_FUTURE)).thenReturn(5 * 60L); + when(config.getBoolean(Keys.FILTER_APPROXIMATE)).thenReturn(true); + when(config.getBoolean(Keys.FILTER_STATIC)).thenReturn(true); + when(config.getInteger(Keys.FILTER_DISTANCE)).thenReturn(10); + when(config.getInteger(Keys.FILTER_MAX_SPEED)).thenReturn(500); + when(config.getLong(Keys.FILTER_SKIP_LIMIT)).thenReturn(10L); + when(config.getBoolean(Keys.FILTER_SKIP_ATTRIBUTES_ENABLE)).thenReturn(true); + when(config.getString(Keys.FILTER_SKIP_ATTRIBUTES.getKey())).thenReturn("alarm,result"); + var cacheManager = mock(CacheManager.class); + when(cacheManager.getConfig()).thenReturn(config); + when(cacheManager.getObject(any(), anyLong())).thenReturn(mock(Device.class)); + filteringHandler = new FilterHandler(config, cacheManager, null); + } + private Position createPosition(Date time, boolean valid, double speed) { Position position = new Position(); - position.setDeviceId(deviceId); + position.setDeviceId(0); position.setTime(time); position.setValid(valid); - position.setLatitude(latitude); - position.setLongitude(longitude); - position.setAltitude(altitude); + position.setLatitude(10); + position.setLongitude(10); + position.setAltitude(10); position.setSpeed(speed); - position.setCourse(course); + position.setCourse(10); return position; } @Test public void testFilter() { - Position position = createPosition(0, new Date(), true, 10, 10, 10, 10, 10); + Position position = createPosition(new Date(), true, 10); assertNotNull(filteringHandler.handlePosition(position)); assertNotNull(passingHandler.handlePosition(position)); - position = createPosition(0, new Date(Long.MAX_VALUE), true, 10, 10, 10, 10, 10); + position = createPosition(new Date(Long.MAX_VALUE), true, 10); assertNull(filteringHandler.handlePosition(position)); assertNotNull(passingHandler.handlePosition(position)); - position = createPosition(0, new Date(), false, 10, 10, 10, 10, 10); + position = createPosition(new Date(), false, 10); assertNull(filteringHandler.handlePosition(position)); assertNotNull(passingHandler.handlePosition(position)); @@ -78,7 +89,7 @@ public class FilterHandlerTest extends BaseTest { @Test public void testSkipAttributes() { - Position position = createPosition(0, new Date(), true, 10, 10, 10, 0, 10); + Position position = createPosition(new Date(), true, 0); position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); assertNotNull(filteringHandler.handlePosition(position)); diff --git a/src/test/java/org/traccar/handler/MotionHandlerTest.java b/src/test/java/org/traccar/handler/MotionHandlerTest.java index 9e0859664..93fd16206 100644 --- a/src/test/java/org/traccar/handler/MotionHandlerTest.java +++ b/src/test/java/org/traccar/handler/MotionHandlerTest.java @@ -1,16 +1,22 @@ package org.traccar.handler; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.traccar.model.Position; +import org.traccar.reports.common.TripsConfig; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class MotionHandlerTest { @Test public void testCalculateMotion() { - MotionHandler motionHandler = new MotionHandler(0.01); + TripsConfig tripsConfig = mock(TripsConfig.class); + when(tripsConfig.getSpeedThreshold()).thenReturn(0.01); + + MotionHandler motionHandler = new MotionHandler(tripsConfig); Position position = motionHandler.handlePosition(new Position()); diff --git a/src/test/java/org/traccar/handler/events/AlertEventHandlerTest.java b/src/test/java/org/traccar/handler/events/AlertEventHandlerTest.java index 3f0823245..550a93da3 100644 --- a/src/test/java/org/traccar/handler/events/AlertEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/AlertEventHandlerTest.java @@ -1,23 +1,24 @@ package org.traccar.handler.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -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; +import org.traccar.session.cache.CacheManager; + +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.mockito.Mockito.mock; public class AlertEventHandlerTest extends BaseTest { @Test public void testAlertEventHandler() { - AlertEventHandler alertEventHandler = new AlertEventHandler(new Config(), new TestIdentityManager()); + AlertEventHandler alertEventHandler = new AlertEventHandler(new Config(), mock(CacheManager.class)); Position position = new Position(); position.set(Position.KEY_ALARM, Position.ALARM_GENERAL); @@ -25,6 +26,7 @@ public class AlertEventHandlerTest extends BaseTest { assertNotNull(events); Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_ALARM, event.getType()); + } } diff --git a/src/test/java/org/traccar/handler/events/CommandResultEventHandlerTest.java b/src/test/java/org/traccar/handler/events/CommandResultEventHandlerTest.java index 0ccf9f6b4..4997a0e0f 100644 --- a/src/test/java/org/traccar/handler/events/CommandResultEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/CommandResultEventHandlerTest.java @@ -1,15 +1,15 @@ package org.traccar.handler.events; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -import java.util.Map; - import org.junit.Test; import org.traccar.BaseTest; import org.traccar.model.Event; import org.traccar.model.Position; +import java.util.Map; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + public class CommandResultEventHandlerTest extends BaseTest { @Test diff --git a/src/test/java/org/traccar/handler/events/IgnitionEventHandlerTest.java b/src/test/java/org/traccar/handler/events/IgnitionEventHandlerTest.java index dade20fb8..84898bea0 100644 --- a/src/test/java/org/traccar/handler/events/IgnitionEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/IgnitionEventHandlerTest.java @@ -1,21 +1,22 @@ package org.traccar.handler.events; -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; +import org.traccar.session.cache.CacheManager; + +import java.util.Map; + +import static org.junit.Assert.assertNull; +import static org.mockito.Mockito.mock; public class IgnitionEventHandlerTest extends BaseTest { @Test public void testIgnitionEventHandler() { - IgnitionEventHandler ignitionEventHandler = new IgnitionEventHandler(new TestIdentityManager()); + IgnitionEventHandler ignitionEventHandler = new IgnitionEventHandler(mock(CacheManager.class)); Position position = new Position(); position.set(Position.KEY_IGNITION, true); diff --git a/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java b/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java new file mode 100644 index 000000000..aa2d0bbe3 --- /dev/null +++ b/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java @@ -0,0 +1,60 @@ +package org.traccar.handler.events; + +import org.junit.Test; +import org.traccar.BaseTest; +import org.traccar.model.Maintenance; +import org.traccar.model.Position; +import org.traccar.session.cache.CacheManager; + +import java.util.Arrays; +import java.util.Date; + +import static org.junit.Assert.assertTrue; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.anyLong; + +public class MaintenanceEventHandlerTest extends BaseTest { + + @Test + public void testMaintenanceEventHandler() { + Position lastPosition = new Position(); + lastPosition.setDeviceId(1); + lastPosition.setFixTime(new Date(0)); + + Position position = new Position(); + position.setDeviceId(1); + position.setFixTime(new Date(0)); + + var maintenance = mock(Maintenance.class); + when(maintenance.getType()).thenReturn(Position.KEY_TOTAL_DISTANCE); + var maintenances = Arrays.asList(maintenance); + + var cacheManager = mock(CacheManager.class); + when(cacheManager.getDeviceObjects(anyLong(), eq(Maintenance.class))).thenReturn(maintenances); + when(cacheManager.getPosition(anyLong())).thenReturn(lastPosition); + MaintenanceEventHandler eventHandler = new MaintenanceEventHandler(cacheManager); + + when(maintenance.getStart()).thenReturn(10000.0); + when(maintenance.getPeriod()).thenReturn(2000.0); + + lastPosition.set(Position.KEY_TOTAL_DISTANCE, 1999); + position.set(Position.KEY_TOTAL_DISTANCE, 2001); + assertTrue(eventHandler.analyzePosition(position).isEmpty()); + + lastPosition.set(Position.KEY_TOTAL_DISTANCE, 3999); + position.set(Position.KEY_TOTAL_DISTANCE, 4001); + assertTrue(eventHandler.analyzePosition(position).isEmpty()); + + lastPosition.set(Position.KEY_TOTAL_DISTANCE, 9999); + position.set(Position.KEY_TOTAL_DISTANCE, 10001); + assertTrue(eventHandler.analyzePosition(position).size() == 1); + + lastPosition.set(Position.KEY_TOTAL_DISTANCE, 11999); + position.set(Position.KEY_TOTAL_DISTANCE, 12001); + assertTrue(eventHandler.analyzePosition(position).size() == 1); + + } + +} diff --git a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java index f57c16635..b77676dc8 100644 --- a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java @@ -1,119 +1,112 @@ package org.traccar.handler.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; +import org.junit.Test; +import org.traccar.BaseTest; +import org.traccar.model.Event; +import org.traccar.model.Position; +import org.traccar.reports.common.TripsConfig; +import org.traccar.session.state.MotionProcessor; +import org.traccar.session.state.MotionState; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; import java.util.TimeZone; -import org.junit.Test; -import org.traccar.BaseTest; -import org.traccar.model.DeviceState; -import org.traccar.model.Event; -import org.traccar.model.Position; -import org.traccar.reports.model.TripsConfig; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; public class MotionEventHandlerTest extends BaseTest { - private Date date(String time) throws ParseException { + private Position position(String time, boolean motion, double distance, Boolean ignition) throws ParseException { + Position position = new Position(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - return dateFormat.parse(time); + position.setTime(dateFormat.parse(time)); + position.set(Position.KEY_MOTION, motion); + position.set(Position.KEY_TOTAL_DISTANCE, distance); + position.set(Position.KEY_IGNITION, ignition); + return position; + } + + private void verifyState(MotionState motionState, boolean state, long distance) { + assertEquals(state, motionState.getMotionState()); + assertEquals(distance, motionState.getMotionDistance(), 0.1); } @Test - public void testMotionWithPosition() throws Exception { - MotionEventHandler motionEventHandler = new MotionEventHandler( - null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01)); + public void testMotionWithPosition() throws ParseException { + TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false, 0.01); - Position position = new Position(); - position.setTime(date("2017-01-01 00:00:00")); - position.set(Position.KEY_MOTION, true); - position.set(Position.KEY_TOTAL_DISTANCE, 0); - DeviceState deviceState = new DeviceState(); - deviceState.setMotionState(false); - deviceState.setMotionPosition(position); - Position nextPosition = new Position(); - - nextPosition.setTime(date("2017-01-01 00:02:00")); - nextPosition.set(Position.KEY_MOTION, true); - nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - - Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNull(events); - - nextPosition.set(Position.KEY_TOTAL_DISTANCE, 600); - events = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNotNull(events); - Event event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); - assertTrue(deviceState.getMotionState()); - assertNull(deviceState.getMotionPosition()); - - deviceState.setMotionState(false); - deviceState.setMotionPosition(position); - nextPosition.setTime(date("2017-01-01 00:06:00")); - nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - events = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNotNull(event); - event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); - assertTrue(deviceState.getMotionState()); - assertNull(deviceState.getMotionPosition()); + MotionState state = new MotionState(); + + MotionProcessor.updateState(state, position("2017-01-01 00:00:00", false, 0, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 100, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 100); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 700, null), true, tripsConfig); + assertEquals(Event.TYPE_DEVICE_MOVING, state.getEvent().getType()); + verifyState(state, true, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:03:00", false, 700, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 700); + + MotionProcessor.updateState(state, position("2017-01-01 00:10:00", false, 700, null), false, tripsConfig); + assertEquals(Event.TYPE_DEVICE_STOPPED, state.getEvent().getType()); + verifyState(state, false, 0); } @Test - public void testMotionWithStatus() throws Exception { - MotionEventHandler motionEventHandler = new MotionEventHandler( - null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, false, false, 0.01)); + public void testMotionFluctuation() throws ParseException { + TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false, 0.01); - 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); - - Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState); - - assertNotNull(events); - Event event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); - assertTrue(deviceState.getMotionState()); - assertNull(deviceState.getMotionPosition()); + MotionState state = new MotionState(); + + MotionProcessor.updateState(state, position("2017-01-01 00:00:00", false, 0, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 100, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 100); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 700, null), true, tripsConfig); + assertEquals(Event.TYPE_DEVICE_MOVING, state.getEvent().getType()); + verifyState(state, true, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:03:00", false, 700, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 700); + + MotionProcessor.updateState(state, position("2017-01-01 00:04:00", true, 1000, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:06:00", true, 2000, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 0); } @Test - public void testStopWithPositionIgnition() throws Exception { - MotionEventHandler motionEventHandler = new MotionEventHandler( - null, null, new TripsConfig(500, 300 * 1000, 300 * 1000, 0, true, false, 0.01)); + public void testStopWithPositionIgnition() throws ParseException { + TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, true, false, 0.01); - 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); - - Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNotNull(events); - Event event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_STOPPED, event.getType()); - assertFalse(deviceState.getMotionState()); - assertNull(deviceState.getMotionPosition()); + MotionState state = new MotionState(); + state.setMotionStreak(true); + state.setMotionState(true); + + MotionProcessor.updateState(state, position("2017-01-01 00:00:00", false, 100, true), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 100); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", false, 100, false), false, tripsConfig); + assertEquals(Event.TYPE_DEVICE_STOPPED, state.getEvent().getType()); + verifyState(state, false, 0); } } diff --git a/src/test/java/org/traccar/handler/events/OverspeedEventHandlerTest.java b/src/test/java/org/traccar/handler/events/OverspeedEventHandlerTest.java index 515f37b5d..ee18ee052 100644 --- a/src/test/java/org/traccar/handler/events/OverspeedEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/OverspeedEventHandlerTest.java @@ -1,128 +1,68 @@ package org.traccar.handler.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 org.junit.Test; +import org.traccar.BaseTest; +import org.traccar.model.Event; +import org.traccar.model.Position; +import org.traccar.session.state.OverspeedProcessor; +import org.traccar.session.state.OverspeedState; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; 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; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; public class OverspeedEventHandlerTest extends BaseTest { - private Date date(String time) throws ParseException { + private Position position(String time, double speed) throws ParseException { + Position position = new Position(); DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); - return dateFormat.parse(time); + position.setTime(dateFormat.parse(time)); + position.setSpeed(speed); + return position; } - 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")); - position.setSpeed(50); - DeviceState deviceState = new DeviceState(); - deviceState.setOverspeedState(false); - - Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, position, 40, geofenceId); - assertNull(events); - assertFalse(deviceState.getOverspeedState()); - assertEquals(position, deviceState.getOverspeedPosition()); - assertEquals(geofenceId, deviceState.getOverspeedGeofenceId()); - - Position nextPosition = new Position(); - nextPosition.setTime(date("2017-01-01 00:00:10")); - nextPosition.setSpeed(55); - - events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, geofenceId); - assertNull(events); - - nextPosition.setTime(date("2017-01-01 00:00:20")); - - events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, geofenceId); - assertNotNull(events); - Event event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); - assertEquals(50, event.getDouble("speed"), 0.1); - assertEquals(40, event.getDouble(OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT), 0.1); - assertEquals(geofenceId, event.getGeofenceId()); - - assertEquals(notRepeat, deviceState.getOverspeedState()); - assertNull(deviceState.getOverspeedPosition()); - assertEquals(0, deviceState.getOverspeedGeofenceId()); + private void verifyState(OverspeedState overspeedState, boolean state, long geofenceId) { + assertEquals(state, overspeedState.getOverspeedState()); + assertEquals(geofenceId, overspeedState.getOverspeedGeofenceId()); + } - nextPosition.setTime(date("2017-01-01 00:00:30")); - events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, geofenceId); - assertNull(events); - assertEquals(notRepeat, deviceState.getOverspeedState()); + private void testOverspeedWithPosition(long geofenceId) throws ParseException { + OverspeedState state = new OverspeedState(); - if (notRepeat) { - assertNull(deviceState.getOverspeedPosition()); - assertEquals(0, deviceState.getOverspeedGeofenceId()); - } else { - assertNotNull(deviceState.getOverspeedPosition()); - assertEquals(geofenceId, deviceState.getOverspeedGeofenceId()); - } + OverspeedProcessor.updateState(state, position("2017-01-01 00:00:00", 50), 40, 15000, geofenceId); + assertNull(state.getEvent()); + verifyState(state, true, geofenceId); - nextPosition.setTime(date("2017-01-01 00:00:40")); - nextPosition.setSpeed(30); + OverspeedProcessor.updateState(state, position("2017-01-01 00:00:10", 55), 40, 15000, geofenceId); + assertNull(state.getEvent()); - events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40, geofenceId); - assertNull(events); - assertFalse(deviceState.getOverspeedState()); - assertNull(deviceState.getOverspeedPosition()); - assertEquals(0, deviceState.getOverspeedGeofenceId()); - } + OverspeedProcessor.updateState(state, position("2017-01-01 00:00:20", 55), 40, 15000, geofenceId); + assertNotNull(state.getEvent()); + assertEquals(Event.TYPE_DEVICE_OVERSPEED, state.getEvent().getType()); + assertEquals(55, state.getEvent().getDouble("speed"), 0.1); + assertEquals(40, state.getEvent().getDouble("speedLimit"), 0.1); + assertEquals(geofenceId, state.getEvent().getGeofenceId()); + verifyState(state, true, 0); - 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); + OverspeedProcessor.updateState(state, position("2017-01-01 00:00:30", 55), 40, 15000, geofenceId); + assertNull(state.getEvent()); + verifyState(state, true, 0); - Position position = new Position(); - position.setTime(new Date(System.currentTimeMillis() - 30000)); - position.setSpeed(50); - DeviceState deviceState = new DeviceState(); - deviceState.setOverspeedState(false); - deviceState.setOverspeedPosition(position); - - Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, 40); - - assertNotNull(events); - Event event = events.keySet().iterator().next(); - assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); - assertEquals(notRepeat, deviceState.getOverspeedState()); + OverspeedProcessor.updateState(state, position("2017-01-01 00:00:30", 30), 40, 15000, geofenceId); + assertNull(state.getEvent()); + verifyState(state, false, 0); } @Test public void testOverspeedEventHandler() throws Exception { - testOverspeedWithPosition(false, 0); - testOverspeedWithPosition(true, 0); - - testOverspeedWithPosition(false, 1); - testOverspeedWithPosition(true, 1); - - testOverspeedWithStatus(false); - testOverspeedWithStatus(true); + testOverspeedWithPosition(0); + testOverspeedWithPosition(1); } } diff --git a/src/test/java/org/traccar/helper/BufferUtilTest.java b/src/test/java/org/traccar/helper/BufferUtilTest.java new file mode 100644 index 000000000..0196cef9d --- /dev/null +++ b/src/test/java/org/traccar/helper/BufferUtilTest.java @@ -0,0 +1,41 @@ +package org.traccar.helper; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.junit.Test; + +import java.nio.charset.StandardCharsets; + +import static org.junit.Assert.assertEquals; + +public class BufferUtilTest { + + @Test + public void testReadSignedMagnitudeInt() { + ByteBuf buf = Unpooled.wrappedBuffer(DataConverter.parseHex("80000001")); + assertEquals(-1, BufferUtil.readSignedMagnitudeInt(buf)); + } + + @Test + public void test1() { + ByteBuf buf = Unpooled.copiedBuffer("abcdef", StandardCharsets.US_ASCII); + assertEquals(2, BufferUtil.indexOf("cd", buf)); + } + + @Test + public void test2() { + ByteBuf buf = Unpooled.copiedBuffer("abcdef", StandardCharsets.US_ASCII); + buf.readerIndex(1); + buf.writerIndex(5); + assertEquals(2, BufferUtil.indexOf("cd", buf)); + } + + @Test + public void test3() { + ByteBuf buf = Unpooled.copiedBuffer("abcdefgh", StandardCharsets.US_ASCII); + buf.readerIndex(1); + buf.writerIndex(7); + assertEquals(3, BufferUtil.indexOf("de", buf, 2, 6)); + } + +} diff --git a/src/test/java/org/traccar/protocol/AdmFrameDecoderTest.java b/src/test/java/org/traccar/protocol/AdmFrameDecoderTest.java index 1682ca56d..02d42447e 100644 --- a/src/test/java/org/traccar/protocol/AdmFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AdmFrameDecoderTest.java @@ -8,7 +8,7 @@ public class AdmFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AdmFrameDecoder(); + var decoder = inject(new AdmFrameDecoder()); verifyFrame( binary("38363931353330343235323337383400003728e000001402441d5f42c3711642930d000000c7000a461954f25fd82ed508000000000000000044000000010000000000140000"), diff --git a/src/test/java/org/traccar/protocol/AdmProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AdmProtocolDecoderTest.java index 7c8769925..810d53bf7 100644 --- a/src/test/java/org/traccar/protocol/AdmProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AdmProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AdmProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AdmProtocolDecoder(null); + var decoder = inject(new AdmProtocolDecoder(null)); verifyPosition(decoder, binary( "38363931353330343235323337383400003728e000001402441d5f42c3711642930d000000c7000a461954f25fd82ed508000000000000000044000000010000000000140000")); diff --git a/src/test/java/org/traccar/protocol/AdmProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/AdmProtocolEncoderTest.java index 89ddef849..79f37c4e4 100644 --- a/src/test/java/org/traccar/protocol/AdmProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/AdmProtocolEncoderTest.java @@ -27,7 +27,7 @@ public class AdmProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new AdmProtocolEncoder(null); + var encoder = inject(new AdmProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/AisProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AisProtocolDecoderTest.java index f869ab8f3..36ea3d361 100644 --- a/src/test/java/org/traccar/protocol/AisProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AisProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AisProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AisProtocolDecoder(null); + var decoder = inject(new AisProtocolDecoder(null)); verifyPositions(decoder, text( "!AIVDM,2,1,8,A,53UlSb01l>Ei=H4KF218PTpv222222222222221?8h=766gB0<Ck11DTp888,0*14s:MTb827ebc7686b,c:1481688227737*4d\\\r\n" + diff --git a/src/test/java/org/traccar/protocol/AlematicsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AlematicsProtocolDecoderTest.java index 8bd457a97..585e02c02 100644 --- a/src/test/java/org/traccar/protocol/AlematicsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AlematicsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AlematicsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AlematicsProtocolDecoder(null); + var decoder = inject(new AlematicsProtocolDecoder(null)); verifyPosition(decoder, text( "$T,2,64,866050035975497,20180726103446,20180726103514,23.033305,72.558032,0,0,41,5.4,4,0,0,0.000,12.960,0,")); diff --git a/src/test/java/org/traccar/protocol/AnytrekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AnytrekProtocolDecoderTest.java index b6f95513c..5e0923e9c 100644 --- a/src/test/java/org/traccar/protocol/AnytrekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AnytrekProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AnytrekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AnytrekProtocolDecoder(null); + var decoder = inject(new AnytrekProtocolDecoder(null)); verifyPosition(decoder, binary( "78783500300086428703204121160085015111050C0A0D20C6FD24A102FF8EAC0C01001404000000FFFFFFFF131702210000000000000000000D0A")); diff --git a/src/test/java/org/traccar/protocol/ApelProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ApelProtocolDecoderTest.java index b922d3ef1..369c13115 100644 --- a/src/test/java/org/traccar/protocol/ApelProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ApelProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ApelProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ApelProtocolDecoder(null); + var decoder = inject(new ApelProtocolDecoder(null)); /*byte[] buf1 = {0x40,0x4E,0x54,0x43,0x01,0x00,0x00,0x00,0x7B,0x00,0x00,0x00,0x13,0x00,0x44,0x34,0x2A,0x3E,0x53,0x3A,0x38,0x36,0x31,0x37,0x38,0x35,0x30,0x30,0x35,0x32,0x30,0x35,0x30,0x37,0x39}; verifyNull(decoder, text( ChannelBuffers.wrappedBuffer(ByteOrder.LITTLE_ENDIAN, buf1)));*/ diff --git a/src/test/java/org/traccar/protocol/AplicomFrameDecoderTest.java b/src/test/java/org/traccar/protocol/AplicomFrameDecoderTest.java index 96a219d2a..b055221f2 100644 --- a/src/test/java/org/traccar/protocol/AplicomFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AplicomFrameDecoderTest.java @@ -10,7 +10,7 @@ public class AplicomFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AplicomFrameDecoder(); + var decoder = inject(new AplicomFrameDecoder()); assertEquals( binary("44C20146B710C158DA009500B09F7700C054CA0EA454CA0EA403BE0BF6015D706B070000142A600000000000000002434946010801000754CA0EA4000000000000008400000000000000000000000000000000300000FE00FE0000000000000000000000000000000000000000000000000000000000000000000040502035000000000000020D0000030D0000040C0000040D0000050C0000050D0000058C0000060C"), diff --git a/src/test/java/org/traccar/protocol/AplicomProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AplicomProtocolDecoderTest.java index 5abe9550d..4b25830f8 100644 --- a/src/test/java/org/traccar/protocol/AplicomProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AplicomProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AplicomProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AplicomProtocolDecoder(null); + var decoder = inject(new AplicomProtocolDecoder(null)); verifyNull(decoder, binary( "434946010A0100075253F85F0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000FEEA0000FEE90000F0030000F0040000FEF10000FEF20000FEF50000FEFC0000FEC10000FEE500")); diff --git a/src/test/java/org/traccar/protocol/AppelloProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AppelloProtocolDecoderTest.java index da4d82938..e821c9dba 100644 --- a/src/test/java/org/traccar/protocol/AppelloProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AppelloProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AppelloProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AppelloProtocolDecoder(null); + var decoder = inject(new AppelloProtocolDecoder(null)); verifyAttributes(decoder, text( "FOLLOWIT,867273024233699,UTCTIME,0.000000,0.000000,0,0,0,0,L,262:3:c703:4bf8:64:255|262:3:c703:9a18:45|262:3:c703:e838:33|262:3:c703:7190:20|262:3:c704:d896:17|,02,44,,31,,4.20,0,0,86/44/24,,,,26,02264DFF6E16:69|4C09D408554E:79|4C09D408554F:79|E0885DE705E5:81|E2885DE705E7:81|246511122CCC:83|,34925")); diff --git a/src/test/java/org/traccar/protocol/AquilaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AquilaProtocolDecoderTest.java index 57d793c71..38c5d3b6d 100644 --- a/src/test/java/org/traccar/protocol/AquilaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AquilaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AquilaProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeA() throws Exception { - var decoder = new AquilaProtocolDecoder(null); + var decoder = inject(new AquilaProtocolDecoder(null)); verifyPosition(decoder, text( "$$CLIENT_1ZF,170215089,20,18.462809,73.824188,170613182744,A,01,123456,*37")); diff --git a/src/test/java/org/traccar/protocol/Ardi01ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Ardi01ProtocolDecoderTest.java index 653e4346d..fd65ce585 100644 --- a/src/test/java/org/traccar/protocol/Ardi01ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Ardi01ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Ardi01ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Ardi01ProtocolDecoder(null); + var decoder = inject(new Ardi01ProtocolDecoder(null)); verifyPosition(decoder, text( "013227003054776,20141010052719,24.4736042,56.8445807,110,289,40,7,5,78,-1"), diff --git a/src/test/java/org/traccar/protocol/ArknavProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ArknavProtocolDecoderTest.java index b95963f40..b07dff150 100644 --- a/src/test/java/org/traccar/protocol/ArknavProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ArknavProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ArknavProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ArknavProtocolDecoder(null); + var decoder = inject(new ArknavProtocolDecoder(null)); verifyPosition(decoder, text( "358266016278447,05*827,000,L001,V,4821.6584,N,01053.8650,E,000.0,000.0,00.0,08:46:04 17-03-16,9.5A,D7,0,79,0,,,,"), diff --git a/src/test/java/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java index c2d78dca6..9686c694b 100644 --- a/src/test/java/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ArknavX8ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ArknavX8ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ArknavX8ProtocolDecoder(null); + var decoder = inject(new ArknavX8ProtocolDecoder(null)); verifyNull(decoder, text( "351856045213782,241111")); diff --git a/src/test/java/org/traccar/protocol/ArmoliProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ArmoliProtocolDecoderTest.java new file mode 100644 index 000000000..515f7f7b2 --- /dev/null +++ b/src/test/java/org/traccar/protocol/ArmoliProtocolDecoderTest.java @@ -0,0 +1,36 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; +import org.traccar.model.Position; + +public class ArmoliProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new ArmoliProtocolDecoder(null)); + + verifyAttribute(decoder, text( + "[M869867039550712160821153237N41.033508E029.2697032F00036000000410006B336FFFFG458563@A6D>04410C2482>03410F56>03412F19>0441210000>034130FF>0441313A7>03410D30>04411F01B6>0341048C>04410C1C98];"), + Position.KEY_RPM, 1830L); + + verifyPosition(decoder, text( + "[M869867038698074210122125205N38.735641E035.4727751E003340000000C00000E9E07FF:106AG505283H60E]")); + + verifyAttribute(decoder, text( + "[W869867038698074,O,1234,2657,1]"), + Position.KEY_RESULT, "O,1234,2657,1"); + + verifyNull(decoder, text( + "[Q010001088610010024363698990011101070608200,05XXXXXXXXX,10.49.182.53,C,1,20,19,0]")); + + verifyPosition(decoder, text( + "[M860906041293587100122061310N40.792751E029.4313092801143000000010003513209FFGC18080H8DA#E209C4]")); + + verifyNull(decoder, text( + "[L866104027971681]")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/ArnaviBinaryProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ArnaviBinaryProtocolDecoderTest.java index f2940de59..f96da5203 100644 --- a/src/test/java/org/traccar/protocol/ArnaviBinaryProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ArnaviBinaryProtocolDecoderTest.java @@ -8,9 +8,7 @@ public class ArnaviBinaryProtocolDecoderTest extends ProtocolTest { @Test public void testHeader1Decode() throws Exception { - ArnaviBinaryProtocolDecoder decoder; - - decoder = new ArnaviBinaryProtocolDecoder(null); + var decoder = inject(new ArnaviBinaryProtocolDecoder(null)); verifyNull(decoder, binary( "ff22f30c45f5c90f0300")); @@ -23,9 +21,7 @@ public class ArnaviBinaryProtocolDecoderTest extends ProtocolTest { @Test public void testHeader2Decode() throws Exception { - ArnaviBinaryProtocolDecoder decoder; - - decoder = new ArnaviBinaryProtocolDecoder(null); + var decoder = inject(new ArnaviBinaryProtocolDecoder(null)); verifyNull(decoder, binary( "ff23f30c45f5c90f0300")); diff --git a/src/test/java/org/traccar/protocol/ArnaviFrameDecoderTest.java b/src/test/java/org/traccar/protocol/ArnaviFrameDecoderTest.java index 3f495731a..92ca5d2b0 100644 --- a/src/test/java/org/traccar/protocol/ArnaviFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ArnaviFrameDecoderTest.java @@ -8,7 +8,7 @@ public class ArnaviFrameDecoderTest extends ProtocolTest { @Test public void testDecodeValidPackets() throws Exception { - var decoder = new ArnaviFrameDecoder(); + var decoder = inject(new ArnaviFrameDecoder()); verifyFrame( binary("2441562c563344492c38353136342c3231342c2d312c31392c30303030344634462c30303030303935452c30433030303030322c3836333037313031333034313631382c38393939373031353630333832353236363232462c2a3039"), diff --git a/src/test/java/org/traccar/protocol/ArnaviTextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ArnaviTextProtocolDecoderTest.java index 9e9047be4..e27367119 100644 --- a/src/test/java/org/traccar/protocol/ArnaviTextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ArnaviTextProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ArnaviTextProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ArnaviTextProtocolDecoder(null); + var decoder = inject(new ArnaviTextProtocolDecoder(null)); verifyPosition(decoder, buffer( "$AV,V4,999999,12487,2277,203,65534,0,0,193,65535,65535,65535,65535,1,13,80.0,56.1,200741,5950.6773N,03029.1043E,300.0,360.0,121012,65535,65535,65535,SF*6E")); diff --git a/src/test/java/org/traccar/protocol/AstraProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AstraProtocolDecoderTest.java index 3376fa3f0..2d8798dff 100644 --- a/src/test/java/org/traccar/protocol/AstraProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AstraProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AstraProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AstraProtocolDecoder(null); + var decoder = inject(new AstraProtocolDecoder(null)); verifyPositions(decoder, binary( "4b00700529c0c265976b8202cba9ff00676d864554a9c30000000020073401006436000300030008000000000000a0000100001920c43d00009600428302cba9ff00676d864554aa3e000000002007240100643b000300020008000000000000b0000100001920c43d00009600420f0e")); diff --git a/src/test/java/org/traccar/protocol/At2000FrameDecoderTest.java b/src/test/java/org/traccar/protocol/At2000FrameDecoderTest.java index 0782c2d34..773a8f7f5 100644 --- a/src/test/java/org/traccar/protocol/At2000FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/At2000FrameDecoderTest.java @@ -8,7 +8,7 @@ public class At2000FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new At2000FrameDecoder(); + var decoder = inject(new At2000FrameDecoder()); verifyFrame( binary("01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8"), diff --git a/src/test/java/org/traccar/protocol/At2000ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/At2000ProtocolDecoderTest.java index 9e2f180d2..8c32289f1 100644 --- a/src/test/java/org/traccar/protocol/At2000ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/At2000ProtocolDecoderTest.java @@ -14,7 +14,7 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { At2000ProtocolDecoder decoder; - decoder = new At2000ProtocolDecoder(null); + decoder = inject(new At2000ProtocolDecoder(null)); verifyNull(decoder, binary( "01012f00000000000000000000000000003335373435343037313632373539388b57ec3a6ec7e3310a1ceb0a70fd751b8f2e7be6df1d6dcd80129f66fff0ea1c")); @@ -22,7 +22,7 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "89000000000000000000000000000000")); - decoder = new At2000ProtocolDecoder(null); + decoder = inject(new At2000ProtocolDecoder(null)); verifyNull(decoder, binary( "01012f0000000000000000000000000000333537343534303731363036313936ddf189075add9a32d97b54073025963e65849a3a59940d05fd8db655fc84bc6d")); @@ -30,7 +30,7 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "893b01000000000000000000000000003b40bcdab6387d829146701d8cb53daaa87b84d24b40cb24fd86da5d3f5f02b0f6f603c43c5a513418a0b2bdcaba603dbe737687cfe9082c57668eb6789d2b029a35aeac6a609558b96de5d7ad37917c902efc878ca9aff474f9d5d2417191285b8d5749bd3ffa86cc99096ce24c1f6ac350ae9adf3d5c788f80b4e3d3dc2dbb8abc1414ea1b52fdb55b2bb8af223ec528245f99d451b715e5774c5397db645d9ae441e645f8dae70230b728e81f51240868712d6f426fd694dbad8026fcf487c268939f04593ad86391cc829b1a1bdac8804ff7507544a69dc0b1b3927d7344e8a5b26fa56825283b3e476330b36d15011e1647ebd9f2ef71844ed32c0dc050457bfbd79160e6d1d8cda00a0927c8957631770e98eb20735aa46b0b18502baf4c45d2623ee51a4320cf3018010e7bbf8bc0dd79eb28e88b727ea67e980b8a91")); - decoder = new At2000ProtocolDecoder(null); + decoder = inject(new At2000ProtocolDecoder(null)); verifyNull(decoder, binary( "01012f000000000000000000000000000033353734353430373136303631393637f5441a9862260117858237fe3160388490f0df7d46c09112ee087235a92101")); @@ -38,7 +38,7 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "89043203000000000000000000000000d01ff1df1b56ba9185bb741ddc253f3cee093b1f8193100cd95777b5288a6f29d1b343a952f882ce8825679f7e27ad88ed7898bff92f716acadfc3c17fa8c1a6b9d0934e8f042433a183776c06c1acd73efb4b9f19030debb4dceb161fb3e6630757d25c3e995b7cf5f446318dcc1677eb215d1af49f11cd7300598bcdc40cc25466ed2391d836c782e44bc04a332e902b2b34f5597a542af4ca670cdfc18d87ce2a225c3e6f2f32359d4914c6df09aa5ee306c229260d4a56da53f93398bc8a6e77095305ee214cf605de20d3876a993fb810486f75bcd514c12442bf4dc3fbe7963b20d5100b5ecff1c1aef4c4b3736a04e245d50f538327db21d55270b279db5ac5a9658876bae3d9b5026b8975bb2bf4d100b8492760d66ae31f27bf9c525c2d794860eabca9c788b91152dbce79f336daaf6a7a9547bf1dd8e3334c891f4548fd6d112ebf45125c2a8abd3a786ebbcfdd03101b524bbf465f14a9a424305ce7de56ffca85b4657fc8c03e4349c0ca6be64d1cf595ee91f8173678ef2267dae54dd00028450c48d9b74c925af0f245d409d8773238dce5832747587f53a12155869c1d464eb0630f94cf8dceb76aa39995411d4ce7743b1501692425afec498535526067e79f568b7f71ee47d8b4929118d57b13d56cdbfd26582d579dee")); - decoder = new At2000ProtocolDecoder(null); + decoder = inject(new At2000ProtocolDecoder(null)); verifyNull(decoder, binary( "01012f0000000000000000000000000000333537343534303731363035353033dd529a1eb5df9f3b6d320b38250e03306692957e8c2127d8e381a717f639b4c9")); @@ -46,7 +46,7 @@ public class At2000ProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "89898701000000000000000000000000ae99e38f13d44f536769eb4930a6826dfebe5b98a6048941e89b17c9cdcb276be4af7c0d188d07c90d6e94aa9efcb465fe7aeaff4d85caf837483b4e9b32fbbacfbc4e175eebf57a27f552a64fc3419565d2dfbea668511a08d5a526342fad0e93b20c4449ad8defab4a9ac68cf7dad86971eb2cd96810d9d6a9c56e07fd90e4c28cfc53a069b63efe37a0523a69b607a2dc011ba17b177c5332c04be1faeeabed24539b3b790fa8a8610ab3633e0140ed79690fcae9dea43c7daad780d95a511d8f4875e621bcfe7516a03b80eb3c473ffd4bc1eda298dfa7d994a2cfeaa5d24c190d52d72fd90975a2e6f9ed3b95017133952262f91787c46839738a80c333dc53ee4d8afe75315d801efe17bc7309f30cfce64906bf70e6844c835781cbb64b49e9315ca3c2cd39d00a03cc7178a4ebc5df230dcdfd44ec588791d488f96bb6ff4007a753f552bda4d1766632aa3ec5eb38feb23ed6efb8f382a7f22b70adc9cb533c09bf749190c36d63b572c1acfc3a59138d51273835ab13c4689df01e3d2c2dd1829e00aac5c56b5d51e60d6731833f82c7464d88df663ca28a20eedeecb60f3704ae78281838caa116184e414db459768321bbfa1e83ad59fe168eb81f3b41cfe0e39c8aa78cbbe5825620bf053a1cb62e04d4cdf17ca2dc9305d47c")); - decoder = new At2000ProtocolDecoder(null); + decoder = inject(new At2000ProtocolDecoder(null)); verifyNull(decoder, binary( "01012f00000000000000000000000000003335363137333036343430373439320fad981997ae8e031fe10c0ea7641903ca32c0331df467233d2a9cd886fbeef8")); diff --git a/src/test/java/org/traccar/protocol/AtrackFrameDecoderTest.java b/src/test/java/org/traccar/protocol/AtrackFrameDecoderTest.java index 77e90ca53..958814e53 100644 --- a/src/test/java/org/traccar/protocol/AtrackFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AtrackFrameDecoderTest.java @@ -8,7 +8,7 @@ public class AtrackFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AtrackFrameDecoder(); + var decoder = inject(new AtrackFrameDecoder()); verifyFrame( binary("4052698c032a924f000147027fe5d7425f642e56060f031847bb68cb500719e26752c25bebc11c7fddce2b8ed4eff4ed863b187cc6653b5b1c1fc6803884d21aeeedae2ec6e72781d97e95b965610c1d107e5400cd5a7b7b3b592e676091c6a5893d80af9b3c63ae4de20d6e5bc60440bf2c299fbabfe268039d558e4b8589dd5173c926b7f51b916ba29f21d46ff9170793fe450072d691896e114fddce4fd29f7f2f9b74e41ca83814015e8a00ffd1f9bd475e2a44624e074a009455ab5628e39fce8036a09368cf1d2ba0d2653b979c0a00e9edc82335a56d1ee6071401d468b0f4cd761a743d011401d15b4636015721870dd0500695b2edabeabf2f4a00a514645cc83a739ad165f320c1ed401617a0a2800a2803ffd2faa68a004660aa598e00acd8f4d866d54eab3c7994284881fe11ebf5e68034e8a0086e674850927f0ae2bc4dafa5844659674451d39e49a00e1dae23d76ed67bb72211d109e4d5bd756da3b68a4b755021e30076a00cf31431a064e41e6a19a68d5396518f7a00f1ff008bfe27f31068766dbb7e1a723d3fbbf8d79aeb764748b489662be7ccbbb6820e07d4500734caa727765aa32ac0720e28026b4bb9ed7ccf2594798bb5b2a0f1f8f4a82800a2803fffd3f9b97352ae02e45004c808e4f7a997823bd005e86600618f26b7b4a9cab819fa500767a749b9403cd74162b903de803acd1e3c28aebf4d4c81401d05a4441fad682444738a00b712f2055f03e502802b14c5dffbc2ac106343ed4012a905411e94b40051401fffd4faa6992488980c793d0773400d54676df2f1e8b9e054b400564ebb77750c463b442d2119247f08f53e9401e7da85d6a12cd221d427217a856c60fe15caea9689292f2832bfac8777f3a00e67538ef150ff00665d9b4b95fba4aee46f623fa8ae26fbe24f88b49b87d3b5bd2a12e38ca3950e3d41e7228008be2ac02d423dadc09071c1047e791fcab96d77c79acdf92969279113f1c1cb7e7401876c4c939b8ba73230e5998e49ac4d66ee6bebd796462ddb9f4ed40140a12339e9dea225b1824d0025140051401fffd5f9bc676f6a7ae4af6e280255cf5c7153a7b0a0052d8715bba64bf32f39a00ed74694902bb1d306e65c500763a5afca2baed2"), diff --git a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java index 4a66dbf58..b6b09fc25 100644 --- a/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AtrackProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AtrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AtrackProtocolDecoder(null); + var decoder = inject(new AtrackProtocolDecoder(null)); verifyNull(decoder, binary( "4052698c032a924f000147027fe5d7425f642e56060f031847bb68cb500719e26752c25bebc11c7fddce2b8ed4eff4ed863b187cc6653b5b1c1fc6803884d21aeeedae2ec6e72781d97e95b965610c1d107e5400cd5a7b7b3b592e676091c6a5893d80af9b3c63ae4de20d6e5bc60440bf2c299fbabfe268039d558e4b8589dd5173c926b7f51b916ba29f21d46ff9170793fe450072d691896e114fddce4fd29f7f2f9b74e41ca83814015e8a00ffd1f9bd475e2a44624e074a009455ab5628e39fce8036a09368cf1d2ba0d2653b979c0a00e9edc82335a56d1ee6071401d468b0f4cd761a743d011401d15b4636015721870dd0500695b2edabeabf2f4a00a514645cc83a739ad165f320c1ed401617a0a2800a2803ffd2faa68a004660aa598e00acd8f4d866d54eab3c7994284881fe11ebf5e68034e8a0086e674850927f0ae2bc4dafa5844659674451d39e49a00e1dae23d76ed67bb72211d109e4d5bd756da3b68a4b755021e30076a00cf31431a064e41e6a19a68d5396518f7a00f1ff008bfe27f31068766dbb7e1a723d3fbbf8d79aeb764748b489662be7ccbbb6820e07d4500734caa727765aa32ac0720e28026b4bb9ed7ccf2594798bb5b2a0f1f8f4a82800a2803fffd3f9b97352ae02e45004c808e4f7a997823bd005e86600618f26b7b4a9cab819fa500767a749b9403cd74162b903de803acd1e3c28aebf4d4c81401d05a4441fad682444738a00b712f2055f03e502802b14c5dffbc2ac106343ed4012a905411e94b40051401fffd4faa6992488980c793d0773400d54676df2f1e8b9e054b400564ebb77750c463b442d2119247f08f53e9401e7da85d6a12cd221d427217a856c60fe15caea9689292f2832bfac8777f3a00e67538ef150ff00665d9b4b95fba4aee46f623fa8ae26fbe24f88b49b87d3b5bd2a12e38ca3950e3d41e7228008be2ac02d423dadc09071c1047e791fcab96d77c79acdf92969279113f1c1cb7e7401876c4c939b8ba73230e5998e49ac4d66ee6bebd796462ddb9f4ed40140a12339e9dea225b1824d0025140051401fffd5f9bc676f6a7ae4af6e280255cf5c7153a7b0a0052d8715bba64bf32f39a00ed74694902bb1d306e65c500763a5afca2baed2")); @@ -111,7 +111,7 @@ public class AtrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeCustom() throws Exception { - var decoder = new AtrackProtocolDecoder(null); + var decoder = inject(new AtrackProtocolDecoder(null)); decoder.setCustom(true); diff --git a/src/test/java/org/traccar/protocol/AuroProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AuroProtocolDecoderTest.java index fbe3ad0a3..368f7ed4c 100644 --- a/src/test/java/org/traccar/protocol/AuroProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AuroProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AuroProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AuroProtocolDecoder(null); + var decoder = inject(new AuroProtocolDecoder(null)); verifyPosition(decoder, text( "M0028T0000816398975I357325031465123E00001W*****110620150437000068DA#RD01DA240000000001+100408425+013756121100620152137231112240330004400")); diff --git a/src/test/java/org/traccar/protocol/AustinNbProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AustinNbProtocolDecoderTest.java index 0be22b333..30152e94c 100644 --- a/src/test/java/org/traccar/protocol/AustinNbProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AustinNbProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AustinNbProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AustinNbProtocolDecoder(null); + var decoder = inject(new AustinNbProtocolDecoder(null)); verifyPosition(decoder, text( "48666666666;2017-01-01 16:31:01;52,1133308410645;21,1000003814697;310;120;2292;1;ORANGE")); diff --git a/src/test/java/org/traccar/protocol/AutoFonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AutoFonProtocolDecoderTest.java index 3e64defdb..8e17d5673 100644 --- a/src/test/java/org/traccar/protocol/AutoFonProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AutoFonProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class AutoFonProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AutoFonProtocolDecoder(null); + var decoder = inject(new AutoFonProtocolDecoder(null)); verifyNull(decoder, binary( "10556103592310314825728F")); diff --git a/src/test/java/org/traccar/protocol/AutoGradeProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AutoGradeProtocolDecoderTest.java index 697ac8a06..7f837451c 100644 --- a/src/test/java/org/traccar/protocol/AutoGradeProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AutoGradeProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AutoGradeProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AutoGradeProtocolDecoder(null); + var decoder = inject(new AutoGradeProtocolDecoder(null)); verifyPosition(decoder, text( "(000000001637868324027912356171116A2250.7611N07556.9425E000.9024427197.36\u008eA0000B0000C0000D0000E0000K0000L0000M0000N0000O0000)")); diff --git a/src/test/java/org/traccar/protocol/AutoTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AutoTrackProtocolDecoderTest.java index 64a7459ce..51bbd0d8c 100644 --- a/src/test/java/org/traccar/protocol/AutoTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AutoTrackProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class AutoTrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AutoTrackProtocolDecoder(null); + var decoder = inject(new AutoTrackProtocolDecoder(null)); verifyNull(decoder, binary( "f1f1f1f1330c00201007090006de7200000000daa3")); diff --git a/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java index 6138711aa..7f41d6b47 100644 --- a/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/AvemaProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class AvemaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new AvemaProtocolDecoder(null); + var decoder = inject(new AvemaProtocolDecoder(null)); verifyAttribute(decoder, text( "1000000000,20190527072358,121.646024,25.062135,0,0,0,0,10,0.0,1,0.02,12.32,0,0,15,2,466-5,10275,0,0.01,65EB812A000104E0,8000001234,NormanChang"), diff --git a/src/test/java/org/traccar/protocol/Avl301ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Avl301ProtocolDecoderTest.java index fb1984d87..1da432cea 100644 --- a/src/test/java/org/traccar/protocol/Avl301ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Avl301ProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Avl301ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Avl301ProtocolDecoder(null); + var decoder = inject(new Avl301ProtocolDecoder(null)); verifyNull(decoder, binary( "244c0f086058500087335500010d0a")); diff --git a/src/test/java/org/traccar/protocol/B2316ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/B2316ProtocolDecoderTest.java index 6b9c71b0e..ea3b38e7d 100644 --- a/src/test/java/org/traccar/protocol/B2316ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/B2316ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class B2316ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new B2316ProtocolDecoder(null); + var decoder = inject(new B2316ProtocolDecoder(null)); verifyPositions(decoder, false, text( "{\"imei\":\"866349041783600\",\"data\":[{\"tm\":1631162952,\"wn\":7},{\"tm\":1631158729,\"ic\":\"89883030000059398609\",\"ve\":\"B2316.TAU.U.TH01\"},{\"tm\":1631158805,\"te\":\"312,363\",\"st\":0,\"ba\":3,\"sn\":80},{\"tm\":1631158829,\"ci\":\"505,1,8218,133179149,-108\"},{\"tm\":1631162956,\"wi\":\"101331c17f4f,-74;f46bef7953bb,-81;b09575cff1c8,-86;e2b9e5d61a7a,-88;b0ee7b4dee2f,-88;e0b9e5d61a77,-89;f66bef7953b9,-89;\",\"te\":\"335,366\",\"hr\":58,\"bp\":\"113,73\",\"st\":0,\"ba\":3,\"sn\":60},{\"tm\":1631162968,\"ci\":\"505,1,8218,133179149,-105\"}]}")); diff --git a/src/test/java/org/traccar/protocol/BceFrameDecoderTest.java b/src/test/java/org/traccar/protocol/BceFrameDecoderTest.java new file mode 100644 index 000000000..e5a442f2f --- /dev/null +++ b/src/test/java/org/traccar/protocol/BceFrameDecoderTest.java @@ -0,0 +1,26 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class BceFrameDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new BceFrameDecoder()); + + verifyNull( + decoder.decode(null, null, binary("23424345230d0a"))); + + verifyFrame( + binary("18ed450cf31403001501a5050a66207bde6442534451380a66207bde6440534451380a66207bde6414534451380a66207bde6416534451380a96207bde6415534451386247277bde03c0ffffc081400069f934418ce94b42001c88ee0000000000908c060103025d19ab004b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c40000000000000001010000000aa6277bde008f5344513862b7277bde03c0ffffc081400051f8344185e94b420c1c85fa0000000000d18c060103025d19ab00470000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c40000000000000001010400000ab6277bde009153445138a0"), + decoder.decode(null, null, binary("18ed450cf31403001501a5050a66207bde6442534451380a66207bde6440534451380a66207bde6414534451380a66207bde6416534451380a96207bde6415534451386247277bde03c0ffffc081400069f934418ce94b42001c88ee0000000000908c060103025d19ab004b0000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c40000000000000001010000000aa6277bde008f5344513862b7277bde03c0ffffc081400051f8344185e94b420c1c85fa0000000000d18c060103025d19ab00470000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c40000000000000001010400000ab6277bde009153445138a0"))); + + verifyFrame( + binary("18ed450cf31403000200a5070e"), + decoder.decode(null, null, binary("18ed450cf31403000200a5070e"))); + + } + +} diff --git a/src/test/java/org/traccar/protocol/BceProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BceProtocolDecoderTest.java index 544d49967..1d980b7e5 100644 --- a/src/test/java/org/traccar/protocol/BceProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/BceProtocolDecoderTest.java @@ -1,15 +1,28 @@ package org.traccar.protocol; +import org.junit.Ignore; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Position; public class BceProtocolDecoderTest extends ProtocolTest { + @Ignore + @Test + public void testDecodeFail() throws Exception { + + var decoder = inject(new BceProtocolDecoder(null)); + + // Needs to be fixed + verifyPositions(decoder, binary( + "18ed450cf3140300c800a53a62972f7bde03c0ffffc0814000e03e354135e34b42121c55fb0000000000d18c060103025d19ab00540000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c400000000000000010104080162a72f7bde03c0ffffc0814000ef3e8e4431e34b42061c54fc0000000000d18c060103025d19ab00540000000000000000000000000000000000000000000000000000000000000000000000000000000000000017b5c400000000000000010100000053")); + + } + @Test public void testDecode() throws Exception { - var decoder = new BceProtocolDecoder(null); + var decoder = inject(new BceProtocolDecoder(null)); verifyNull(decoder, binary( "3ab90b71bc1503000300c10bff11")); diff --git a/src/test/java/org/traccar/protocol/BceProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/BceProtocolEncoderTest.java index c72012e5a..bfaa3ccd8 100644 --- a/src/test/java/org/traccar/protocol/BceProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/BceProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class BceProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new BceProtocolEncoder(null); + var encoder = inject(new BceProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/BlackKiteProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BlackKiteProtocolDecoderTest.java index 3fdac8479..2fb93f2a9 100644 --- a/src/test/java/org/traccar/protocol/BlackKiteProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/BlackKiteProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class BlackKiteProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new BlackKiteProtocolDecoder(null); + var decoder = inject(new BlackKiteProtocolDecoder(null)); verifyNull(decoder, binary( "01150003313131313131313131313131313131209836055605BA")); diff --git a/src/test/java/org/traccar/protocol/BlueProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BlueProtocolDecoderTest.java index 4e74adf38..1de542e24 100644 --- a/src/test/java/org/traccar/protocol/BlueProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/BlueProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class BlueProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new BlueProtocolDecoder(null); + var decoder = inject(new BlueProtocolDecoder(null)); verifyAttribute(decoder, binary( "AA0056860080E3E79E0C811F80000114020207170520011F00407F8005EE1938113B270000000000000000140202071705005AC7A621121F0002000100B7000080110000000000001A3A0000000001F400000000000078"), diff --git a/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java index 5b639e12b..0a19eb3b0 100644 --- a/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/BoxProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class BoxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new BoxProtocolDecoder(null); + var decoder = inject(new BoxProtocolDecoder(null)); verifyNull(decoder, text( "H,BT,358281002435893,081028142432,F5813D19,6D6E6DC2")); diff --git a/src/test/java/org/traccar/protocol/BstplProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/BstplProtocolDecoderTest.java new file mode 100644 index 000000000..ae4c47229 --- /dev/null +++ b/src/test/java/org/traccar/protocol/BstplProtocolDecoderTest.java @@ -0,0 +1,21 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class BstplProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new BstplProtocolDecoder(null)); + + verifyPosition(decoder, text( + "BSTPL$1,869630054439504,V,200722,045113,00.000000,0,00.00000,0,0,0,000,00,0,17,1,1,0,0,00.01,0,04.19,15B_190821,8991000907387031196F,12.27")); + + verifyPosition(decoder, text( + "BSTPL$1,AP12AP3456,A,130720,160552,27.244183,N,83.673973,E,20,156,183,17,0,11,1,0,0,0,00.00,00,04.16,15_V1_0_0,89917380578146790443,12.16")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java index d6831c1cf..28876075d 100644 --- a/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/C2stekProtocolDecoderTest.java @@ -8,9 +8,15 @@ public class C2stekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new C2stekProtocolDecoder(null); + var decoder = inject(new C2stekProtocolDecoder(null)); - verifyNull(decoder, text( + verifyPosition(decoder, text( + "PA$012207006145046$D#190607#123157#1#37.947087#023.768669#000.00#314.6#00000.0#4104#000#8$AP")); + + verifyPosition(decoder, text( + "PA$867965024889327$D#220222#135059#0#+37.98995#+23.85141#0.00#69.2#0.0#0000#000#8#00#sz-w1001#B2600$AP")); + + verifyPosition(decoder, text( "PA$863083038046613$D#181123#162850#1#+37.92684#+23.75933#0.62#200.1#0.0#3768#000#9#00#sz-w1001#B0907839$AP")); verifyPosition(decoder, text( diff --git a/src/test/java/org/traccar/protocol/CalAmpProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CalAmpProtocolDecoderTest.java index 79d27e2ab..1a8431f23 100644 --- a/src/test/java/org/traccar/protocol/CalAmpProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CalAmpProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CalAmpProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CalAmpProtocolDecoder(null); + var decoder = inject(new CalAmpProtocolDecoder(null)); verifyPosition(decoder, binary( "830547643586340101010400105f9c39ba5f9c302eeb36d5bddf39df700000000000000000003400040321ff9f4f0087080200001c30783330304544383946333335303139303030303030343637450d0a")); diff --git a/src/test/java/org/traccar/protocol/CarTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CarTrackProtocolDecoderTest.java index dd96c2585..d12d4aa9f 100644 --- a/src/test/java/org/traccar/protocol/CarTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CarTrackProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CarTrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CarTrackProtocolDecoder(null); + var decoder = inject(new CarTrackProtocolDecoder(null)); verifyNull(decoder, text( "$$020040????????&A0000")); diff --git a/src/test/java/org/traccar/protocol/CarscopProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CarscopProtocolDecoderTest.java index b1fe69bac..71137cacf 100644 --- a/src/test/java/org/traccar/protocol/CarscopProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CarscopProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CarscopProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CarscopProtocolDecoder(null); + var decoder = inject(new CarscopProtocolDecoder(null)); verifyNull(decoder, text( "*170821223045UB00HSO")); diff --git a/src/test/java/org/traccar/protocol/CastelProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CastelProtocolDecoderTest.java index f90fbe5ba..1add623b7 100644 --- a/src/test/java/org/traccar/protocol/CastelProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CastelProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class CastelProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CastelProtocolDecoder(null); + var decoder = inject(new CastelProtocolDecoder(null)); verifyAttribute(decoder, binary( "40403a00043231334744503230313830323133343300000000a002000001000001012011004d414c43333831434d4b4d353637313438c8fc0d0a"), diff --git a/src/test/java/org/traccar/protocol/CastelProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/CastelProtocolEncoderTest.java index cdf6a7c3b..9b3a285da 100644 --- a/src/test/java/org/traccar/protocol/CastelProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/CastelProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class CastelProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new CastelProtocolEncoder(null); + var encoder = inject(new CastelProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/CautelaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CautelaProtocolDecoderTest.java index fe8586068..4022d688b 100644 --- a/src/test/java/org/traccar/protocol/CautelaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CautelaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CautelaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CautelaProtocolDecoder(null); + var decoder = inject(new CautelaProtocolDecoder(null)); verifyPosition(decoder, text( "20,010907000000,14,02,18,16.816667,96.166667,1325,S,*2E")); diff --git a/src/test/java/org/traccar/protocol/CellocatorFrameDecoderTest.java b/src/test/java/org/traccar/protocol/CellocatorFrameDecoderTest.java index 04a0f74d5..c266dd1f4 100644 --- a/src/test/java/org/traccar/protocol/CellocatorFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CellocatorFrameDecoderTest.java @@ -8,7 +8,7 @@ public class CellocatorFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CellocatorFrameDecoder(); + var decoder = inject(new CellocatorFrameDecoder()); verifyFrame( binary("4D4347500BA9880B00C80A7E003800000000000806000001210A14000613000000000D4457A5F71442AC02E80300000100040707000011171408060E1C08000100000200020000FD"), diff --git a/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java index 3ae5350f2..27cad39a3 100644 --- a/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CellocatorProtocolDecoderTest.java @@ -2,13 +2,18 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class CellocatorProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CellocatorProtocolDecoder(null); + var decoder = inject(new CellocatorProtocolDecoder(null)); + + verifyAttribute(decoder, binary( + "4d4347500098ab31000856b12b2c041016002c0023b3000021f3f5ffb04c8f0100000000000078dd0004020f716445f75f3b0701126e0200b303000036002538151b0ce607ab"), + Position.KEY_IGNITION, true); verifyPosition(decoder, binary( "4D43475000856308000004B2DE1F04009E00200100000000696CF7AB002F1A00000000000000325C000402069BFDE70857E22502F41C000036000000DF0B0932100B09DC0719")); diff --git a/src/test/java/org/traccar/protocol/CellocatorProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/CellocatorProtocolEncoderTest.java index 9d42bd65d..bb5d4979d 100644 --- a/src/test/java/org/traccar/protocol/CellocatorProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/CellocatorProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class CellocatorProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new CellocatorProtocolEncoder(null); + var encoder = inject(new CellocatorProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/CguardProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CguardProtocolDecoderTest.java index a7ed0e754..835ab5fe5 100644 --- a/src/test/java/org/traccar/protocol/CguardProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CguardProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CguardProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CguardProtocolDecoder(null); + var decoder = inject(new CguardProtocolDecoder(null)); verifyNull(decoder, text( "IDRO:354868050655283")); diff --git a/src/test/java/org/traccar/protocol/CityeasyProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CityeasyProtocolDecoderTest.java index 07d6368ab..0c1fc1f5d 100644 --- a/src/test/java/org/traccar/protocol/CityeasyProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CityeasyProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class CityeasyProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CityeasyProtocolDecoder(null); + var decoder = inject(new CityeasyProtocolDecoder(null)); verifyNotNull(decoder, binary( "545400853575570249020100033b3430342c34352c31303638312c31313632312c33352c31303638312c31313632322c32332c31303638312c32383938332c32332c31303638312c31313632332c32312c31303638312c32333338312c31372c31303638312c32323538332c31372c31303638312c32363434312c31330000000d352e0d0a")); diff --git a/src/test/java/org/traccar/protocol/CityeasyProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/CityeasyProtocolEncoderTest.java index 2722f6474..6da9856c8 100644 --- a/src/test/java/org/traccar/protocol/CityeasyProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/CityeasyProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class CityeasyProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new CityeasyProtocolEncoder(null); + var encoder = inject(new CityeasyProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/ContinentalProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ContinentalProtocolDecoderTest.java index 2924d2c4d..6ac2ae01d 100644 --- a/src/test/java/org/traccar/protocol/ContinentalProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ContinentalProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ContinentalProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ContinentalProtocolDecoder(null); + var decoder = inject(new ContinentalProtocolDecoder(null)); verifyPosition(decoder, binary( "5356003216001eb48505025b4001e90f7f18ce0f00522200400001015b4001e9000e820100000c24000100014e0400736a7a"), diff --git a/src/test/java/org/traccar/protocol/CradlepointProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/CradlepointProtocolDecoderTest.java index 1e3023b39..f95bfb54d 100644 --- a/src/test/java/org/traccar/protocol/CradlepointProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/CradlepointProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class CradlepointProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new CradlepointProtocolDecoder(null); + var decoder = inject(new CradlepointProtocolDecoder(null)); verifyPosition(decoder, text( "356526070063940,0,4337.19009,N,11612.34705,W,0.0,277.2,AT&T,,,-79,,-14.0,")); diff --git a/src/test/java/org/traccar/protocol/DingtekFrameDecoderTest.java b/src/test/java/org/traccar/protocol/DingtekFrameDecoderTest.java index 6236410b3..c63775858 100644 --- a/src/test/java/org/traccar/protocol/DingtekFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DingtekFrameDecoderTest.java @@ -8,7 +8,7 @@ public class DingtekFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DingtekFrameDecoder(); + var decoder = inject(new DingtekFrameDecoder()); verifyFrame( binary("383030303031303131453032383830303138303030303030303030313545303038303545433430303031313836383832323034303130343433303831"), diff --git a/src/test/java/org/traccar/protocol/DingtekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DingtekProtocolDecoderTest.java index 8b3d07c22..7e5f68e05 100644 --- a/src/test/java/org/traccar/protocol/DingtekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DingtekProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DingtekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DingtekProtocolDecoder(null); + var decoder = inject(new DingtekProtocolDecoder(null)); verifyPosition(decoder, text( "800001011e0692001a00000000016e008027c40000186962703655111781")); diff --git a/src/test/java/org/traccar/protocol/DishaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DishaProtocolDecoderTest.java index 4492b3ed0..3faccd7ea 100644 --- a/src/test/java/org/traccar/protocol/DishaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DishaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DishaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DishaProtocolDecoder(null); + var decoder = inject(new DishaProtocolDecoder(null)); verifyPosition(decoder, text( "$A#A#864161028848856#A#053523#010216#2232.7733#N#08821.1940#E#002.75#038.1#09#00.8#1800#0#000#0000#9999#11.7#285.7#0001*")); diff --git a/src/test/java/org/traccar/protocol/DmtHttpProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DmtHttpProtocolDecoderTest.java index bed56ba30..99760546f 100644 --- a/src/test/java/org/traccar/protocol/DmtHttpProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DmtHttpProtocolDecoderTest.java @@ -9,7 +9,10 @@ public class DmtHttpProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DmtHttpProtocolDecoder(null); + var decoder = inject(new DmtHttpProtocolDecoder(null)); + + verifyAttributes(decoder, request(HttpMethod.POST, "/", + buffer("{\"date\":\"2021-12-12T16:04:52Z\",\"device\":{\"sn\":\"416581\",\"prod\":85,\"rev\":1,\"fw\":\"1.12\",\"iccid\":\"89011702278612797427\",\"imei\":\"351358810439486\"},\"sqn\":1549,\"reason\":42,\"counters\":[{\"id\":0,\"val\":5304},{\"id\":3,\"val\":3200},{\"id\":4,\"val\":5066},{\"id\":128,\"val\":1},{\"id\":129,\"val\":8},{\"id\":130,\"val\":0},{\"id\":131,\"val\":0},{\"id\":132,\"val\":0},{\"id\":134,\"val\":1},{\"id\":138,\"val\":0},{\"id\":139,\"val\":36},{\"id\":142,\"val\":1629023},{\"id\":145,\"val\":0},{\"id\":146,\"val\":1}]}"))); verifyAttributes(decoder, request(HttpMethod.POST, "/", buffer("{\"date\":\"2021-10-04T18:15:47Z\",\"device\":{\"sn\":\"403809\",\"prod\":85,\"rev\":1,\"fw\":\"1.12\",\"iccid\":\"89011702278483601922\",\"imei\":\"352656106127312\"},\"sqn\":40927,\"reason\":11,\"analogues\":[{\"id\":1,\"val\":4265},{\"id\":3,\"val\":3800},{\"id\":4,\"val\":12},{\"id\":5,\"val\":4251}],\"inputs\":1,\"outputs\":0,\"status\":137}"))); diff --git a/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java index 82a4cd5ff..9c14a1ebe 100644 --- a/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DmtProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DmtProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DmtProtocolDecoder(null); + var decoder = inject(new DmtProtocolDecoder(null)); verifyNull(decoder, binary( "0255003300001b00003335333232393032373533393235310038393931353030303030303030313330343539340000000403041910780603")); diff --git a/src/test/java/org/traccar/protocol/DolphinProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DolphinProtocolDecoderTest.java index 0215973e8..b9e3da67d 100644 --- a/src/test/java/org/traccar/protocol/DolphinProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DolphinProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DolphinProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DolphinProtocolDecoder(null); + var decoder = inject(new DolphinProtocolDecoder(null)); verifyPositions(decoder, binary( "ababff8f0300000100000100e03c0b86c70e03005c0f0000ab4cd12d0aa9010d0d7f0e4215f6fe6c421d00b0ce4420122daa9a9042359a99f9413806455e53fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa0662404801010ce41bb8f4cc2ad801fe98f3030893dd9a010001019299f303155400000007b401000000000072ac01b99401f8de8a0adc03900e0049000003004bfa010aa7010d4f7f0e421505ff6c421dcd1cce4420112d3ef984423552b89e413806456053fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e4201010ce41bd8f4cc2a20ff98f3030193dd9a010001019399f30315420000000000000000000072ad018f950181df8a0aee03cd0d004b000003004bfa010aa7010da67f0e42154fff6c421d3393cd4420112d073c9942358fc2df413806456253fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e4c010111f51d88f5cc2a308199f3030293dd9a010001019599f303154c0000000000000000000072ad01ef95018bdf8a0aee03d30d004a000003004bfa010aa9010dfd800e421525006d421d3373d04420102da5b7aa4235ec51c4413806456853fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa0662405501010ef01db0f6cc2aa8018899f3030793dd9a010001019c99f3031555000000068a010000000000739d01df9501acdf8a0ac0028a150031000003004bfa010aa8010d3b830e421561016d421dcddcd04420102d8edda94235cdccbe413806457353fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623f5401010ef01db8f8cc2a88029499f3030c93dd9a01000101a899f303155500000004480000000000728a018f9501e5df8a0aa9018d280015000003004bfa010aa8010ddd850e4215b3026d421dcd3cd04420112d2e9ba942359a99af413806458053fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623f5401010df01df0facc2ab802a199f3030d93dd9a01000101b599f303155500000005760000000000728b01f59401a2e08a0a9b01c12b0018000003004bfa010aa9010d4a870e421554036d421d66d6cf4420112d5f29a842355c8faa413806458753fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa0662405401010dea1d98fccc2aa801a899f3030793dd9a01000101bc99f303155400000007a4010000000000719701b29401bae08a0a9202be180026000003004bfa010aa7010da7870e421591036d421d33d3cf4420112d6329a942353333a7413806458953fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e5401010df51dc8fccc2a30aa99f3030293dd9a01000101be99f3031554000000022c0000000000719901db9401c3e08a0aae02a016002b000003004bfa010aa7010d1a880e4215b6036d421d33e3cf4420112ddc45aa423514aea3413806458b53fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e5501010df51df8fccc2a30ac99f3030293dd9a01000101c099f303155500000002320000000000719e01f69401d1e08a0a9f02b3170031000003004bfa010aa8010d50890e42154d046d421d3363d04420102da0b7a94235d7a3a2413806459253fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623f5401010edf1d88fecc2a9001b399f3030793dd9a01000101c799f303155400000000000000000000729a01e69501f7e08a0ab0028e16002d000003004bfa010aa9010d188c0e421573056d421d00c0ce4420102d300c84423514ae7741380645a053fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06624042010110da1dd080cd2ac802c199f3030e93dd9a01000101d599f303155500000009e2010000000000729801b19501afe18a0a97029018002a000003004bfa010aa7010d528c0e42159d056d421d3313cf4420102dfec98c423552b8c241380645a053fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e46010110da1df080cd2a20c299f3030193dd9a01000101d699f303154600000000000000000000729701df9501b8e18a0aa002b9170029000003004bfa010aa9010d198f0e42159e066d421d9a49d04420112dfae6a642359a999941380645ad53fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06624053010111e51da883cd2ab802cf99f3030d93dd9a01000101e399f30315540000000ca4020000000000729601c49501f1e18a0a9102dc180028000003004bfa010aa7010da68f0e4215e9066d421d9a19d044200f2d83dda74235ec519441380645b153fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e53010111e51df083cd2a48d299f3030393dd9a01000101e699f303155300000003400000000000729701de950183e28a0a8e02ff180028000003004bfa010aa7010d40900e42151a076d421d33c3cf4420102d717e9b423548e15e41380645b453fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e4d010110e51db884cd2a48d599f3030393dd9a01000101e999f303154d00000003420000000000729801bf950191e28a0a9a02f117002a000003004bfa010aa7010d5f900e42153c076d421d66c6cf44200f2de3028d4235713daa41380645b553fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e46010110da1dc884cd2a10d699f3030193dd9a01000101ea99f303154600000001120000000000729901bf950191e28a0a98029318002b000003004bfa010aa7010dae900e42153d076d421d9ad9cf44200f2d324fa342357b144241380645b653fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e51010110da1de884cd2a20d799f3030193dd9a01000101eb99f303155100000000000000000000729b01a5950196e28a0aa2029b17002c000003004bfa010aa7010d08910e42157e076d421d33b3cf4420102d51b79a42357b14b241380645b853fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623e4d010110da1d9885cd2a30d999f3030293dd9a01000101ed99f3031552000000022c0000000000729b01ca95019be28a0ab602e815002f000003004bfa010aa9010d3b930e42153f086d421d9a99d044200f2d5a3ca9423552b88441380645c153fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06624054010110f51d9087cd2af801e499f3030b93dd9a01000101f899f30315540000000bfa010000000000729901cf9501cee28a0ac502f814002e000003004bfa010aa9010df1950e421558096d421d6646d24420102da3a4a842357b149441380645cf53fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa0662405401010eea1dc889cd2ab802f199f3030d93dd9a01000101859af303155500000008be010000000000729901c7950190e38a0a9c02da17002c000003004bfa010aa9010dcf970e4215260a6d421d6676d34420112d653cab423552b89e41380645d853fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa0662405501010efa1ba08bcd2ad801fa99f3030993dd9a010001018e9af303155600000007a8010000000000729e01bb9501bae38a0ac00284150031000003004bfa010aa8010de89a0e4215510b6d421d00a0d44420112d1aaea74235cdcc6841380645e653fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06623f53010110f51d808ecd2ae002899af3030f93dd9a010001019d9af30315550000000460000000000073a401e59501fce38a0a9003e510003e000003004bfa010aa9010d6b9c0e4215b00b6d421d00b0d44420112dd46bac423585eb0541380645ed53fc5f48015a41050a0b1e29323334353637464850649601a401a601aa01ab01ad01b401b501b601b701b801c905ca05cb05cd05d105d205e605e705ef059c069e06a206a906aa06624056010110ea1da88fcd2aa801919af3030893dd9a01000101a59af303155600000008a801000000000073a201a19501a1e48a0a8103ce110038000003004bfa01")); diff --git a/src/test/java/org/traccar/protocol/Dsf22FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Dsf22FrameDecoderTest.java new file mode 100644 index 000000000..7e3ec0706 --- /dev/null +++ b/src/test/java/org/traccar/protocol/Dsf22FrameDecoderTest.java @@ -0,0 +1,23 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class Dsf22FrameDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new Dsf22FrameDecoder()); + + verifyFrame( + binary("4642000101A8EE5F0ECA5FF421B33F524E32610401"), + decoder.decode(null, null, binary("4642000101A8EE5F0ECA5FF421B33F524E32610401"))); + + verifyFrame( + binary("4642000103A8EE5F0ECA5FF421B33F524E326104010216600EFC92F421B63F524E366104013238600E1EBEF421B93F524E35610401"), + decoder.decode(null, null, binary("4642000103A8EE5F0ECA5FF421B33F524E326104010216600EFC92F421B63F524E366104013238600E1EBEF421B93F524E35610401"))); + + } + +} diff --git a/src/test/java/org/traccar/protocol/Dsf22ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Dsf22ProtocolDecoderTest.java new file mode 100644 index 000000000..2e52b950d --- /dev/null +++ b/src/test/java/org/traccar/protocol/Dsf22ProtocolDecoderTest.java @@ -0,0 +1,24 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class Dsf22ProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new Dsf22ProtocolDecoder(null)); + + verifyPositions(decoder, binary( + "4642a82d01c8f6aa1af1792c0c1411eb61001e0000")); + + verifyPositions(decoder, binary( + "4642000101A8EE5F0ECA5FF421B33F524E32610401")); + + verifyPositions(decoder, binary( + "4642000103A8EE5F0ECA5FF421B33F524E326104010216600EFC92F421B63F524E366104013238600E1EBEF421B93F524E35610401")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/DualcamFrameDecoderTest.java b/src/test/java/org/traccar/protocol/DualcamFrameDecoderTest.java index 46f32a8ae..f74a40d13 100644 --- a/src/test/java/org/traccar/protocol/DualcamFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DualcamFrameDecoderTest.java @@ -8,7 +8,7 @@ public class DualcamFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DualcamFrameDecoder(); + var decoder = inject(new DualcamFrameDecoder()); verifyFrame( binary("000000050001403a4abaa31444000400"), diff --git a/src/test/java/org/traccar/protocol/DualcamProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DualcamProtocolDecoderTest.java index 3dd11bdf7..a61f20c13 100644 --- a/src/test/java/org/traccar/protocol/DualcamProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DualcamProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DualcamProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DualcamProtocolDecoder(null); + var decoder = inject(new DualcamProtocolDecoder(null)); verifyNull(decoder, binary( "000000050001403a4abaa31444000400")); diff --git a/src/test/java/org/traccar/protocol/DwayProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/DwayProtocolDecoderTest.java index 368f8b4ac..1cdd82664 100644 --- a/src/test/java/org/traccar/protocol/DwayProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/DwayProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class DwayProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new DwayProtocolDecoder(null); + var decoder = inject(new DwayProtocolDecoder(null)); verifyPosition(decoder, text( "AA55,36,10024,1,171025,161055,36.0294,-79.7881,201, 2.5,111,1000,0000,00000,3578,0,0,0,D")); diff --git a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java index 5fda7fb28..ef319449e 100644 --- a/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EasyTrackProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class EasyTrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EasyTrackProtocolDecoder(null); + var decoder = inject(new EasyTrackProtocolDecoder(null)); verifyNotNull(decoder, text( "*ET,354522180593498,JZ,0,20222,262,724,4#")); diff --git a/src/test/java/org/traccar/protocol/EasyTrackProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/EasyTrackProtocolEncoderTest.java index 79b4e66e3..1e1934435 100644 --- a/src/test/java/org/traccar/protocol/EasyTrackProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/EasyTrackProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class EasyTrackProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeEngineStop() { + public void testEncodeEngineStop() throws Exception { - var encoder = new EasyTrackProtocolEncoder(null); + var encoder = inject(new EasyTrackProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/EelinkProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EelinkProtocolDecoderTest.java index d0c683abf..ec1467c09 100644 --- a/src/test/java/org/traccar/protocol/EelinkProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EelinkProtocolDecoderTest.java @@ -9,11 +9,14 @@ public class EelinkProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EelinkProtocolDecoder(null); + var decoder = inject(new EelinkProtocolDecoder(null)); verifyPositions(decoder, binary( "454c029249a50354679090044671676712004321315f3cf43503fc94d3760c79328a0129000000000a01f9000190330905580d2e046f118a04ec00000000ccc7086c02fe000000000000000000000000000000000000676712004321325f3cf43e03fc94d3760c79328a0129000000000901f9000190330905580d2e046f117b04ec00000000ccc7086d02ff000000000000000000000000000000000000676712004321335f3cf44703fc94d3760c79328a0129000000000901f9000190330905580d2e046f117f04ec00000000ccc7086d02ff000000000000000000000000000000000000676712004321345f3cf45303fc94d3760c79328a0129000000000901f9000190330905580d2e046f119d04ec00000000ccc7086d02ff000000000000000000000000000000000000676712004321355f3cf45c03fc94d3760c79328a0129000000000801f9000190330905580d2e046f11a304ec00000000ccc7086d02ff000000000000000000000000000000000000676712004321365f3cf46603fc94d3760c79328a0129000000000801f9000190330905580d2e046f118804df00000000ccc7086d02ff000000000000000000000000000000000000676712004321375f3cf47103fc94d3760c79328a0129000000000901f9000190330905580d2e046f119704ec00000000ccc7086d02ff000000000000000000000000000000000000676712004321385f3cf47a03fc94d3760c79328a0129000000000901f9000190330905580d2e046f118204ec00000000ccc7086e0300000000000000000000000000000000000000676712004321395f3cf48303fc94d3760c79328a0129000000000901f9000190330905580d2e046f117604df00000000ccc7086e0300000000000000000000000000000000000000")); + verifyPosition(decoder, binary( + "6767120056096661d38e0091fbf0aa3a0f8fa08500060051015f09002542e50e7ea6080101f90001304e304e0818390d000000c524c2ae0699102b00000000000115b0040504050000000014000000000000000000000000000002")); + verifyAttribute(decoder, binary( "676714001500035f74a2940201360104591100a7160122250400"), Position.KEY_ALARM, Position.ALARM_REMOVING); @@ -42,9 +45,6 @@ public class EelinkProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, binary( "676714002414B05AD43A7D03026B92B10C395499FFD7000000000701CC00002495000014203604067B")); - verifyNotNull(decoder, binary( - "676714004F14B0E68CAFE58AA8E68AA5E8ADA621E5B9BFE4B89CE79C81E6B7B1E59CB3E5B882E58D97E5B1B1E58CBAE696B0E8A5BFE8B7AF3138EFBC88E8B79DE5AE87E998B3E5A4A7E58EA63230E7B1B3EFBC89")); - verifyPosition(decoder, binary( "676780005a000001000000004c61743a4e33312e38333935352c4c6f6e3a5738322e36313334362c436f757273653a302e30302c53706565643a302e30306b6d2f682c4461746554696d653a323031372d31322d30322031313a32393a3433")); diff --git a/src/test/java/org/traccar/protocol/EelinkProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/EelinkProtocolEncoderTest.java index 616ca0b52..380888843 100644 --- a/src/test/java/org/traccar/protocol/EelinkProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/EelinkProtocolEncoderTest.java @@ -7,15 +7,28 @@ import org.traccar.model.Command; public class EelinkProtocolEncoderTest extends ProtocolTest { @Test - public void testEncode() throws Exception { + public void testEncodeTcp() throws Exception { + + var encoder = inject(new EelinkProtocolEncoder(null, false)); Command command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_ENGINE_STOP); - verifyCommand(new EelinkProtocolEncoder(null, false), command, binary("676780000f0000010000000052454c41592c3123")); + verifyCommand(encoder, command, binary("676780000f0000010000000052454c41592c3123")); + + } + + @Test + public void testEncodeUdp() throws Exception { + + var encoder = inject(new EelinkProtocolEncoder(null, true)); + + Command command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_ENGINE_STOP); - verifyCommand(new EelinkProtocolEncoder(null, true), command, binary("454c001eb41a0123456789012345676780000f0000010000000052454c41592c3123")); + verifyCommand(encoder, command, binary("454c001eb41a0123456789012345676780000f0000010000000052454c41592c3123")); } diff --git a/src/test/java/org/traccar/protocol/EgtsFrameDecoderTest.java b/src/test/java/org/traccar/protocol/EgtsFrameDecoderTest.java index a1acb1e9d..dde71d1e7 100644 --- a/src/test/java/org/traccar/protocol/EgtsFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EgtsFrameDecoderTest.java @@ -8,7 +8,7 @@ public class EgtsFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EgtsFrameDecoder(); + var decoder = inject(new EgtsFrameDecoder()); verifyFrame( binary("0100020B0025003A5701C91A003A5701CD6E68490202101700CBB4740F7617FD924364104F116A0000000000010300001EC2"), diff --git a/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java index dcf70bcae..0f5a40605 100644 --- a/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EgtsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class EgtsProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeWithObjectId() throws Exception { - var decoder = new EgtsProtocolDecoder(null); + var decoder = inject(new EgtsProtocolDecoder(null)); verifyNull(decoder, binary( "0100020b002300020001871c00020000010105190000ab0800006247396e615734366347467a63336476636d513daadf")); @@ -31,7 +31,7 @@ public class EgtsProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeWithAuth() throws Exception { - var decoder = new EgtsProtocolDecoder(null); + var decoder = inject(new EgtsProtocolDecoder(null)); verifyNull(decoder, binary( "0100010b002200c06401f21700c1640171360d00010101140071360d000238363539303500000000000000000047fc")); diff --git a/src/test/java/org/traccar/protocol/EnforaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EnforaProtocolDecoderTest.java index 14e982e39..2d2a211c3 100644 --- a/src/test/java/org/traccar/protocol/EnforaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EnforaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class EnforaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EnforaProtocolDecoder(null); + var decoder = inject(new EnforaProtocolDecoder(null)); verifyNull(decoder, binary( "000A08002020202020303131303730303030353730323637")); diff --git a/src/test/java/org/traccar/protocol/EnnfuProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EnnfuProtocolDecoderTest.java index 4afa5921f..0134e8052 100644 --- a/src/test/java/org/traccar/protocol/EnnfuProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EnnfuProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class EnnfuProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EnnfuProtocolDecoder(null); + var decoder = inject(new EnnfuProtocolDecoder(null)); verifyPosition(decoder, text( "Ennfu:354679095321652,041504.00,A,3154.86654,N,11849.08737,E,0.053,,080121,20,3.72,21.4,V0.01")); diff --git a/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java new file mode 100644 index 000000000..50db6c743 --- /dev/null +++ b/src/test/java/org/traccar/protocol/EnvotechProtocolDecoderTest.java @@ -0,0 +1,31 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class EnvotechProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new EnvotechProtocolDecoder(null)); + + verifyPosition(decoder, text( + "$80IVM,03,E002215,E002215,110422061936,672763902,126423,0180,000000,00018600,0.0000'11042206193710406325S03966094E000118*42D6#")); + + verifyPosition(decoder, text( + "$80SLM,62,000F,F015727,020522053200,611000000,000391,C080,000,80028900,85010000'02052205320110399426S03970217E000145*E0C2#")); + + verifyPosition(decoder, text( + "$80SLM,02,F,AB0010,130410155921,431750216,000040,0000,,00000000,'13041015592110476673N10111459E001281*2A"), + position("2010-04-13 15:59:21.000", true, 4.76673, 101.11459)); + + verifyPosition(decoder, text( + "$80SLM,82,F,AB0010,130410155921,431750216,000040,0000,,00000000,'13041015592110476673N10111459E001281@B0,F,C456,038,00,M234567,,,1A2A3A4A5A6A*4E")); + + verifyPosition(decoder, text( + "$80SLM,60,000F,F016109,290322100445,AF2463902,000406,0000,000,00018780,54000000'29032209493500406302S03966062E000348*E637")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/EsealProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EsealProtocolDecoderTest.java index d0d9e3c41..2d9b19b70 100644 --- a/src/test/java/org/traccar/protocol/EsealProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EsealProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class EsealProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EsealProtocolDecoder(null); + var decoder = inject(new EsealProtocolDecoder(null)); verifyPosition(decoder, text( "##S,eSeal,1000821,256,3.0.6,Normal,34,2017-08-31,08:14:40,15,A,25.708828N 100.372870W,10,0,Close,0.71,0:0:3:0,3.8,-73,E##")); diff --git a/src/test/java/org/traccar/protocol/EsealProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/EsealProtocolEncoderTest.java index 88be3ebc9..3ea8de5d6 100644 --- a/src/test/java/org/traccar/protocol/EsealProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/EsealProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class EsealProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new EsealProtocolEncoder(null); + var encoder = inject(new EsealProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/EskyFrameDecoderTest.java b/src/test/java/org/traccar/protocol/EskyFrameDecoderTest.java index c3926c8d7..f808cd4a8 100644 --- a/src/test/java/org/traccar/protocol/EskyFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EskyFrameDecoderTest.java @@ -8,7 +8,7 @@ public class EskyFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EskyFrameDecoder(); + var decoder = inject(new EskyFrameDecoder()); verifyNull( decoder.decode(null, null, binary("00"))); diff --git a/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java index ace55f934..678007f5c 100644 --- a/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/EskyProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class EskyProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new EskyProtocolDecoder(null); + var decoder = inject(new EskyProtocolDecoder(null)); verifyAttribute(decoder, text( "ET;0;860337031066546;R;9+200717114059+41.32053+19.80761+0.30+0+0x2+8+40381744+0+1409+11"), diff --git a/src/test/java/org/traccar/protocol/ExtremTracProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ExtremTracProtocolDecoderTest.java index 29d11e02f..36a26bbe3 100644 --- a/src/test/java/org/traccar/protocol/ExtremTracProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ExtremTracProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ExtremTracProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ExtremTracProtocolDecoder(null); + var decoder = inject(new ExtremTracProtocolDecoder(null)); verifyPosition(decoder, text( "$GPRMC,862106020628733,050859.000,A,1404.8573,N,08710.9967,W,0.00,0,080117,0,,00C8,00218,99,,,,,,0.00")); diff --git a/src/test/java/org/traccar/protocol/FifotrackFrameDecoderTest.java b/src/test/java/org/traccar/protocol/FifotrackFrameDecoderTest.java index 32657b277..417c49de5 100644 --- a/src/test/java/org/traccar/protocol/FifotrackFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FifotrackFrameDecoderTest.java @@ -8,7 +8,7 @@ public class FifotrackFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FifotrackFrameDecoder(); + var decoder = inject(new FifotrackFrameDecoder()); verifyFrame( binary("24243132362c3836393436373034393239303738372c324138432c4130312c2c3139303431333135333235342c412c2d31352e3132373836382c33392e3236323530362c302c3136322c3431352c38303937323234332c302c303030302c30302c302c3634337c337c353141467c424632462c3141337c3446367c3833327c302c312c2a3534"), diff --git a/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java index 6480d1dc4..ec08b432c 100644 --- a/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FifotrackProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class FifotrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FifotrackProtocolDecoder(null); + var decoder = inject(new FifotrackProtocolDecoder(null)); verifyPosition(decoder, buffer( "$$95,866104023192332,1,A03,,210414055249,460|0|25FC|104C,4.18,100,000F,0,A,2,9,22.643175,114.018150*75")); diff --git a/src/test/java/org/traccar/protocol/FifotrackProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/FifotrackProtocolEncoderTest.java index 2da7f0842..c3352f510 100644 --- a/src/test/java/org/traccar/protocol/FifotrackProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/FifotrackProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class FifotrackProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new FifotrackProtocolEncoder(null); + var encoder = inject(new FifotrackProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/FlespiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlespiProtocolDecoderTest.java index 88fdb0959..c794c9094 100644 --- a/src/test/java/org/traccar/protocol/FlespiProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FlespiProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class FlespiProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FlespiProtocolDecoder(null); + var decoder = inject(new FlespiProtocolDecoder(null)); verifyPositions(decoder, request(HttpMethod.POST, "/", buffer("[{\"position.speed\":0,\"position.latitude\":53.90573,\"time.valid.status\":true,\"timestamp\":1506956075,\"position.satellites\":10,\"message.buffered.status\":false,\"business.mode.status\":true,\"gps.status\":true,\"position.longitude\":27.455848,\"position.direction\":0,\"ident\":\"605630\"},{\"siren.status\":false,\"business.mode.status\":true,\"position.satellites\":8,\"timestamp\":1506695785,\"led.status\":false,\"position.latitude\":53.905569,\"position.longitude\":27.455986,\"position.speed\":0,\"gradual.stop.status\":false,\"position.direction\":262.643854,\"hardware.version.enum\":223,\"vehicle.mileage\":160,\"message.buffered.status\":false,\"blinkers.status\":false,\"ident\":\"605630\",\"position.altitude\":233.48,\"immobilizer.status\":false}]"))); diff --git a/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java new file mode 100644 index 000000000..ffb8eb3a9 --- /dev/null +++ b/src/test/java/org/traccar/protocol/FlexApiProtocolDecoderTest.java @@ -0,0 +1,45 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class FlexApiProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new FlexApiProtocolDecoder(null)); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021113001/motion/info\",\"payload\":{\"motion.ts\":1641885877,\"motion.ax\":0.006344,\"motion.ay\":0.289384,\"motion.az\":-0.939156,\"motion.gx\":0.420000,\"motion.gy\":0.420000,\"motion.gz\":-0.280000}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021113001/gnss/info\",\"payload\":{\"gnss.ts\":1639713510,\"gnss.latitude\":30.587509,\"gnss.longitude\":104.053650,\"gnss.altitude\":391,\"gnss.speed\":0,\"gnss.heading\":0,\"gnss.hdop\":1.100000,\"gnss.fix\":4,\"gnss.num_sv\":10}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021113001/cellular1/info\",\"payload\":{\"modem1.ts\":1639713510,\"modem1.imei\":\"863674047326655\",\"modem1.imsi\":\"\",\"modem1.iccid\":\"\",\"modem1.phone_num\":\"\",\"modem1.signal_lvl\":0,\"modem1.reg_status\":0,\"modem1.operator\":\"\",\"modem1.network\":0,\"modem1.lac\":\"\",\"modem1.cell_id\":\"\",\"modem1.rssi\":0,\"modem1.rsrp\":0,\"modem1.rsrq\":0,\"cellular1.status\":2,\"cellular1.ip\":\"0.0.0.0\",\"cellular1.netmask\":\"255.255.255.255\",\"cellular1.gateway\":\"0.0.0.0\",\"cellular1.dns1\":\"0.0.0.0\",\"cellular1.up_at\":602}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102029000003/obd/info\",\"payload\":{\"obd.ts\":1639037377,\"obd.speed\":211,\"obd.f_lvl\":50.196079,\"obd.mil\":0,\"obd.dtcs\":0,\"obd.rpm\":14531.250000,\"obd.e_load\":50.980392,\"obd.c_temp\":118,\"obd.o_temp\":56,\"obd.a_temp\":-40,\"obd.f_press\":48,\"obd.t_pos\":51.764706,\"obd.b_volt\":13.782000,\"obd.up_time\":2265,\"obd.m_dist\":4643,\"obd.m_time\":257,\"obd.d_dist\":200,\"obd.d_time\":771,\"obd.vin\":\"LFV3B28R8A3025310\",\"obd.f_rate\":10,\"obd.t_dist\":4843,\"obd.b_press\":101,\"obd.f_r_press\":48,\"obd.i_temp\":37,\"obd.i_press\":32,\"obd.r_torque\":4128,\"obd.a_torque\":2,\"obd.mf_mon\":1,\"obd.f_s_mon\":0,\"obd.c_c_mon\":0,\"obd.c_mon\":1,\"obd.e_s_mon\":1,\"obd.e_v_s_mon\":1,\"obd.o_s_mon\":1,\"obd.o_s_h_mon\":1}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021111601/obd/info\",\"payload\":{\"obd.ts\":1637225390,\"obd.speed\":0,\"obd.f_lvl\":null,\"obd.odo\":0,\"obd.e_hours\":0,\"obd.ab_level\":null,\"obd.mil\":0,\"obd.dtcs\":null,\"obd.rpm\":0,\"obd.e_load\":null,\"obd.c_temp\":-40,\"obd.o_temp\":-273,\"obd.a_temp\":null,\"obd.f_press\":null,\"obd.t_pos\":0,\"obd.b_volt\":null,\"obd.up_time\":null,\"obd.m_dist\":null,\"obd.m_time\":null,\"obd.d_dist\":null,\"obd.d_time\":null,\"obd.vin\":\"NLVIN123456789ABC\",\"obd.brake\":0,\"obd.parking\":0,\"obd.s_w_angle\":null,\"obd.f_rate\":0,\"obd.f_econ\":0,\"obd.a_pos\":null,\"obd.t_dist\":0,\"obd.b_press\":null,\"obd.f_r_press\":null,\"obd.i_temp\":null,\"obd.i_press\":null,\"obd.r_torque\":null,\"obd.f_torque\":null,\"obd.max_avl_torque\":null,\"obd.a_torque\":-125,\"obd.d_e_f_vol\":null,\"obd.mf_mon\":null,\"obd.f_s_mon\":null,\"obd.c_c_mon\":null,\"obd.c_mon\":null,\"obd.h_c_mon\":null,\"obd.e_s_mon\":null,\"obd.s_a_s_mon\":null,\"obd.a_s_r_mon\":null,\"obd.e_g_s_mon\":null,\"obd.e_g_s_h_mon\":null,\"obd.e_v_s_mon\":null,\"obd.c_s_a_s_mon\":null,\"obd.b_p_c_s_mon\":null,\"obd.dpf_mon\":null,\"obd.n_c_mon\":null,\"obd.nmhc_mon\":null,\"obd.o_s_mon\":null,\"obd.o_s_h_mon\":null,\"obd.pf_mon\":null}}xx")); + + verifyPosition(decoder, text( + "${\"topic\":\"v1/VF3102021111601/gnss/info\",\"payload\":{\"time\":1637225390,\"lat\":30.587942,\"log\":104.053543,\"gnss.altitude\":480.399994,\"gnss.speed\":0,\"gnss.heading\":0,\"gnss.hdop\":0.900000,\"gnss.fix\":4,\"gnss.num_sv\":11}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021111601/motion/info\",\"payload\":{\"motion.ts\":1637225450,\"motion.ax\":0.009272,\"motion.ay\":0.278404,\"motion.az\":-0.941596,\"motion.gx\":0.420000,\"motion.gy\":-0.490000,\"motion.gz\":0.140000}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021111601/sysinfo/info\",\"payload\":{\"sysinfo.ts\":1637224740,\"sysinfo.model_name\":\"310\",\"sysinfo.oem_name\":\"inhand\",\"sysinfo.serial_number\":\"VF3102021111601\",\"sysinfo.firmware_version\":\"VT3_V1.1.32\",\"sysinfo.product_number\":\"FQ58\",\"sysinfo.description\":\"www.inhand.com.cn\"}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021111601/io/info\",\"payload\":{\"io.ts\":1637227722,\"io.AI1\":0,\"io.DI1\":1,\"io.DI2\":0,\"io.DI3\":0,\"io.DI4\":0,\"io.DI1_pullup\":0,\"io.DI2_pullup\":0,\"io.DI3_pullup\":0,\"io.DI4_pullup\":0,\"io.DO1\":0,\"io.DO2\":0,\"io.DO3\":0,\"io.IGT\":1}}xx")); + + verifyAttributes(decoder, text( + "${\"topic\":\"v1/VF3102021111601/cellular1/info\",\"payload\":{\"modem1.ts\":1637225330,\"modem1.imei\":\"863674047324999\",\"modem1.imsi\":\"460111150414721\",\"modem1.iccid\":\"89860319482086580401\",\"modem1.phone_num\":\"\",\"modem1.signal_lvl\":25,\"modem1.reg_status\":1,\"modem1.operator\":\"46011\",\"modem1.network\":3,\"modem1.lac\":\"EA00\",\"modem1.cell_id\":\"E779B81\",\"modem1.rssi\":0,\"modem1.rsrp\":0,\"modem1.rsrq\":0,\"cellular1.status\":3,\"cellular1.ip\":\"10.136.143.193\",\"cellular1.netmask\":\"255.255.255.255\",\"cellular1.gateway\":\"10.64.64.64\",\"cellular1.dns1\":\"223.5.5.5\",\"cellular1.up_at\":450}}xx")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/FlexCommProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlexCommProtocolDecoderTest.java index 3e988ba4f..ed44fc62e 100644 --- a/src/test/java/org/traccar/protocol/FlexCommProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FlexCommProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FlexCommProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FlexCommProtocolDecoder(null); + var decoder = inject(new FlexCommProtocolDecoder(null)); verifyPosition(decoder, text( "7E00865067022408382201705302358271024932258006712785200700022601010224100040002C5002A2210001000000010012342107")); diff --git a/src/test/java/org/traccar/protocol/FlexibleReportProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlexibleReportProtocolDecoderTest.java index 8763887a5..6b289396d 100644 --- a/src/test/java/org/traccar/protocol/FlexibleReportProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FlexibleReportProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FlexibleReportProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FlexibleReportProtocolDecoder(null); + var decoder = inject(new FlexibleReportProtocolDecoder(null)); verifyPosition(decoder, binary( "7d010015875000013001001028fd98991830002e7fffffff0c28fd989903f6540a07f250ed00000f02f2140f5ea20000000000000202d4000a1f8b0100000708ffff")); diff --git a/src/test/java/org/traccar/protocol/FlextrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FlextrackProtocolDecoderTest.java index 0c1c18a0c..6e5ebf4cf 100644 --- a/src/test/java/org/traccar/protocol/FlextrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FlextrackProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class FlextrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FlextrackProtocolDecoder(null); + var decoder = inject(new FlextrackProtocolDecoder(null)); verifyNull(decoder, text( "-1,LOGON,7000000123,8945000000")); diff --git a/src/test/java/org/traccar/protocol/FoxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FoxProtocolDecoderTest.java index 439a5553a..8e62c878e 100644 --- a/src/test/java/org/traccar/protocol/FoxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FoxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FoxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FoxProtocolDecoder(null); + var decoder = inject(new FoxProtocolDecoder(null)); verifyPosition(decoder, text( "<fox><gps id=\"10\" data=\"51,A,010416,085317,4444.4158,N,02025.4466,E,1,182,,1110111111110111 141 0 0 0 0 0 10010000 10142,018C81851800009B\"/></fox>")); diff --git a/src/test/java/org/traccar/protocol/FreedomProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FreedomProtocolDecoderTest.java index c8f7a444b..1163b4e04 100644 --- a/src/test/java/org/traccar/protocol/FreedomProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FreedomProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FreedomProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FreedomProtocolDecoder(null); + var decoder = inject(new FreedomProtocolDecoder(null)); verifyPosition(decoder, text( "IMEI,353358011714362,2014/05/22, 20:49:32, N, Lat:4725.9624, E, Lon:01912.5483, Spd:5.05"), diff --git a/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java index 6a7a15397..a7ce042e5 100644 --- a/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FreematicsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FreematicsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FreematicsProtocolDecoder(null); + var decoder = inject(new FreematicsProtocolDecoder(null)); verifyPositions(decoder, text( "M0ZR4X0#0:204391,11:140221,10:8445000,A:49.215920,B:18.737755,C:410,D:0,E:208,24:1252,20:0;0;0,82:47*B5")); diff --git a/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java b/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java index b8eb3908e..a101ef45d 100644 --- a/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FutureWayFrameDecoderTest.java @@ -8,7 +8,7 @@ public class FutureWayFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FutureWayFrameDecoder(); + var decoder = inject(new FutureWayFrameDecoder()); verifyFrame( binary("343130303030303039424130303030344750533a562c3230303930323039333333332c302e3030303030304e2c302e303030303030452c302e3030302c302e3030300d0a574946493a332c317c39302d36372d31432d46372d32312d36437c353226327c38302d38392d31372d43362d37392d41307c353426337c34302d46342d32302d45462d44442d32417c35380d0a4c42533a3436302c302c34363437353036362c36390d0a36413432"), diff --git a/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java index fbb0a2aba..e529d5c90 100644 --- a/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/FutureWayProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class FutureWayProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new FutureWayProtocolDecoder(null); + var decoder = inject(new FutureWayProtocolDecoder(null)); verifyNull(decoder, text( "410000003F2000020,IMEI:354828100126461,battery level:6,network type:7,CSQ:236F42")); diff --git a/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java new file mode 100644 index 000000000..c8b4e35fe --- /dev/null +++ b/src/test/java/org/traccar/protocol/G1rusProtocolDecoderTest.java @@ -0,0 +1,18 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class G1rusProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new G1rusProtocolDecoder(null)); + + verifyPositions(decoder, binary( + "f84604000d85f5e55298004b012ad7d524003d1d0f50726f6d61205361742031303030201556312e31302656312e312e340a03120fa0142b8475a157050401846dfc060175120a29a10d02440111002100310041005107d10ef8")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java b/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java index 0d3199eab..a5aba3513 100644 --- a/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GalileoFrameDecoderTest.java @@ -10,7 +10,7 @@ public class GalileoFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GalileoFrameDecoder(); + var decoder = inject(new GalileoFrameDecoder()); assertEquals( binary("011780011102e603383633353931303238393630323437043200801c"), diff --git a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java index 66b375b8a..f676b1cc1 100644 --- a/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GalileoProtocolDecoderTest.java @@ -8,12 +8,18 @@ public class GalileoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GalileoProtocolDecoder(null); + var decoder = inject(new GalileoProtocolDecoder(null)); + + verifyNotNull(decoder, binary( + "01006501001c05cf1f8133303032333430363939303130313000004a000062d8f3ee03000b000f85402088970000000602003503333030323334303639393031303130100000207af3d862300cbe08ee00acfaf001330000760634b301350840090a416b2f42920e")); verifyPositions(decoder, binary( "011801018202130338363833343530333230343234323604640010a406207caa9f5b300c830a7901ca0ec802330000000034b802350540003e41703f422b1043234504004600e09000000000a000a100a200a300a400a500a600a700a800a900aa00ab00ac00ad00ae00af00b00000b10000b20000b30000b40000b50000b60000b70000b80000b90000c000000000c100000000c200000000c300000000c400c500c600c700c800c900ca00cb00cc00cd00ce00cf00d000d100d200d4d3140000d60000d70000d80000d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000f400000000f500000000f600000000f700000000f800000000f9000000008960")); verifyPositions(decoder, binary( + "01bf83043200101ee4209832bc62300549589302511aaa013300002e00342e02350440003b41b15d42d50e4326450e0046040050000051000052fc5c5300006100008b009000000000d400000000e201000000e376000000e4efce0100e53b590200e600000000e773000000e800000000e9a002d007ea140000d6021b00f8430220ac760000000000000000043200101de4201232bc62300549589302511aaa013300002e00342e02350440012b41b55d42d40e4326450e0046040050000051000052145d5300006100008b009000000000d400000000e201000000e376000000e4efce0100e53b590200e600000000e773000000e800000000e9a002d007ea140000d6021b00f8430220ac760000000000000000043200101ce4208e2ebc62300549589302511aaa013300002e00342e02350440013b41a95d42cd0e4325450f0046040050000051000052235d5300006100008b009000000000d400000000e201000000e376000000e4efce0100e53b590200e600000000e773000000e802000000e9a002d007ea140000d6021b00f8430220ac760000000000000000043200101be4208b2ebc62300549589302511aaa013300002e00342e02350440013b41a45d42cd0e432545090046040050000051000052115d5300006100008b009000000000d400000000e201000000e375000000e48ac90100e53a590200e673000000e773000000e806000000e9a002d007ea140000d6021b00f8430220ac760000000000000000043200101ae420642ebc62300549589302511aaa013300002e00342e02350440013b419f5d42cd0e4324450b00460600500000519313521c5d5300006100008b009000000000d400000000e201000000e300000000e406000000e5c5580200e673000000e700000000e801000000e9a002d007ea140000d6021b00f8430220ac7600000000000000000432001019e420632ebc62300549589302511aaa013300002e00342e02350440013b41725d42cd0e4324450b0046060050000051ab1352035d5300006100008b009000000000d400000000e201000000e300000000e406000000e5c5580200e673000000e700000000e8d6021b00e9a002d007ea140000d6021b00f8430220ac7600000000000000000432001018e4205c2ebc62300549589302511aaa013300002e00342e02350440013b41955d42cd0e4324450a00460400500000510000520b5d5300006100008b009000000000d400000000e201000000e30d000000e4a4350000e5c5580200e600000000e700000000e8d6021b00e9a002d007ea140000d6021b00f8430220ac76000000000000000099f3")); + + verifyPositions(decoder, binary( "017583018202120338363833343530333230363635373304520010384520c850975b300cc03a910107cbf9023365000607341300350640012a41236a4215104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4993b0500d64100d70000d8be02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000018202120338363833343530333230363635373304520010394520c950975b300cab3a91010ecbf902336000be06341300350640012a41266a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d49b3b0500d64100d70000d8bc02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103a4520ca50975b300c953a910113cbf9023358008f06341300350640012a41206a4215104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d49e3b0500d64100d70000d8ba02d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103b45204251975b300c6d3a91011dcbf9023300008a06341300350640013a41726a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4a33b0500d64800d70000d80003d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f3000000000182021203383638333435303332303636353733045200103c4520bb51975b300c6d3a91011dcbf9023300008a06341300350640013a41816a4216104329450400460020500000510000520000530000540000550000c000000000c100000000c44bc500c6ffc700c800c900ca00cb00d4a33b0500d64800d70000d80003d90000da0000db00000000dc00000000dd00000000de00000000df00000000f000000000f100000000f200000000f300000000e007")); verifyNull(decoder, binary( diff --git a/src/test/java/org/traccar/protocol/GalileoProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/GalileoProtocolEncoderTest.java index b25100c48..29fe4cc94 100644 --- a/src/test/java/org/traccar/protocol/GalileoProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/GalileoProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class GalileoProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new GalileoProtocolEncoder(null); + var encoder = inject(new GalileoProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/GatorProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GatorProtocolDecoderTest.java index 24686e220..bfb33de22 100644 --- a/src/test/java/org/traccar/protocol/GatorProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GatorProtocolDecoderTest.java @@ -17,7 +17,7 @@ public class GatorProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GatorProtocolDecoder(null); + var decoder = inject(new GatorProtocolDecoder(null)); verifyAttributes(decoder, binary( "242480002600341cad190917022021812497260280594200000000c047010000135400009bb600ff00b90d")); diff --git a/src/test/java/org/traccar/protocol/GenxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GenxProtocolDecoderTest.java index 382c974ce..67a730f97 100644 --- a/src/test/java/org/traccar/protocol/GenxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GenxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GenxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GenxProtocolDecoder(null); + var decoder = inject(new GenxProtocolDecoder(null)); decoder.setReportColumns("28,2,3,4,13,17,10,23,27,11,7,8,46,56,59,70,74,75,77,89,90,93,99,107,112,113,114,176,175,178,181,182"); diff --git a/src/test/java/org/traccar/protocol/Gl100ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl100ProtocolDecoderTest.java index 50f993839..31ae1d5e8 100644 --- a/src/test/java/org/traccar/protocol/Gl100ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl100ProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Gl100ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gl100ProtocolDecoder(null); + var decoder = inject(new Gl100ProtocolDecoder(null)); verifyPosition(decoder, text( "+RESP:GTLGL,359464030492644,1,2,1,0,0.4,0,299.7,1,5.455551,51.449776,20160311083229,0204,0016,03EC,BD94,00,0036,0102090501")); diff --git a/src/test/java/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java index b8ce8af5d..cad70c35b 100644 --- a/src/test/java/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200BinaryProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Gl200BinaryProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gl200BinaryProtocolDecoder(null); + var decoder = inject(new Gl200BinaryProtocolDecoder(null)); verifyPosition(decoder, binary( "2b4556542d00fc1fbf0063450102020956325403000343056437f8220700000200000000010000160100f2007eff75a1f0025c6b1a07e1080108241a02680003189c1ac500000000000002100800000000000000000007e1080108241a19e24e4e0d0a")); diff --git a/src/test/java/org/traccar/protocol/Gl200FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200FrameDecoderTest.java index 17eed8a59..51816222d 100644 --- a/src/test/java/org/traccar/protocol/Gl200FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200FrameDecoderTest.java @@ -10,7 +10,7 @@ public class Gl200FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gl200FrameDecoder(); + var decoder = inject(new Gl200FrameDecoder()); assertEquals( binary("2b4c474e00ff0026fe110b07020106563454040d054905000007e4031911213905083abd0d0a"), diff --git a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java index 8978f64e5..ef82a11a2 100644 --- a/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gl200TextProtocolDecoderTest.java @@ -9,7 +9,22 @@ public class Gl200TextProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gl200TextProtocolDecoder(null); + var decoder = inject(new Gl200TextProtocolDecoder(null)); + + verifyAttribute(decoder, buffer( + "+RESP:GTDAR,F10406,865284049582228,,4,0,,,1,18.5,0,129.4,114.015430,22.537279,20210922004634,0460,0000,27BD,0DFC,,,,20210922004635,082B$"), + "warningType", 4); + + verifyAttribute(decoder, buffer( + "+RESP:GTNMR,423033,355197370058831,,0,0,0,1,0,0.0,298,182.7,-79.257983,43.875152,20220627132020,,,,,15,0,74,20220627144928,03CF$"), + Position.KEY_BATTERY_LEVEL, 74); + + verifyPosition(decoder, buffer( + "+RESP:GTFRI,5E0100,861971050039361,,,,10,1,1,10.4,140,196.9,-80.709946,35.016525,20220302220944,0310,0260,1CE9,52A1,00,0.0,,,,,420000,,,,20220302220948,1B0B$")); + + verifyAttribute(decoder, buffer( + "+RESP:GTFRI,423031,866873025895726,,0,1,1,0,1,16,0.0,351,51.6,121.391063,31.164633,20181212072535,460,00,1877,DAE,00,3,85,20181212072535,002C$"), + Position.KEY_BATTERY_LEVEL, 85); verifyAttributes(decoder, buffer( "+RESP:GTINF,DC0103,865284049247079,gv600mg,21,89883070000007211665,22,0,11,12913,12917,4.26,0,1,,,20210216154607,1,79,,01,00,,,20210216104606,1EBE$")); diff --git a/src/test/java/org/traccar/protocol/GlobalSatProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GlobalSatProtocolDecoderTest.java index 3f5296f4b..e244a835d 100644 --- a/src/test/java/org/traccar/protocol/GlobalSatProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GlobalSatProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GlobalSatProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GlobalSatProtocolDecoder(null); + var decoder = inject(new GlobalSatProtocolDecoder(null)); verifyNull(decoder, text( "GSh,131826789036289,3,M,ea04*3d")); diff --git a/src/test/java/org/traccar/protocol/GlobalSatProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/GlobalSatProtocolEncoderTest.java index ae4b52167..9001c4bf3 100644 --- a/src/test/java/org/traccar/protocol/GlobalSatProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/GlobalSatProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class GlobalSatProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeAlarmDismiss() { + public void testEncodeAlarmDismiss() throws Exception { - var encoder = new GlobalSatProtocolEncoder(null); + var encoder = inject(new GlobalSatProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -22,9 +22,9 @@ public class GlobalSatProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeOutputControl() { + public void testEncodeOutputControl() throws Exception { - var encoder = new GlobalSatProtocolEncoder(null); + var encoder = inject(new GlobalSatProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java index 1dd5c2542..730d4bb60 100644 --- a/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GlobalstarProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class GlobalstarProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GlobalstarProtocolDecoder(null); + var decoder = inject(new GlobalstarProtocolDecoder(null)); verifyNull(decoder, request(HttpMethod.POST, "/", buffer( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", @@ -29,7 +29,7 @@ public class GlobalstarProtocolDecoderTest extends ProtocolTest { "<esn>0-2682225</esn>", "<unixTime>1585105370</unixTime>", "<gps>N</gps>", - "<payload length=\"9\" source=\"pc\" encoding=\"hex\">0x8EFE2D97DDEA420018</payload>", + "<payload length=\"9\" source=\"pc\" encoding=\"hex\">0x00C583EACD37210A00</payload>", "</stuMessage>", "</stuMessages>"))); diff --git a/src/test/java/org/traccar/protocol/GnxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GnxProtocolDecoderTest.java index 8bd5e2bd5..592c2de91 100644 --- a/src/test/java/org/traccar/protocol/GnxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GnxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GnxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GnxProtocolDecoder(null); + var decoder = inject(new GnxProtocolDecoder(null)); verifyPosition(decoder, text( "$GNX_MIF,865733022354161,143,0,172642,180316,172642,180316,1,13.034581,N,080.234521,E,0,05396274,ROUTE_2#########,Deo ############,GNX04008,B0*")); diff --git a/src/test/java/org/traccar/protocol/GoSafeProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GoSafeProtocolDecoderTest.java index bb79f4f25..71ffbb587 100644 --- a/src/test/java/org/traccar/protocol/GoSafeProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GoSafeProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class GoSafeProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GoSafeProtocolDecoder(null); + var decoder = inject(new GoSafeProtocolDecoder(null)); verifyPositions(decoder, false, text( "*GS06,357330050846344,RST#")); diff --git a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java index bae187959..a6e3f2d69 100644 --- a/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GotopProtocolDecoderTest.java @@ -2,17 +2,29 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class GotopProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GotopProtocolDecoder(null); + var decoder = inject(new GotopProtocolDecoder(null)); verifyNull(decoder, text( "")); - + + verifyAttribute(decoder, text( + "867688033841044,ALM-B1-1,A,DATE:190622,TIME:144956,LAT:22.7193976N,LON:114.3878200E,Speed:000.1,100-22,03.72"), + Position.KEY_ALARM, Position.ALARM_GEOFENCE_ENTER); + + verifyAttribute(decoder, text( + "860264050778076,CMD-KEY,V,DATE:220516,TIME:090224,LAT:48.7592616N,LON:003.4658121W,Speed:000.0,057-21,01.60"), + Position.KEY_ALARM, Position.ALARM_SOS); + + verifyPosition(decoder, text( + "860264050778076,CMD-T,A,DATE:220516,TIME:100627,LAT:48.7636978N,LON:003.4652398W,Speed:051.4,077-24,01.00,WIFI:{84-a0-6e-94-42-5e&-47,b2-22-7a-56-5a-2a&-48,b4-b0-24-09-91-d4&-76,18-3c-b7-1f-da-67&-83,08-86-3b-94-78-44&-85,40-24-b2-c5-0f-5e&-87,b0-e5-ed-4e-06-61&-87,60-1d-9d-a6-d2-5d&-88,14-eb-b6-a5-55-8c&-88,40-18-b1-d7-28-54&-88},BLE:{1f-cf-4d-3c-61-bf&-91,39-82-d0-ba-34-69&-57,df-3a-31-ac-ad-72&-73,7c-d9-f4-11-0b-a0&-78,03-b5-9f-45-bd-0d&-88}")); + verifyNull(decoder, text( "353327020412763,CMD-X")); diff --git a/src/test/java/org/traccar/protocol/Gps056FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Gps056FrameDecoderTest.java index f6524f82b..cb75b4035 100644 --- a/src/test/java/org/traccar/protocol/Gps056FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gps056FrameDecoderTest.java @@ -10,7 +10,7 @@ public class Gps056FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gps056FrameDecoder(); + var decoder = inject(new Gps056FrameDecoder()); assertEquals( binary("242435314750534c5f30323836323436323033333738323934361905110f160b0b7710584e1cbd1b9b4500005b100300fb0a071700ffff23"), diff --git a/src/test/java/org/traccar/protocol/Gps056ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gps056ProtocolDecoderTest.java index 01fa98ba4..ac3738644 100644 --- a/src/test/java/org/traccar/protocol/Gps056ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gps056ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Gps056ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gps056ProtocolDecoder(null); + var decoder = inject(new Gps056ProtocolDecoder(null)); verifyNull(decoder, buffer( "$$25LOGN_118624620337829462.1#")); diff --git a/src/test/java/org/traccar/protocol/Gps103ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gps103ProtocolDecoderTest.java index 79dc8ab7b..cf5786d75 100644 --- a/src/test/java/org/traccar/protocol/Gps103ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gps103ProtocolDecoderTest.java @@ -9,7 +9,11 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gps103ProtocolDecoder(null); + var decoder = inject(new Gps103ProtocolDecoder(null)); + + verifyAttribute(decoder, text( + "imei:865456055519122,sensor alarm,2208011920,,L,;"), + Position.KEY_ALARM, Position.ALARM_VIBRATION); verifyPosition(decoder, text( "imei:864035050002451,tracker,201223064947,,F,064947,A,1935.70640,N,09859.94436,W,0.025,;")); @@ -155,7 +159,7 @@ public class Gps103ProtocolDecoderTest extends ProtocolTest { "359586015829802")); // No GPS signal - verifyNull(decoder, text( + verifyNotNull(decoder, text( "imei:359586015829802,tracker,000000000,13554900601,L,;")); verifyPosition(decoder, text( diff --git a/src/test/java/org/traccar/protocol/Gps103ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Gps103ProtocolEncoderTest.java index 5edfbf629..f6cbe6d17 100644 --- a/src/test/java/org/traccar/protocol/Gps103ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Gps103ProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class Gps103ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodePositionPeriodic() throws Exception { - var encoder = new Gps103ProtocolEncoder(null); + var encoder = inject(new Gps103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -25,7 +25,7 @@ public class Gps103ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeCustom() throws Exception { - var encoder = new Gps103ProtocolEncoder(null); + var encoder = inject(new Gps103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/GpsGateProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GpsGateProtocolDecoderTest.java index c935fb3c2..a1f81b329 100644 --- a/src/test/java/org/traccar/protocol/GpsGateProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GpsGateProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GpsGateProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GpsGateProtocolDecoder(null); + var decoder = inject(new GpsGateProtocolDecoder(null)); verifyPosition(decoder, text( "$FRCMD,0097,_SendMessage,,7618.51990,S,4002.26182,E,350.0,1.08,0.0,250816,183522.000,0*7F")); diff --git a/src/test/java/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java index c0b4966a8..bc7910779 100644 --- a/src/test/java/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GpsMarkerProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class GpsMarkerProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GpsMarkerProtocolDecoder(null); + var decoder = inject(new GpsMarkerProtocolDecoder(null)); verifyPosition(decoder, text( "$GM23D863071014445404T260816142611N55441051E037325071033063C0530304#")); diff --git a/src/test/java/org/traccar/protocol/GpsmtaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GpsmtaProtocolDecoderTest.java index 7170718f6..d1326515f 100644 --- a/src/test/java/org/traccar/protocol/GpsmtaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GpsmtaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GpsmtaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GpsmtaProtocolDecoder(null); + var decoder = inject(new GpsmtaProtocolDecoder(null)); verifyPosition(decoder, text( "3085a94ef459 1446536867 49.81621 24.054207 1 0 22 0 10 12 24 0 0")); diff --git a/src/test/java/org/traccar/protocol/GranitFrameDecoderTest.java b/src/test/java/org/traccar/protocol/GranitFrameDecoderTest.java index b4e24f961..a61e708f7 100644 --- a/src/test/java/org/traccar/protocol/GranitFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GranitFrameDecoderTest.java @@ -10,7 +10,7 @@ public class GranitFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GranitFrameDecoder(); + var decoder = inject(new GranitFrameDecoder()); assertEquals( binary("2b525243427e1a003e2934757c57b8b03c38d279b4e61e9bd7006b000000001c00002a4533"), diff --git a/src/test/java/org/traccar/protocol/GranitProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/GranitProtocolDecoderTest.java index 7fd5ffe0e..d2e181e09 100644 --- a/src/test/java/org/traccar/protocol/GranitProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/GranitProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class GranitProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new GranitProtocolDecoder(null); + var decoder = inject(new GranitProtocolDecoder(null)); verifyPositions(decoder, binary( "2b444441547e8400c500040130050c43495808002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000008002839aee3150200000000640000000000000014002a37420d0a")); diff --git a/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java index 68c9b8219..ce2768448 100644 --- a/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gs100ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Gs100ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gs100ProtocolDecoder(null); + var decoder = inject(new Gs100ProtocolDecoder(null)); verifyNull(decoder, binary( "474C490F383632343632303332353036373030133839333831303131363039313838343837323546084657312E302E3236")); diff --git a/src/test/java/org/traccar/protocol/Gt02ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt02ProtocolDecoderTest.java index 9d36ef346..25f59a948 100644 --- a/src/test/java/org/traccar/protocol/Gt02ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt02ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Gt02ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gt02ProtocolDecoder(null); + var decoder = inject(new Gt02ProtocolDecoder(null)); verifyAttributes(decoder, binary( "6868150000035889905895258400831c07415045584f4b210d0a")); diff --git a/src/test/java/org/traccar/protocol/Gt06FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06FrameDecoderTest.java index 059674398..a9d011277 100644 --- a/src/test/java/org/traccar/protocol/Gt06FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06FrameDecoderTest.java @@ -8,7 +8,7 @@ public class Gt06FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gt06FrameDecoder(); + var decoder = inject(new Gt06FrameDecoder()); verifyFrame( binary("787803691604130318491475905BD30E25001E10BBF7635D14759006E626560501CC0028660F213228660F1F2828660EA81E286610731428660F20140D0A"), diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java index d2d090c04..23c29b0d3 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gt06ProtocolDecoder(null); + var decoder = inject(new Gt06ProtocolDecoder(null)); verifyNull(decoder, binary( "787805120099abec0d0a")); @@ -17,6 +17,46 @@ public class Gt06ProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, binary( "78780D01086471700328358100093F040D0A")); + verifyPosition(decoder, binary( + "78781511170103100e1f9904efe30400a97f88003410ffdd000d0a")); + + verifyAttribute(decoder, binary( + "787819a5012ed0000075df000000000098661502050413000019a12b0d0a"), + Position.KEY_ALARM, Position.ALARM_TAMPERING); + + verifyAttribute(decoder, binary( + "7878131302801900002e42016f000000003a0177ef180d0a"), + Position.KEY_POWER, 3.67); + + verifyAttribute(decoder, binary( + "78782526160913063918c002780fab0c44750f00040008027f14084c0038420600030c020007398e0d0a"), + Position.KEY_ALARM, Position.ALARM_TAMPERING); + + verifyAttribute(decoder, binary( + "7979000d940516090908081c030defbd2d0d0a"), + Position.KEY_DOOR, true); + + verifyAttribute(decoder, binary( + "78782516160908063736c0006e70110442fc800000000800000000000000000300002512000473fb0d0a"), + Position.KEY_ALARM, Position.ALARM_TAMPERING); + + verifyPosition(decoder, binary( + "78782e2416061a103600c80275298404a0a24000184602d4023a49006f060104ed01940000086508004139765000be7d640d0a")); + + verifyAttribute(decoder, binary( + "79790019941b524649443a3030384642324245424133390d0a000c14930d0a"), + "serial", "RFID:008FB2BEBA39"); + + verifyAttribute(decoder, binary( + "7878241216040e102c22cf00915ffb04c6016300195a02d402283b00753f400571040001dda4880d0a"), + Position.KEY_IGNITION, false); + + verifyNotNull(decoder, binary( + "787831241603060c231e000194620213ee00606a3413ee0060692e000000000000000000000000000000000000000000003a0cb70d0a")); + + verifyNotNull(decoder, binary( + "78783B2810010D02020201CC00287D001F713E287D001F7231287D001E232D287D001F4018000000000000000000000000000000000000FF00020005B14B0D0A")); + verifyNotNull(decoder, binary( "78782111150b0b022c30c804b7af7808810cb0003c00012e02d075df0084890c000679950d0a")); diff --git a/src/test/java/org/traccar/protocol/Gt06ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Gt06ProtocolEncoderTest.java index 79165d9dc..13463ea39 100644 --- a/src/test/java/org/traccar/protocol/Gt06ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt06ProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class Gt06ProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new Gt06ProtocolEncoder(null); + var encoder = inject(new Gt06ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Gt30ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Gt30ProtocolDecoderTest.java index 24addc8b4..48c4306d6 100644 --- a/src/test/java/org/traccar/protocol/Gt30ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Gt30ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Gt30ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Gt30ProtocolDecoder(null); + var decoder = inject(new Gt30ProtocolDecoder(null)); verifyPosition(decoder, text( "$$005D3037811014 9955102834.000,A,3802.8629,N,02349.7163,E,0.00,,060117,,*13|1.3|26225BD")); diff --git a/src/test/java/org/traccar/protocol/H02FrameDecoderTest.java b/src/test/java/org/traccar/protocol/H02FrameDecoderTest.java index 2294b773b..c61c0f0c9 100644 --- a/src/test/java/org/traccar/protocol/H02FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/H02FrameDecoderTest.java @@ -10,7 +10,7 @@ public class H02FrameDecoderTest extends ProtocolTest { @Test public void testDecodeShort() throws Exception { - var decoder = new H02FrameDecoder(0); + var decoder = inject(new H02FrameDecoder(0)); assertEquals( binary("2a48512c3335353438383032303131333931312c56312c3031323934352c412c353233312e37393238332c4e2c30313332342e31303731382c452c302e30352c302c3137303231372c464646464646464623"), @@ -37,7 +37,7 @@ public class H02FrameDecoderTest extends ProtocolTest { @Test public void testDecodeLong() throws Exception { - var decoder = new H02FrameDecoder(0); + var decoder = inject(new H02FrameDecoder(0)); assertEquals( binary("24410600082621532131081504419390060740418306000000fffffbfdff0015060000002c02dc0c000000001f"), @@ -48,7 +48,7 @@ public class H02FrameDecoderTest extends ProtocolTest { @Test public void testDecodeAlternative() throws Exception { - var decoder = new H02FrameDecoder(0); + var decoder = inject(new H02FrameDecoder(0)); assertEquals( binary("2a48512c343230363131393133302c4e42522c3130323430332c3233382c312c302c372c313131312c323236342c36332c313131312c323236352c35382c313131312c323236362c35302c313131312c333133352c33372c313131312c3630352c33332c313131312c343932302c33302c313131312c3630372c32382c3131303131372c46464646444646462c3623"), diff --git a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java index a0462e675..e68f0814c 100644 --- a/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/H02ProtocolDecoderTest.java @@ -9,7 +9,13 @@ public class H02ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new H02ProtocolDecoder(null); + var decoder = inject(new H02ProtocolDecoder(null)); + + verifyPosition(decoder, buffer( + "*HQ,3177718238,V6,002926,V,3514.4088,N,9733.2842,W,0.00,0.00,151222,FFF7FBFF,310,260,32936,13641,8944501311217563382F,#")); + + verifyPosition(decoder, buffer( + "*HQ,5905101893,V1,105759,A,37573392,S,145037022,E,000.00,173,280122,FF7FFBFF,,,9059e2c,8232,4#")); verifyPosition(decoder, buffer( "*HQ,4970105243,V1,104000,A,2235.1777,N,11357.8913,E,000.27,235,130721,FFFFFBFF,460,11,d18e105,7752,6#")); @@ -267,7 +273,7 @@ public class H02ProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeStatus() throws Exception { - var decoder = new H02ProtocolDecoder(null); + var decoder = inject(new H02ProtocolDecoder(null)); verifyAttribute(decoder, buffer( "*HQ,2705171109,V1,213324,A,5002.5849,N,01433.7822,E,0.00,000,140613,FFFFFFFF#"), diff --git a/src/test/java/org/traccar/protocol/H02ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/H02ProtocolEncoderTest.java index 3ed0a7e91..1be9421bb 100644 --- a/src/test/java/org/traccar/protocol/H02ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/H02ProtocolEncoderTest.java @@ -1,5 +1,6 @@ package org.traccar.protocol; +import org.junit.Before; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; @@ -14,10 +15,15 @@ import static org.junit.Assert.assertEquals; public class H02ProtocolEncoderTest extends ProtocolTest { - private H02ProtocolEncoder encoder = new H02ProtocolEncoder(null); - private Date time = Date.from( + private H02ProtocolEncoder encoder; + private final Date time = Date.from( LocalDateTime.of(LocalDate.now(), LocalTime.of(1, 2, 3)).atZone(ZoneOffset.systemDefault()).toInstant()); + @Before + public void before() throws Exception { + encoder = inject(new H02ProtocolEncoder(null)); + } + @Test public void testAlarmArmEncode() { diff --git a/src/test/java/org/traccar/protocol/HaicomProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HaicomProtocolDecoderTest.java index 9d80940ea..9d26d56c3 100644 --- a/src/test/java/org/traccar/protocol/HaicomProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HaicomProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class HaicomProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HaicomProtocolDecoder(null); + var decoder = inject(new HaicomProtocolDecoder(null)); verifyPosition(decoder, text( "$GPRS012497007097169,T100001,150618,230031,5402267400332464,0004,2014,000001,,,1,00#V040*"), diff --git a/src/test/java/org/traccar/protocol/HomtecsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HomtecsProtocolDecoderTest.java index 192aa3010..8fe4d2c8b 100644 --- a/src/test/java/org/traccar/protocol/HomtecsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HomtecsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class HomtecsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HomtecsProtocolDecoder(null); + var decoder = inject(new HomtecsProtocolDecoder(null)); verifyNull(decoder, text( "MDS0001_R6d1821f7,170323,143601.00,04,,,,,,,,,")); diff --git a/src/test/java/org/traccar/protocol/HoopoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HoopoProtocolDecoderTest.java index 35d0f1423..ed7b0534b 100644 --- a/src/test/java/org/traccar/protocol/HoopoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HoopoProtocolDecoderTest.java @@ -8,11 +8,14 @@ public class HoopoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HoopoProtocolDecoder(null); + var decoder = inject(new HoopoProtocolDecoder(null)); verifyPosition(decoder, text( "{ \"deviceId\": \"BCCD0654\", \"assetName\": \"BCCD0654\", \"assetType\": \"???? ?????? - ??? 8\", \"eventData\": { \"latitude\": 31.97498, \"longitude\": 34.80802, \"locationName\": \"\", \"accuracyLevel\": \"High\", \"eventType\": \"Arrival\", \"batteryLevel\": 100, \"receiveTime\": \"2021-09-20T18:52:32Z\" }, \"eventTime\": \"2021-09-20T08:52:02Z\", \"serverReportTime\": \"0001-01-01T00:00:00Z\" }")); + verifyPosition(decoder, text( + "{\"deviceId\":\"BCCD2559\",\"assetName\":\"BCCD2559\",\"assetType\":\"Standard\",\"eventData\":{\"latitude\":32.04746,\"longitude\":34.75843,\"locationName\":\"\",\"accuracyLevel\":\"?????\",\"eventType\":\"InMotion\",\"batteryLevel\":100,\"receiveTime\":\"2022-01-20T08:02:44Z\"},\"address\":{\"line1\":\"????????????70\",\"city\":\"??????-???\",\"stateOrProvince\":\"\",\"postalCode\":\"\",\"countryCode\":\"IL\"},\"movement\":{\"Speed\":1},\"eventTime\":\"2022-01-20T05:55:27Z\",\"serverReportTime\":\"2022-01-20T08:02:48Z\"}")); + } } diff --git a/src/test/java/org/traccar/protocol/HuaShengFrameDecoderTest.java b/src/test/java/org/traccar/protocol/HuaShengFrameDecoderTest.java index 228f41ee8..991e0b36d 100644 --- a/src/test/java/org/traccar/protocol/HuaShengFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuaShengFrameDecoderTest.java @@ -10,7 +10,7 @@ public class HuaShengFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HuaShengFrameDecoder(); + var decoder = inject(new HuaShengFrameDecoder()); assertEquals( binary("c0010c00120060000000000004000600010100c0"), diff --git a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java index 74671b845..7002d7e88 100644 --- a/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuaShengProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class HuaShengProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HuaShengProtocolDecoder(null); + var decoder = inject(new HuaShengProtocolDecoder(null)); verifyNull(decoder, binary( "c00000007eaa000000000000cb8000000032313130313030393238323800e9abafffd615d2000000000008000000010015ffffff0000000000000004e7ffffffffff0005000a10080001d5ab000900154b4e4142323531324d4b54353638363630000f00133335343434343131353130333138380014000b00000000000000c0")); diff --git a/src/test/java/org/traccar/protocol/HuabaoFrameDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoFrameDecoderTest.java index d4789032d..6b902fb46 100644 --- a/src/test/java/org/traccar/protocol/HuabaoFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoFrameDecoderTest.java @@ -8,7 +8,7 @@ public class HuabaoFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HuabaoFrameDecoder(); + var decoder = inject(new HuabaoFrameDecoder()); verifyFrame( binary("283734303139303331313138352c312c3030312c454c4f434b2c332c35323934333929"), diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java index bf94c5dc5..e91c84d79 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolDecoderTest.java @@ -9,11 +9,59 @@ public class HuabaoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HuabaoProtocolDecoder(null); + var decoder = inject(new HuabaoProtocolDecoder(null)); + + verifyNull(decoder, binary( + "7e010200204f07788ef67601824f4459344f544d314d4459774d4441314d444977626d5633553235536457786cba7e")); + + verifyPosition(decoder, binary( + "7e0200004107904226220608ca0000010000000010031dac0d004864f30000000000002212291003220104000179a7300107310100eb17000300e151000300e304000b00d801041edf340000306b007e")); + + verifyPosition(decoder, binary( + "7E020000FE069223000241002E00000000000C0003015A98F806C8A1260013000000E622082617464401040000017F02020001030200002504000000002A0200002B0400000000300117310112E306000005890000F3B4000202000000030202F2000402375F00050400000000000602000C000702000C000801320009020072000B020035000C020050000D020176000E0122000F018A00501B4C46504D34414350584731413337303937000000000000000000000052040000000C01000200010101040000000001020200010103040000000101040203E7010C02000E010D020000010E02059B010F020072011002387001110200000112020000011302000001140200000116020000D17E")); + + verifyPositions(decoder, binary( + "7E021001A2010036526447000A3B00000000000000010158F52206C916B0000000000000161118110121661D019431000B0000CF47006931000B000058A4006930000B0000882400693B00000000000000010158F52206C916B0000000000000161118110122661D019431000B0000CF47006931000B000058A4006930000B0000882400693B00000000000000010158F52206C916B0000000000000161118110123661D019431000B0000CF47006931000B000058A4006930000B0000882400693B00000000000000010158F52206C916B0000000000000161118110124661D019431000B0000CF47006931000B000058A4006930000B0000882400691C00000000000000010158F52206C916B00000000000001611181101253B00000000000000010158F52206C916B0000000000000161118110126661D019431000B0000CF47006931000B000058A4006930000B0000882400693B00000000000000010158F52206C916B0000000000000161118110127661D019431000B0000CF47006931000B000058A4006930000B0000882400691C00000000000000010158F52206C916B0000000000000161118110128F57E")); + + verifyAttribute(decoder, binary( + "7e02000042012291302260198f00000000800c012300d2651605ff3188001e0000000022102510310003020000a70400000000ac040000012ce5020003e60b03bc572900ce2eef183200e7030000005c7e"), + Position.PREFIX_TEMP + 3, -17.094117647058823); + + verifyAttribute(decoder, binary( + "7E0200008201215233475100030000000000000003015A7F6106CF8CEC003D0000000021071311481901040000005630011931011AE10200755D3D0601CC0024990A7dA0032301CC002499099B2941FC01CC002499099B29430B01CC0024990A7dA0290601CC0024990A7dA015FD01CC0026220994506BFFFE157C010400000001F10C000000000000000000000000997E"), + Position.KEY_ALARM, Position.ALARM_ACCELERATION); + + verifyAttribute(decoder, binary( + "7e020000340551231425560568000000000400000201618a9706c320e100410000002722060816261501040000015d300115310105eb0a000300e164000300e301957e"), + Position.KEY_BATTERY_LEVEL, 100); + + verifyNull(decoder, buffer( + "(794104004140,1,001,BASE,2,TIME)")); + + verifyAttribute(decoder, binary( + "7E02000053200002604323004800000000000C00000158B91406CB7007006B00000000220512101138010400000F2803020000250400000000300114310100E30100D50E0100026043232795980277530030E50400000000E7020FC8E8020E83AB7E"), + "lock1Locked", false); + + verifyPosition(decoder, binary( + "7E0900005A4E5DE66FBA2200C4F02204280610090002010D052B0150052C0400129009052D016B052E014F05300231BA053502000005360203B8053802000005390200AD053D0201EA05440150054604009899D90545040000001E000C00030160A85C06D1C1389C7E")); verifyNull(decoder, binary( "7E01000021013345678906000F002C012F373031313142534A2D4D3742203030303030303001D4C1423838383838B47E")); + verifyAttribute(decoder, binary( + "7E020000480123456789010013000000800000000301597BC506CBFF6600EB00000155210726203531010400000000EB24000C00B28986047701207027150200060089FFFFEFFF0004002D0E10000600C5FFFFFFEF697E"), + Position.KEY_ALARM, Position.ALARM_LOW_BATTERY); + + verifyAttribute(decoder, binary( + "7e0200008e01917159043700b300000000800000030158990606ca0fd7000400000000211129111705010400000000cc14383938363037423831303230393031363239363830010d8001aa81021388820200858301148401aa8502189b8601338702007e8801338901148a0200998b1131323334353637383941424344454647488c04000200a88d0200828e0114a00b50353338662c5530323966037e"), + Position.KEY_DTCS, "P538f U029f"); + + verifyPosition(decoder, binary( + "7E020000830191715904370A2E00000000800000030158991806CA0FEB00040000010D211108194050010400000003CC14383938363034373831303230373033313836303830011A8001AA810213888202007A8301148401AA8502189B8601338702007D028801338901148A0200998B1131323334353637383941424344454647488C04000200A88D0200828E0114A0002E7E")); + + verifyPosition(decoder, binary( + "7e0200007c0191718447540dcd000000008000000b029eabc204ba78510004000000042111182321120104000017f6cc14383933303237323037303339333033383732373130011d800134810204718202008283010e84017b85021ae986012f870201788901038b114a4e31424a314352364b573333363533358c040008dcb68d02018c8e013da000c07e")); + verifyNotNull(decoder, binary( "7e207002940121523001530047210927151009000e002d80ac210927151010000e002d80ab210927151011000e002d80ac210927151012000e002e80ab210927151013000e002d80ab210927151014000e002d80ab210927151015000e002d80ab210927151016000e002d80aa210927151017000e002e80ab210927151018000e002d80ab210927151019000e002e80ac210927151020000e002d80ab210927151021000e002d80ab210927151022000d002d80ac210927151023000e002d80ac210927151024000e002e80ab210927151025000e002e80b0210927151026000e002e80ab210927151027000e002d80ab210927151028000e002e80b0210927151029000e002d80b0210927151030000e002e80ab210927151031000e002d80ab210927151032000e002d80aa210927151033000e002d80ab210927151034000e002d80ab210927151035000e002d80ab210927151036000e002d80ab210927151037000e002d80ab210927151038000e002d80b0210927151039000d002e80aa210927151040000e002d80ab210927151041000e002d80a5210927151042000e002e80ab210927151043000e002d80aa210927151044000e002d80ab210927151045000e002d80ab210927151046000e002d80ac210927151047000e002e80ab210927151048000e002e80a5210927151049000e002d80ab210927151050000e002d80ab210927151051000e002d80ab210927151052000e002d80ab210927151053000e002d80aa210927151054000e002e80b0210927151055000e002e80ab210927151056000e002d80ac210927151057000e002e80ab210927151058000e002d80ab210927151059000e002e80ab210927151100000e002d80ab210927151101000e002e80aa210927151102000e002d80a6210927151103000e002e80a5847e")); diff --git a/src/test/java/org/traccar/protocol/HuabaoProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/HuabaoProtocolEncoderTest.java index 1cb273c2b..6f9c8250a 100644 --- a/src/test/java/org/traccar/protocol/HuabaoProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/HuabaoProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class HuabaoProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new HuabaoProtocolEncoder(null); + var encoder = inject(new HuabaoProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/HunterProProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/HunterProProtocolDecoderTest.java index 81fdae95c..5503ab02c 100644 --- a/src/test/java/org/traccar/protocol/HunterProProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/HunterProProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class HunterProProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new HunterProProtocolDecoder(null); + var decoder = inject(new HunterProProtocolDecoder(null)); verifyPosition(decoder, text( ">0002<$GPRMC,170559.000,A,0328.3045,N,07630.0735,W,0.73,266.16,200816,,,A77, s000078015180\",0MD")); diff --git a/src/test/java/org/traccar/protocol/IdplProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/IdplProtocolDecoderTest.java index a5141c389..1bd52ce89 100644 --- a/src/test/java/org/traccar/protocol/IdplProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/IdplProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class IdplProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new IdplProtocolDecoder(null); + var decoder = inject(new IdplProtocolDecoder(null)); verifyPosition(decoder, text( "*ID1,863071011086474,210314,153218,A,1831.4577,N,07351.1433,E,0.79,240.64,9,20,A,1,4.20,0,1,01,1,0,0,A01,R,935D#"), diff --git a/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java index ee3a25cbe..b6e12aef5 100644 --- a/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/IntellitracProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class IntellitracProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new IntellitracProtocolDecoder(null); + var decoder = inject(new IntellitracProtocolDecoder(null)); verifyPosition(decoder, text( "359316075744331,20201008181424,12.014662,57.826301,0,76,24,10,997,3,0,0.000,4.208,20201008181424,0")); diff --git a/src/test/java/org/traccar/protocol/IotmProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/IotmProtocolDecoderTest.java index ca72874ef..c668084a1 100644 --- a/src/test/java/org/traccar/protocol/IotmProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/IotmProtocolDecoderTest.java @@ -10,7 +10,7 @@ public class IotmProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new IotmProtocolDecoder(null); + var decoder = inject(new IotmProtocolDecoder(null)); verifyNull(decoder, MqttMessageBuilders.connect().clientId( "123456789012345").build()); diff --git a/src/test/java/org/traccar/protocol/ItsFrameDecoderTest.java b/src/test/java/org/traccar/protocol/ItsFrameDecoderTest.java index 363185b4c..26f28916c 100644 --- a/src/test/java/org/traccar/protocol/ItsFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsFrameDecoderTest.java @@ -8,7 +8,7 @@ public class ItsFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ItsFrameDecoder(); + var decoder = inject(new ItsFrameDecoder()); verifyFrame( binary("242c2c3836383732383033373731373434312c312e3444335f4149533134305f312e302c56455253494f4e312e302c32382e3633333731372c4e2c37372e3232323730322c45"), diff --git a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java index dfd86969a..dd8d3a0d9 100644 --- a/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class ItsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ItsProtocolDecoder(null); + var decoder = inject(new ItsProtocolDecoder(null)); verifyNull(decoder, text( "$,LGN,MARK,000000000,358980100077446,V0.0.1,AIS140,19.804487,N,75.225876,E,*")); diff --git a/src/test/java/org/traccar/protocol/ItsProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/ItsProtocolEncoderTest.java index 5302709fc..195fc4258 100644 --- a/src/test/java/org/traccar/protocol/ItsProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/ItsProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class ItsProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new ItsProtocolEncoder(null); + var encoder = inject(new ItsProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Ivt401ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Ivt401ProtocolDecoderTest.java index 8a71cb4d5..b08dff4e7 100644 --- a/src/test/java/org/traccar/protocol/Ivt401ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Ivt401ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Ivt401ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Ivt401ProtocolDecoder(null); + var decoder = inject(new Ivt401ProtocolDecoder(null)); verifyPosition(decoder, text( "(TLA,356917051007891,190118,090211,+16.986606,+82.242416,0,66,4,13,1,5,000,00,0.0,11.59,8.30,37.77,0.0,1,1.02,0,0,208,0,0,0,0,000000000,0,0,0,0,0,0,0,1,8654604,5,9,114)")); diff --git a/src/test/java/org/traccar/protocol/JidoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/JidoProtocolDecoderTest.java new file mode 100644 index 000000000..b275e6d01 --- /dev/null +++ b/src/test/java/org/traccar/protocol/JidoProtocolDecoderTest.java @@ -0,0 +1,21 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class JidoProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new JidoProtocolDecoder(null)); + + verifyPosition(decoder, text( + "*12345678910101000,01,A,130517,160435,1820.5845,N,07833.2478,E,20,0,067,045,05,28,26,1,075,Y,1,0000,0000,0000,59")); + + verifyPosition(decoder, text( + "*12345678910101000,03,130517,160435,1820.5845,N,07833.2478,E,1,58")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/JpKorjarProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/JpKorjarProtocolDecoderTest.java index 13137006c..a1b0acac5 100644 --- a/src/test/java/org/traccar/protocol/JpKorjarProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/JpKorjarProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class JpKorjarProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new JpKorjarProtocolDecoder(null); + var decoder = inject(new JpKorjarProtocolDecoder(null)); verifyPosition(decoder, text( "KORJAR.PL,329587014519383,160910144240,52.247254N,021.013375E,0.00,1,F:4.18V,1 260 01 794B 3517,")); diff --git a/src/test/java/org/traccar/protocol/JsonFrameDecoderTest.java b/src/test/java/org/traccar/protocol/JsonFrameDecoderTest.java index 42777e419..1bc5d8480 100644 --- a/src/test/java/org/traccar/protocol/JsonFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/JsonFrameDecoderTest.java @@ -8,7 +8,7 @@ public class JsonFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new JsonFrameDecoder(); + var decoder = inject(new JsonFrameDecoder()); verifyFrame( binary("7b226465764964223a2243485a4430384b504430323130343235303436222c2264657654797065223a322c226861726456657273696f6e223a224844545456413139222c226d736754797065223a3131302c2270726f746f636f6c56657273696f6e223a225631222c22736f667456657273696f6e223a22332e312e38222c22737769746368436162537461747573223a2231222c2274786e4e6f223a2231363235323132373431353337227d"), diff --git a/src/test/java/org/traccar/protocol/Jt600FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Jt600FrameDecoderTest.java index eda97ba2d..8e408e50f 100644 --- a/src/test/java/org/traccar/protocol/Jt600FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Jt600FrameDecoderTest.java @@ -8,7 +8,7 @@ public class Jt600FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Jt600FrameDecoder(); + var decoder = inject(new Jt600FrameDecoder()); verifyFrame( binary("2480413009781914003406102107544354193631006213423b00000000006c070000000020e064f91ea0671d00020f0f0f0f0f0f0f0f0f0f07f100ea0f6e"), diff --git a/src/test/java/org/traccar/protocol/Jt600ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Jt600ProtocolDecoderTest.java index 3c681ec58..fc52e32e3 100644 --- a/src/test/java/org/traccar/protocol/Jt600ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Jt600ProtocolDecoderTest.java @@ -1,15 +1,20 @@ package org.traccar.protocol; -import org.traccar.ProtocolTest; - import org.junit.Test; +import org.traccar.ProtocolTest; public class Jt600ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Jt600ProtocolDecoder(null); + var decoder = inject(new Jt600ProtocolDecoder(null)); + + verifyPositions(decoder, binary( + "2480433966040111002718031919195822424550114158888E15A40000F124080000000000F00F110A24991900000DF0C7")); + + verifyPosition(decoder, buffer( + "(8000632862,P45,290322,132412,25.28217,S,57.54683,W,A,0,0,5,0,0000000000,0,0,9,0)")); verifyPositions(decoder, binary( "2480413009781914003406102107544354193631006213423b00000000006c070000000020e064f91ea0671d00020f0f0f0f0f0f0f0f0f0f07f100ea0f6e")); diff --git a/src/test/java/org/traccar/protocol/Jt600ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Jt600ProtocolEncoderTest.java index 51cefb962..fdd73b9ce 100644 --- a/src/test/java/org/traccar/protocol/Jt600ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Jt600ProtocolEncoderTest.java @@ -1,11 +1,11 @@ package org.traccar.protocol; -import static org.junit.Assert.assertEquals; - import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Command; +import static org.junit.Assert.assertEquals; + public class Jt600ProtocolEncoderTest extends ProtocolTest { Jt600ProtocolEncoder encoder = new Jt600ProtocolEncoder(null); Command command = new Command(); diff --git a/src/test/java/org/traccar/protocol/KenjiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/KenjiProtocolDecoderTest.java index 53ef1d5ca..a705d8082 100755 --- a/src/test/java/org/traccar/protocol/KenjiProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/KenjiProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class KenjiProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new KenjiProtocolDecoder(null); + var decoder = inject(new KenjiProtocolDecoder(null)); verifyPosition(decoder, text( ">C800000,M005004,O0000,I0002,D124057,A,S3137.2783,W05830.2978,T000.0,H254.3,Y240116,G06*17"), diff --git a/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java index 5c2b0732b..155493bea 100644 --- a/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/KhdProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class KhdProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new KhdProtocolDecoder(null); + var decoder = inject(new KhdProtocolDecoder(null)); verifyPosition(decoder, binary( "2929800028258b8c10210731035840031534240542120200000337fb000000ffff5a00000a0000000005005d0d")); diff --git a/src/test/java/org/traccar/protocol/KhdProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/KhdProtocolEncoderTest.java index 287d05fca..468083f35 100644 --- a/src/test/java/org/traccar/protocol/KhdProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/KhdProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class KhdProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new KhdProtocolEncoder(null); + var encoder = inject(new KhdProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/L100FrameDecoderTest.java b/src/test/java/org/traccar/protocol/L100FrameDecoderTest.java index 45c69105b..084ae0498 100644 --- a/src/test/java/org/traccar/protocol/L100FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/L100FrameDecoderTest.java @@ -8,7 +8,7 @@ public class L100FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new L100FrameDecoder(); + var decoder = inject(new L100FrameDecoder()); verifyFrame( binary("41544c2c4c2c3836383334353033383137313936332c4e2c3230313231382c3039333031362c412c3032352e3036373134342c4e2c3035352e3134343833332c452c3030302e302c4750532c333933392c3432342c30332c30303430352c303038383334"), diff --git a/src/test/java/org/traccar/protocol/L100ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/L100ProtocolDecoderTest.java index d4bef3885..56281cda0 100644 --- a/src/test/java/org/traccar/protocol/L100ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/L100ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class L100ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new L100ProtocolDecoder(null); + var decoder = inject(new L100ProtocolDecoder(null)); verifyPosition(decoder, text( "ATL,NP,868004029750174,$GPRMC,062943,A,2533.6719,N,09154.3203,E,0,179,311218,,,*39,#01111011000000,0,0,0,934.82,27.13,4.0,25,405,755,15af,974b,0,0,0,ATL")); diff --git a/src/test/java/org/traccar/protocol/LacakProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/LacakProtocolDecoderTest.java index c407d1e64..45544241f 100644 --- a/src/test/java/org/traccar/protocol/LacakProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/LacakProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class LacakProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new LacakProtocolDecoder(null); + var decoder = inject(new LacakProtocolDecoder(null)); verifyPosition(decoder, request(HttpMethod.POST, "/", buffer("{\"location\":{\"event\":\"motionchange\",\"is_moving\":false,\"uuid\":\"0e9a2473-a9a7-4c00-997b-fb97d2154e75\",\"timestamp\":\"2021-07-21T08:06:34.444Z\",\"odometer\":0,\"coords\":{\"latitude\":-6.1148096,\"longitude\":106.6837015,\"accuracy\":3.8,\"speed\":18.67,\"speed_accuracy\":0.26,\"heading\":63,\"heading_accuracy\":0.28,\"altitude\":35.7,\"altitude_accuracy\":3.8},\"activity\":{\"type\":\"still\",\"confidence\":100},\"battery\":{\"is_charging\":false,\"level\":0.79},\"extras\":{}},\"device_id\":\"8737767034\"}"))); diff --git a/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java index 1d5819603..aacf9abc8 100644 --- a/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/LaipacProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class LaipacProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new LaipacProtocolDecoder(null); + var decoder = inject(new LaipacProtocolDecoder(null)); verifyPosition(decoder, text( "$AVRMC,80006405,212645,r,3013.9938,N,08133.3998,W,0.00,0.00,010317,a,4076,0,1,0,0,53170583,310260*78")); diff --git a/src/test/java/org/traccar/protocol/LeafSpyProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/LeafSpyProtocolDecoderTest.java index aed82eb41..ea31bc99d 100644 --- a/src/test/java/org/traccar/protocol/LeafSpyProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/LeafSpyProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class LeafSpyProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new LeafSpyProtocolDecoder(null); + var decoder = inject(new LeafSpyProtocolDecoder(null)); verifyNull(decoder, request( "/?Lat=60.0&Long=30.0")); diff --git a/src/test/java/org/traccar/protocol/M2cProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/M2cProtocolDecoderTest.java index ede056f96..674738c82 100644 --- a/src/test/java/org/traccar/protocol/M2cProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/M2cProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class M2cProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new M2cProtocolDecoder(null); + var decoder = inject(new M2cProtocolDecoder(null)); verifyPositions(decoder, text( "[#M2C,2020,P1.B1.H3.F9.R1,102,864547034433966,1,L,0,20,171221,062016,28.647552,77.192841,0,0,0.0,0,0,64,255,11983,0,0,0,0.0,0,0,0,404,4,1F6,4D77,31,0*7524\r\n", diff --git a/src/test/java/org/traccar/protocol/M2mProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/M2mProtocolDecoderTest.java index f318dcfef..0d812ebfc 100644 --- a/src/test/java/org/traccar/protocol/M2mProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/M2mProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class M2mProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new M2mProtocolDecoder(null); + var decoder = inject(new M2mProtocolDecoder(null)); verifyNull(decoder, binary( "235A3C2A2624215C287D70212A21254C7C6421220B0B0B")); diff --git a/src/test/java/org/traccar/protocol/MaestroProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MaestroProtocolDecoderTest.java index 19f9b9da7..be0fe502e 100644 --- a/src/test/java/org/traccar/protocol/MaestroProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MaestroProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class MaestroProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MaestroProtocolDecoder(null); + var decoder = inject(new MaestroProtocolDecoder(null)); verifyPosition(decoder, text( "@353893040202807,705,UPV-02,1,13.2,17,0,0,16/09/11,11:42:49,0.352705,32.647918,1210.5,0.000000,35.33,11,0.8,0.000,0!\0")); diff --git a/src/test/java/org/traccar/protocol/ManPowerProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ManPowerProtocolDecoderTest.java index 74f3ff1ec..a77043b9d 100644 --- a/src/test/java/org/traccar/protocol/ManPowerProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ManPowerProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ManPowerProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ManPowerProtocolDecoder(null); + var decoder = inject(new ManPowerProtocolDecoder(null)); verifyPosition(decoder, text( "simei:352581250259539,,,tracker,51,24,1.73,130426023608,A,3201.5462,N,03452.2975,E,0.01,28B9,1DED,425,01,1x0x0*0x1*60x+2,en-us,"), diff --git a/src/test/java/org/traccar/protocol/Mavlink2ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Mavlink2ProtocolDecoderTest.java index ccddb6a11..0c74d4772 100644 --- a/src/test/java/org/traccar/protocol/Mavlink2ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Mavlink2ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Mavlink2ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Mavlink2ProtocolDecoder(null); + var decoder = inject(new Mavlink2ProtocolDecoder(null)); verifyAttributes(decoder, binary( "fd1c0000ce01012100004da91f004005d323b89aa30ea6ed070099fb0100f7fffdff0000942c4a88")); diff --git a/src/test/java/org/traccar/protocol/MegastekFrameDecoderTest.java b/src/test/java/org/traccar/protocol/MegastekFrameDecoderTest.java index 19e5cb0ab..854564cd2 100644 --- a/src/test/java/org/traccar/protocol/MegastekFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MegastekFrameDecoderTest.java @@ -8,7 +8,7 @@ public class MegastekFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MegastekFrameDecoder(); + var decoder = inject(new MegastekFrameDecoder()); verifyFrame( binary("30313337244d47563030322c3335343535303035303239323636392c4756543930302c522c3134313231352c3033313830342c412c2c532c2c452c30302c30332c30302c332e36372c302e3030302c302e30302c3131372e312c302e302c3531302c31302c2c2c2c303030302c303030302c32322c31322c302c202c202c2c312d312c39382c5057204f4e3b21"), diff --git a/src/test/java/org/traccar/protocol/MegastekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MegastekProtocolDecoderTest.java index 83d62e766..964c59927 100644 --- a/src/test/java/org/traccar/protocol/MegastekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MegastekProtocolDecoderTest.java @@ -1,15 +1,15 @@ package org.traccar.protocol; import org.junit.Test; -import org.traccar.model.Position; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class MegastekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MegastekProtocolDecoder(null); + var decoder = inject(new MegastekProtocolDecoder(null)); verifyPosition(decoder, text( "$MGV002,860719020193193,,S,070521,160748,V,2255.09165,N,11404.01322,E,00,00,00,,,,,,,,,,,,,,,,,,,10,015,Restart;!")); diff --git a/src/test/java/org/traccar/protocol/MeiligaoFrameDecoderTest.java b/src/test/java/org/traccar/protocol/MeiligaoFrameDecoderTest.java index c0e5f1e97..379cf28f9 100644 --- a/src/test/java/org/traccar/protocol/MeiligaoFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MeiligaoFrameDecoderTest.java @@ -11,7 +11,7 @@ public class MeiligaoFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MeiligaoFrameDecoder(); + var decoder = inject(new MeiligaoFrameDecoder()); assertNull( decoder.decode(null, null, binary("00"))); diff --git a/src/test/java/org/traccar/protocol/MeiligaoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MeiligaoProtocolDecoderTest.java index 087701be4..4c6eae847 100644 --- a/src/test/java/org/traccar/protocol/MeiligaoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MeiligaoProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class MeiligaoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MeiligaoProtocolDecoder(null); + var decoder = inject(new MeiligaoProtocolDecoder(null)); verifyAttribute(decoder, binary( "2424008f142180340967ff99553033333233302e3030302c412c313531362e383039392c4e2c31303435322e383835352c452c302e30302c33332c3038313232302c2c2a33367c302e387c3132337c323130307c303030302c303030302c303230452c303241417c30323038303030353038394530304531434638347c31437c31373243353832437c3042a8060d0a"), diff --git a/src/test/java/org/traccar/protocol/MeiligaoProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/MeiligaoProtocolEncoderTest.java index 9c50d972a..1f2e5f7e3 100644 --- a/src/test/java/org/traccar/protocol/MeiligaoProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/MeiligaoProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class MeiligaoProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new MeiligaoProtocolEncoder(null); + var encoder = inject(new MeiligaoProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -36,6 +36,10 @@ public class MeiligaoProtocolEncoderTest extends ProtocolTest { verifyCommand(encoder, command, binary("4040001312345678901234410603e87bb00d0a")); + command.setType(Command.TYPE_ENGINE_STOP); + + verifyCommand(encoder, command, binary("4040001212345678901234411501fd460d0a")); + } } diff --git a/src/test/java/org/traccar/protocol/MeitrackFrameDecoderTest.java b/src/test/java/org/traccar/protocol/MeitrackFrameDecoderTest.java index 38d0f2f92..a55935ed2 100644 --- a/src/test/java/org/traccar/protocol/MeitrackFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MeitrackFrameDecoderTest.java @@ -10,7 +10,7 @@ public class MeitrackFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MeitrackFrameDecoder(); + var decoder = inject(new MeitrackFrameDecoder()); assertEquals( binary("24244e3132372c3836333037313031333830333036362c4141412c33352c2d312e3330323638302c33362e3835323133352c3135303430393231313032362c412c392c302c302e312c302c352c313635332c343039362c33323634382c3633397c30327c313030347c3930432c303030302c307c307c307c3346467c3330302c2a37430d0a"), diff --git a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java index 58861c139..ce0a1e922 100644 --- a/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MeitrackProtocolDecoderTest.java @@ -9,7 +9,20 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MeitrackProtocolDecoder(null); + var decoder = inject(new MeitrackProtocolDecoder(null)); + + verifyPositions(decoder, binary( + "24246a3138312c3836343238313034313930383330332c4343452c00000000010093001f000505000600070714001502090800000900000a00000b0000160a001706001904001ad90440230006023279570103305ccc0604f536492b0c510300000d495701001c014000000b0e0ccc010000922781abb90c00002a030034212b03008b082c030053082d03009e082e030034212f030034213003003421310300342149090400000000000000004b07010104574946492a36310d0a")); + + verifyPositions(decoder, binary( + "2424423233322c3836323039303035303030323831332c4343452c0400000003004400110004050006000700fe6962060800000900000a00000b00001aef044023000602d65fbcfd03173b9c0804cc76ae2a0c14ae1b000d00aa0d001c01000000014b030101003f00100004050006000700fe695f060800000900000a00000b00001aea044016000502d65fbcfd03173b9c0804cf76ae2a0c14ae1b000d03aa0d00014b030101003f00100004050006000700fe695f060800000900000a00000b00001aed044001000502d65fbcfd03173b9c0804d076ae2a0c14ae1b000d04aa0d00014b030101002a30460d0a")); + + verifyAttribute(decoder, buffer( + "$$F160,861412043027965,AAA,22,45.499458,-82.493581,220718171428,V,0,0,0,0,0.0,0,227940,119812,302|220|D8D6|086E1B2B,0000,0000|0000|0000|0191|0573,,,3,,002134,0,0*FA"), + Position.KEY_POWER, 13.95); + + verifyPositions(decoder, binary( + "2424423233392c3836323039303035303030373436352c4343452c0100000003004300130006050006000700140015801b00080800000900000a00000b0000165105198d011a630540160005024c5e910103590bfe0204922153290c6b2501000dd5b50200004300130006050006000700140015011b00080800000900000a00000b0000165005198d011a630540010005024c5e910103590bfe0204932153290c6b2501000dd6b50200004300130006050006000700140015011b00080800000900000a00000b0000165205198d011a630540230005024c5e910103590bfe0204942153290c6b2501000dd7b50200002a43330d0a")); verifyPosition(decoder, buffer( "$$D149,867047043162018,AAA,35,-1.264865,36.800705,211001105240,A,9,20,41.0,323,1,1697,1,0,000|00||,0000,4.33|12.96|1.92|2.72|2.69,0.000000|0|0.000000,*E1")); @@ -119,6 +132,9 @@ public class MeitrackProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "2424473937302c3336393830303031333436303637342c4343432c020134005b000000010ce304035db9e000ec6f591a000013000000000c001801edb70200c96d0100e60001004838576501000300a101c20400000000010ce304035db9e000ee6f591a000013000000000c001801edb70200ca6d0100e60001004838576501000300a101c20400000000010ce304035db9e000ef6f591a000013000000000c001801edb70200cc6d0100e60001004838576501000300a101c20400000000020ce304035db9e000f76f591a000016000000000c001801edb70200d36d0100e60001004838576502000300a101bf04000000000a0ce304035db9e000f76f591a000016000000000c001801edb70200d46d0100e60001004838576500000300a101bf0400000000020ce304035db9e000fb6f591a000016000000000c001801edb70200d86d0100e60001004838576502000300a101760400000000180ce304035db9e000fc6f591a0000120000000000008c00edb70200d96d0100e60001004838576502000300a10176040000000019b1e2040323b9e0000b70591a0105150600bb0012002901edb70200e76d0100e60001004838576502000300a2017005000000002023e304031fb9e0001070591a010615070027010d001601fcb70200ec6d0100e60001004838576502000300a201800500000000201fe3040302b9e0001170591a010615090019010d001501feb70200ed6d0100e60001004838576502000300a2018005000000002018e30403dcb8e0001270591a0106150b0011010d00150100b80200ee6d0100e60001004838576502000300a2018005000000002036e3040345b8e0001570591a0107150b002d010b0013010ab80200f16d0100e60001004838576502000300a2018005000000002053e3040326b8e0001670591a0107150d0041010b0013010eb80200f26d0100e60001004838576502000300a2018005000000002070e3040310b8e0001770591a0107150e004f010b00130111b80200f36d0100e60001004838576502000300a2018005000000002095e3040306b8e0001870591a0107150d005a010b00140115b80200f46d0100e60001004838576502000300a20180050000000020b3e3040305b8e0001970591a0107150b0060010b00140118b80200f56d0100e60001004838576502000300a20183050000000020cfe3040308b8e0001a70591a0107150b0066010b0014011bb80200f66d0100e60001004838576502000300a20183050000000020eee304030cb8e0001b70591a0106170b0004000d0014011eb80200f76d0100e60001004838576502000300a2018305000000002a62350d0a")); + verifyNull(decoder, buffer( + "$$z27,861451040910625,AAC,1*D3")); + } } diff --git a/src/test/java/org/traccar/protocol/MeitrackProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/MeitrackProtocolEncoderTest.java index 64fc7e17b..cc8847db2 100644 --- a/src/test/java/org/traccar/protocol/MeitrackProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/MeitrackProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class MeitrackProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new MeitrackProtocolEncoder(null); + var encoder = inject(new MeitrackProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java index 4c17bf1f8..5e36abe5b 100644 --- a/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MictrackProtocolDecoderTest.java @@ -9,7 +9,10 @@ public class MictrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeStandard() throws Exception { - var decoder = new MictrackProtocolDecoder(null); + var decoder = inject(new MictrackProtocolDecoder(null)); + + verifyAttributes(decoder, text( + "MT;5;867035041396795;Y1;220111085741+test,8c:53:c3:db:e7:26,-58,jiuide-842,80:26:89:f0:5e:4f,-74,jiu2ide 403,94:e4:4b:0a:31:08,-75,jiu3ide,7a:91:e9:50:26:0b,-85,CNet-9rNe,78:91:e9:40:26:0b,-87+0+4092+1")); verifyAttribute(decoder, text( "867035041390699 netlock=Success!"), @@ -45,7 +48,7 @@ public class MictrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeLowAltitude() throws Exception { - var decoder = new MictrackProtocolDecoder(null); + var decoder = inject(new MictrackProtocolDecoder(null)); verifyPositions(decoder, text( "861836051888035$162835.00,A,4139.6460,N,07009.7239,W,,41.53,-25.8,220621")); diff --git a/src/test/java/org/traccar/protocol/MilesmateProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MilesmateProtocolDecoderTest.java index 69fd82886..275672554 100644 --- a/src/test/java/org/traccar/protocol/MilesmateProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MilesmateProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class MilesmateProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MilesmateProtocolDecoder(null); + var decoder = inject(new MilesmateProtocolDecoder(null)); verifyPosition(decoder, text( "ApiString={A:861359037373030,B:09.8,C:00.0,D:083506,E:2838.5529N,F:07717.8049E,G:000.00,H:170918,I:G,J:00004100,K:0000000A,L:1234,M:126.86}")); diff --git a/src/test/java/org/traccar/protocol/MiniFinderProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MiniFinderProtocolDecoderTest.java index 2d7e4e597..a8f1be855 100644 --- a/src/test/java/org/traccar/protocol/MiniFinderProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MiniFinderProtocolDecoderTest.java @@ -2,13 +2,14 @@ package org.traccar.protocol; import org.junit.Test; import org.traccar.ProtocolTest; +import org.traccar.model.Position; public class MiniFinderProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MiniFinderProtocolDecoder(null); + var decoder = inject(new MiniFinderProtocolDecoder(null)); verifyNull(decoder, text( "!1,867273023933661,V07S.5701.1621,100")); @@ -19,7 +20,11 @@ public class MiniFinderProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, text( "!1,123456789012345")); - verifyNull(decoder, text( + verifyAttribute(decoder, text( + "!5,17,V,50"), + Position.KEY_BATTERY_LEVEL, 50); + + verifyAttributes(decoder, text( "!5,17,V")); verifyNull(decoder, text( diff --git a/src/test/java/org/traccar/protocol/MiniFinderProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/MiniFinderProtocolEncoderTest.java index 652490b72..502f8e8bf 100644 --- a/src/test/java/org/traccar/protocol/MiniFinderProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/MiniFinderProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class MiniFinderProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new MiniFinderProtocolEncoder(null); + var encoder = inject(new MiniFinderProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Minifinder2ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Minifinder2ProtocolDecoderTest.java index ab23f277a..0809996f6 100644 --- a/src/test/java/org/traccar/protocol/Minifinder2ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Minifinder2ProtocolDecoderTest.java @@ -8,7 +8,14 @@ public class Minifinder2ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Minifinder2ProtocolDecoder(null); + var decoder = inject(new Minifinder2ProtocolDecoder(null)); + + verifyAttribute(decoder, binary( + "ab102600080f1400011001383633393231303339393833343736092429b347633003a96409020000008027b34763"), + "bark", true); + + verifyPositions(decoder, binary( + "AB103D0035A700000110013836373733303035333430333237390924AC5783620103C250162030CC5F0D5002FB432D00AF005A3158006D0A00000B0931EC5783620A000000")); verifyPositions(decoder, binary( "ab10350015ae59010110013836333932313033333836353231360924723a12610042535a182ac0f6b4f2923100c900af02215c2b9bfb5461736b4c4d53")); diff --git a/src/test/java/org/traccar/protocol/MobilogixProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MobilogixProtocolDecoderTest.java index ddfa6ad8b..fea74db7a 100644 --- a/src/test/java/org/traccar/protocol/MobilogixProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MobilogixProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class MobilogixProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MobilogixProtocolDecoder(null); + var decoder = inject(new MobilogixProtocolDecoder(null)); verifyAttributes(decoder, text( "[2021-08-20 19:27:14,T14,1,V1.3.5,201909000982,53,12.18")); diff --git a/src/test/java/org/traccar/protocol/MoovboxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MoovboxProtocolDecoderTest.java index af19b8222..82781550e 100644 --- a/src/test/java/org/traccar/protocol/MoovboxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MoovboxProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class MoovboxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MoovboxProtocolDecoder(null); + var decoder = inject(new MoovboxProtocolDecoder(null)); verifyPositions(decoder, request(HttpMethod.POST, "/", buffer("<gps id=\"911\">\n<coordinates><coordinate>\n<fix>3</fix>\n<time>1597580050</time>\n<latitude>100.726257</latitude>\n<longitude>13.821351</longitude>\n<altitude>9.500000</altitude>\n<climb>0.000000</climb>\n<speed>0.064000</speed>\n<separation>-27.300000</separation>\n<track>0.000000</track>\n<satellites>9</satellites>\n</coordinate></coordinates>\n</gps>"))); diff --git a/src/test/java/org/traccar/protocol/MotorProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MotorProtocolDecoderTest.java index bd4a97ef4..f3ebb8e5c 100644 --- a/src/test/java/org/traccar/protocol/MotorProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MotorProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class MotorProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MotorProtocolDecoder(null); + var decoder = inject(new MotorProtocolDecoder(null)); verifyPosition(decoder, text( "341200007E7E00007E7E020301803955352401161766210162090501010108191625132655351234567F12345F")); diff --git a/src/test/java/org/traccar/protocol/MtxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MtxProtocolDecoderTest.java index 28b5d3be0..8a5e228c7 100644 --- a/src/test/java/org/traccar/protocol/MtxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MtxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class MtxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MtxProtocolDecoder(null); + var decoder = inject(new MtxProtocolDecoder(null)); verifyPosition(decoder, text( "#MTX,353815011138124,20101226,195550,41.6296399,002.3611174,000,035,000000.00,X,X,1111,000,0,0")); diff --git a/src/test/java/org/traccar/protocol/MxtProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/MxtProtocolDecoderTest.java index 301b6102b..68a68c9e8 100644 --- a/src/test/java/org/traccar/protocol/MxtProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/MxtProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class MxtProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new MxtProtocolDecoder(null); + var decoder = inject(new MxtProtocolDecoder(null)); verifyPosition(decoder, binary( "01a631a7627b00087dc41c40850006aab70affecdf23fd32200080000600000000000000000000001b2ff03b1bb9c4c60214f40100050000006c2d0000f427600051051101de0704")); diff --git a/src/test/java/org/traccar/protocol/NavigilProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NavigilProtocolDecoderTest.java index 60d88999e..8eda687cc 100644 --- a/src/test/java/org/traccar/protocol/NavigilProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavigilProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NavigilProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NavigilProtocolDecoder(null); + var decoder = inject(new NavigilProtocolDecoder(null)); verifyNull(decoder, binary( "01004300040020000000f60203080200e7cd0f510c0000003b00000000000000")); diff --git a/src/test/java/org/traccar/protocol/NavisFrameDecoderTest.java b/src/test/java/org/traccar/protocol/NavisFrameDecoderTest.java index 0ebfeacd2..29327f7e1 100644 --- a/src/test/java/org/traccar/protocol/NavisFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavisFrameDecoderTest.java @@ -1,8 +1,7 @@ package org.traccar.protocol; -import org.traccar.ProtocolTest; - import org.junit.Test; +import org.traccar.ProtocolTest; public class NavisFrameDecoderTest extends ProtocolTest { diff --git a/src/test/java/org/traccar/protocol/NavisProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NavisProtocolDecoderTest.java index b1282cac7..960ed1442 100644 --- a/src/test/java/org/traccar/protocol/NavisProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavisProtocolDecoderTest.java @@ -1,15 +1,14 @@ package org.traccar.protocol; -import org.traccar.ProtocolTest; - import org.junit.Test; +import org.traccar.ProtocolTest; public class NavisProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeNtcb() throws Exception { - var decoder = new NavisProtocolDecoder(null); + var decoder = inject(new NavisProtocolDecoder(null)); verifyNull(decoder, binary( "404E5443010000007B000000130044342A3E533A383631373835303035323035303739")); @@ -41,7 +40,7 @@ public class NavisProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeFlex10() throws Exception { - var decoder = new NavisProtocolDecoder(null); + var decoder = inject(new NavisProtocolDecoder(null)); verifyNull(decoder, binary( "404e544301000000c9b5f602130046c52a3e533a383639363936303439373232383235")); @@ -60,7 +59,7 @@ public class NavisProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeFlex20() throws Exception { - var decoder = new NavisProtocolDecoder(null); + var decoder = inject(new NavisProtocolDecoder(null)); verifyNull(decoder, binary( "404e544301000000a9eef602130043fb2a3e533a383639363936303439373337333835")); diff --git a/src/test/java/org/traccar/protocol/NavisetFrameDecoderTest.java b/src/test/java/org/traccar/protocol/NavisetFrameDecoderTest.java index e73c173b7..d15d01cc0 100644 --- a/src/test/java/org/traccar/protocol/NavisetFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavisetFrameDecoderTest.java @@ -8,7 +8,7 @@ public class NavisetFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NavisetFrameDecoder(); + var decoder = inject(new NavisetFrameDecoder()); verifyFrame( binary("1310e4073836383230343030353935383436362a060716"), diff --git a/src/test/java/org/traccar/protocol/NavisetProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NavisetProtocolDecoderTest.java index df4e57e8d..d7643b50c 100644 --- a/src/test/java/org/traccar/protocol/NavisetProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavisetProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NavisetProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NavisetProtocolDecoder(null); + var decoder = inject(new NavisetProtocolDecoder(null)); verifyNull(decoder, binary( "1310e4073836383230343030353935383436362a060716")); diff --git a/src/test/java/org/traccar/protocol/NavtelecomFrameDecoderTest.java b/src/test/java/org/traccar/protocol/NavtelecomFrameDecoderTest.java index 07b19651b..360f92447 100644 --- a/src/test/java/org/traccar/protocol/NavtelecomFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavtelecomFrameDecoderTest.java @@ -9,7 +9,7 @@ public class NavtelecomFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NavtelecomFrameDecoder(); + var decoder = inject(new NavtelecomFrameDecoder()); verifyFrame( binary("404e5443010000000000000013004e452a3e533a383636373935303331343130363839"), @@ -19,13 +19,16 @@ public class NavtelecomFrameDecoderTest extends ProtocolTest { binary("404e544301000000000000002a005e6c2a3e464c4558b01e1efffffe300a08080ffffe08000000580028002bc0000000000000b4000000000000"), decoder.decode(null, null, binary("404e544301000000000000002a005e6c2a3e464c4558b01e1efffffe300a08080ffffe08000000580028002bc0000000000000b4000000000000"))); + verifyNull( + decoder.decode(null, null, binary("7f"))); + } @Ignore @Test public void testDecodeFull() throws Exception { - var decoder = new NavtelecomFrameDecoder(); + var decoder = inject(new NavtelecomFrameDecoder()); verifyFrame( binary("404e5443010000000000000013004e452a3e533a383636373935303331343130363839"), diff --git a/src/test/java/org/traccar/protocol/NavtelecomProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NavtelecomProtocolDecoderTest.java index fd22049fc..301a72b2a 100644 --- a/src/test/java/org/traccar/protocol/NavtelecomProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NavtelecomProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NavtelecomProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NavtelecomProtocolDecoder(null); + var decoder = inject(new NavtelecomProtocolDecoder(null)); verifyNull(decoder, binary( "404e5443010000000000000013004e452a3e533a383636373935303331343130363839")); diff --git a/src/test/java/org/traccar/protocol/NdtpV6ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NdtpV6ProtocolDecoderTest.java new file mode 100644 index 000000000..c63c19a29 --- /dev/null +++ b/src/test/java/org/traccar/protocol/NdtpV6ProtocolDecoderTest.java @@ -0,0 +1,18 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class NdtpV6ProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new NdtpV6ProtocolDecoder(null)); + + verifyAttributes(decoder, binary( + "7e7e3b000200334202000000000000000064000100000000000600020002034f0c0200000400000000000033353135313330353131393430353532353030323632373237343836363500")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/NeosProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NeosProtocolDecoderTest.java index b77bdf658..4e9e55f62 100644 --- a/src/test/java/org/traccar/protocol/NeosProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NeosProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NeosProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NeosProtocolDecoder(null); + var decoder = inject(new NeosProtocolDecoder(null)); verifyPosition(decoder, text( ">12345678,1,1,070201,144111,W05829.2613,S3435.2313,,00,034,25,00,126-000,0,3,11111111*2d!\r\n")); diff --git a/src/test/java/org/traccar/protocol/NetProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NetProtocolDecoderTest.java index 9ab4aea4f..239d892f8 100644 --- a/src/test/java/org/traccar/protocol/NetProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NetProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NetProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NetProtocolDecoder(null); + var decoder = inject(new NetProtocolDecoder(null)); verifyPosition(decoder, text( "@L03686090604017761712271020161807037078881037233751000000010F850036980A4000")); diff --git a/src/test/java/org/traccar/protocol/NiotProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NiotProtocolDecoderTest.java index 7707094a5..03aaa49aa 100644 --- a/src/test/java/org/traccar/protocol/NiotProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NiotProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NiotProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NiotProtocolDecoder(null); + var decoder = inject(new NiotProtocolDecoder(null)); verifyPosition(decoder, binary( "585880004c08675430347318522007161451458024b28003f566ee00000328f8000748217ffc500729007a280000000000160001383932353430323130363431363738373136323100050002004e00570d"), diff --git a/src/test/java/org/traccar/protocol/NoranProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NoranProtocolDecoderTest.java index a30847160..3f1ec7aee 100644 --- a/src/test/java/org/traccar/protocol/NoranProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NoranProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NoranProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NoranProtocolDecoder(null); + var decoder = inject(new NoranProtocolDecoder(null)); verifyNull(decoder, binary( "0d0a2a4b57000d000080010d0a")); diff --git a/src/test/java/org/traccar/protocol/NoranProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/NoranProtocolEncoderTest.java index 76486d024..d1b28525c 100644 --- a/src/test/java/org/traccar/protocol/NoranProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/NoranProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class NoranProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new NoranProtocolEncoder(null); + var encoder = inject(new NoranProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/NvsFrameDecoderTest.java b/src/test/java/org/traccar/protocol/NvsFrameDecoderTest.java index 76c7cafb9..dd5e1d9b9 100644 --- a/src/test/java/org/traccar/protocol/NvsFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NvsFrameDecoderTest.java @@ -10,7 +10,7 @@ public class NvsFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NvsFrameDecoder(); + var decoder = inject(new NvsFrameDecoder()); assertEquals( binary("0012333537303430303630303137383234312e38"), diff --git a/src/test/java/org/traccar/protocol/NvsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NvsProtocolDecoderTest.java index ed4008d47..61d050679 100644 --- a/src/test/java/org/traccar/protocol/NvsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NvsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NvsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NvsProtocolDecoder(null); + var decoder = inject(new NvsProtocolDecoder(null)); verifyNull(decoder, binary( "0012333537303430303630303137383234312e38")); diff --git a/src/test/java/org/traccar/protocol/NyitechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/NyitechProtocolDecoderTest.java index 81de06f89..b3bd9aca7 100644 --- a/src/test/java/org/traccar/protocol/NyitechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/NyitechProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class NyitechProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new NyitechProtocolDecoder(null); + var decoder = inject(new NyitechProtocolDecoder(null)); verifyPosition(decoder, binary( "4040690030313436383230303238373201201c0c12031a308080801c0c12031a3007d67e7e08aceb841002000000ae08000000000000000000000000001e002900f0ffdd002700f2ffe0002700f2ffe1002400f0ffdf002400f3ffe3008a00ffff01010000a9c70d0a")); diff --git a/src/test/java/org/traccar/protocol/ObdDongleProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ObdDongleProtocolDecoderTest.java index 08ebf9995..8272fe41e 100644 --- a/src/test/java/org/traccar/protocol/ObdDongleProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ObdDongleProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ObdDongleProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ObdDongleProtocolDecoder(null); + var decoder = inject(new ObdDongleProtocolDecoder(null)); verifyNull(decoder, binary( "55550003383634383637303232353131303135010009010011023402010201ABAAAA")); diff --git a/src/test/java/org/traccar/protocol/OigoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OigoProtocolDecoderTest.java index 023158f21..6015f1d18 100644 --- a/src/test/java/org/traccar/protocol/OigoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OigoProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OigoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OigoProtocolDecoder(null); + var decoder = inject(new OigoProtocolDecoder(null)); verifyPosition(decoder, binary( "7e002e000000146310002523830400001bfb000369150f310c0591594d062ac0c0141508011303cd63101604fd00000000")); diff --git a/src/test/java/org/traccar/protocol/OkoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OkoProtocolDecoderTest.java index 0df537642..19c96ed9a 100644 --- a/src/test/java/org/traccar/protocol/OkoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OkoProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OkoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OkoProtocolDecoder(null); + var decoder = inject(new OkoProtocolDecoder(null)); verifyPosition(decoder, text( "{861001001012919,090745,A,4944.302,N,02353.366,E,0.0,225,251120,7,0.27,F9,11.3,1}")); diff --git a/src/test/java/org/traccar/protocol/OmnicommFrameDecoderTest.java b/src/test/java/org/traccar/protocol/OmnicommFrameDecoderTest.java index c8bbf399a..8e8d9b1cf 100644 --- a/src/test/java/org/traccar/protocol/OmnicommFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OmnicommFrameDecoderTest.java @@ -8,7 +8,7 @@ public class OmnicommFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OmnicommFrameDecoder(); + var decoder = inject(new OmnicommFrameDecoder()); verifyFrame( binary("c08600004566"), diff --git a/src/test/java/org/traccar/protocol/OmnicommProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OmnicommProtocolDecoderTest.java index 76b476fc2..5b3b08194 100644 --- a/src/test/java/org/traccar/protocol/OmnicommProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OmnicommProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OmnicommProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OmnicommProtocolDecoder(null); + var decoder = inject(new OmnicommProtocolDecoder(null)); verifyNull(decoder, binary( "c080080061a61915340100001dec")); diff --git a/src/test/java/org/traccar/protocol/OpenGtsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OpenGtsProtocolDecoderTest.java index 9fbd79cbf..5494301d8 100644 --- a/src/test/java/org/traccar/protocol/OpenGtsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OpenGtsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OpenGtsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OpenGtsProtocolDecoder(null); + var decoder = inject(new OpenGtsProtocolDecoder(null)); verifyPosition(decoder, request( "/?id=999000000000003&gprmc=$GPRMC,082202.0,A,5006.747329,N,01416.512315,E,0.0,,131018,1.2,E,A*2E")); diff --git a/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java new file mode 100644 index 000000000..408053496 --- /dev/null +++ b/src/test/java/org/traccar/protocol/OrbcommProtocolDecoderTest.java @@ -0,0 +1,24 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class OrbcommProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new OrbcommProtocolDecoder(null)); + + verifyNull(decoder, response( + buffer("{\"ErrorID\":0,\"NextStartUTC\":\"\",\"Messages\":null}"))); + + verifyPositions(decoder, response( + buffer("{\"ErrorID\":0,\"NextStartUTC\":\"2022-02-17 08:44:45\",\"Messages\":[{\"ID\":10343663424,\"MessageUTC\":\"2022-02-17 08:44:45\",\"ReceiveUTC\":\"2022-02-17 08:44:45\",\"SIN\":126,\"MobileID\":\"01452955SKYB444\",\"Payload\":{\"Name\":\"MovingIntervalSat\",\"SIN\":126,\"MIN\":22,\"Fields\":[{\"Name\":\"Latitude\",\"Value\":\"727668\"},{\"Name\":\"Longitude\",\"Value\":\"902276\"},{\"Name\":\"Speed\",\"Value\":\"0\"},{\"Name\":\"Heading\",\"Value\":\"361\"},{\"Name\":\"EventTime\",\"Value\":\"1645087473\"}]},\"RegionName\":\"EMEARB6\",\"OTAMessageSize\":16,\"CustomerID\":0,\"Transport\":1,\"MobileOwnerID\":60003097}]}"))); + + verifyPositions(decoder, false, response( + buffer("{\"ErrorID\":0,\"NextStartUTC\":\"2016-10-13 15:19:59\",\"Messages\":[{\"ID\":120213064,\"MessageUTC\":\"2016-10-12 12:42:01\",\"ReceiveUTC\":\"2016-10-12 12:42:01\",\"SIN\":0,\"MobileID\":\"01173096SKY0E45\",\"Payload\":{\"Name\":\"modemRegistration\",\"SIN\":0,\"MIN\":0,\"Fields\":[{\"Name\":\"hardwareMajorVersion\",\"Value\":\"4\"},{\"Name\":\"hardwareMinorVersion\",\"Value\":\"2\"},{\"Name\":\"softwareMajorVersion\",\"Value\":\"13\"},{\"Name\":\"softwareMinorVersion\",\"Value\":\"1\"},{\"Name\":\"product\",\"Value\":\"4\"},{\"Name\":\"wakeupPeriod\",\"Value\":\"None\"},{\"Name\":\"lastResetReason\",\"Value\":\"Software\"},{\"Name\":\"virtualCarrier\",\"Value\":\"6\"},{\"Name\":\"beam\",\"Value\":\"1\"},{\"Name\":\"vain\",\"Value\":\"0\"},{\"Name\":\"reserved\",\"Value\":\"0\"},{\"Name\":\"operatorTxState\",\"Value\":\"0\"},{\"Name\":\"userTxState\",\"Value\":\"0\"},{\"Name\":\"broadcastIDCount\",\"Value\":\"0\"}],\"RegionName\":\"AMERRB11\",\"OTAMessageSize\":15,\"CustomerID\":0}}]}"))); + + } + +} diff --git a/src/test/java/org/traccar/protocol/OrionProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OrionProtocolDecoderTest.java index 7368a9d4e..f5b98574c 100644 --- a/src/test/java/org/traccar/protocol/OrionProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OrionProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OrionProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OrionProtocolDecoder(null); + var decoder = inject(new OrionProtocolDecoder(null)); verifyPositions(decoder, binary( "5057000137bf6236235a0331b5c6e402a3b5ecff5102980003000e0c1d172936080e0c1d172936b03b01000882050000008e080000000000008c0300940500000084030085030003067600900113150000000000000000000000000000000000000004a4c8")); diff --git a/src/test/java/org/traccar/protocol/OsmAndProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OsmAndProtocolDecoderTest.java index a87b45ec4..3b8a94613 100644 --- a/src/test/java/org/traccar/protocol/OsmAndProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OsmAndProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class OsmAndProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OsmAndProtocolDecoder(null); + var decoder = inject(new OsmAndProtocolDecoder(null)); verifyNotNull(decoder, request( "/?id=123456×tamp=1377177267&cell=257,02,16,2224&cell=257,02,16,2223,-90&wifi=00-14-22-01-23-45,-80&wifi=00-1C-B3-09-85-15,-70")); diff --git a/src/test/java/org/traccar/protocol/OutsafeProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OutsafeProtocolDecoderTest.java index 1194f7970..edb7d1aad 100644 --- a/src/test/java/org/traccar/protocol/OutsafeProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OutsafeProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class OutsafeProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OutsafeProtocolDecoder(null); + var decoder = inject(new OutsafeProtocolDecoder(null)); verifyPosition(decoder, request(HttpMethod.POST, "/", buffer("{\"device\":\"865303040103725\",\"owner\":\"\",\"data\":{\"cmd\":\"\",\"ms1\":-1,\"ms2\":-1,\"ms3\":0,\"ms4\":0,\"observation\":\"\",\"content\":null},\"time\":1589277568,\"origin\":\"mqgatte\",\"latitude\":19.346855,\"longitude\":-99.29587,\"altitude\":2757,\"heading\":0,\"rssi\":0}"))); diff --git a/src/test/java/org/traccar/protocol/OwnTracksProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/OwnTracksProtocolDecoderTest.java index 55b48fb05..03332e7fe 100644 --- a/src/test/java/org/traccar/protocol/OwnTracksProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/OwnTracksProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class OwnTracksProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new OwnTracksProtocolDecoder(null); + var decoder = inject(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}"))); diff --git a/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java index edf508314..bde464162 100644 --- a/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PacificTrackProtocolDecoderTest.java @@ -22,7 +22,7 @@ public class PacificTrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PacificTrackProtocolDecoder(null); + var decoder = inject(new PacificTrackProtocolDecoder(null)); verifyAttributes(decoder, binary( "FB80019702808835275309000091108181B2C08F0143000E10000000010000001400010192DF0143288063810A8202835584D285B486E68780882D89C38A788BCE8C3A8D3C8E418F809073A008ACA16600A225A0C0000F4240C10003DF2CC200004E20C3004428C0C4000008C6C5000316A4E011314334424A57464758444C35333137373302A086AB569DFE110E02A8811203FF81000190820100")); diff --git a/src/test/java/org/traccar/protocol/PathAwayProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PathAwayProtocolDecoderTest.java index e4c9bf449..97020343f 100644 --- a/src/test/java/org/traccar/protocol/PathAwayProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PathAwayProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class PathAwayProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PathAwayProtocolDecoder(null); + var decoder = inject(new PathAwayProtocolDecoder(null)); verifyPosition(decoder, request( "?UserName=name&Password=pass&LOC=$PWS,1,\"Roger\",,,100107,122846,45.317270,-79.642219,45.00,42,1,\"Comment\",0*58")); diff --git a/src/test/java/org/traccar/protocol/PiligrimProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PiligrimProtocolDecoderTest.java index b39060420..0dd00462d 100644 --- a/src/test/java/org/traccar/protocol/PiligrimProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PiligrimProtocolDecoderTest.java @@ -9,12 +9,16 @@ public class PiligrimProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PiligrimProtocolDecoder(null); + var decoder = inject(new PiligrimProtocolDecoder(null)); verifyPositions(decoder, request(HttpMethod.POST, "/bingps?imei=868204005544720&csq=18&vout=00&vin=4050&dataid=00000000", binary("fff2200d4110061a32354f3422310062000a0005173b0000a101000300005e00fff2200d4110100932354f2b22310042000b000e173b00009f01000700006000"))); + verifyPosition(decoder, request(HttpMethod.POST, + "/push.do", + buffer("&phoneNumber=%2B+78000000000&message=ALARM KEY; $GPRMC,180752.000,A,5314.0857,N,03421.8173,E,0.00,104.74,220722,,,A,V* 29,05; GSM: 250-01 0b54-0519,1c30,3e96,3ebe,412e 25; S; Batt: 405,M"))); + } } diff --git a/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java index 2d134d967..8b15d70a6 100644 --- a/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PluginProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class PluginProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PluginProtocolDecoder(null); + var decoder = inject(new PluginProtocolDecoder(null)); verifyPosition(decoder, text( "$$STATUS,000000900005,20210521111252,27.171105,-25.600934,62.0,323,0,-1,2,0.000,2147489155,0.00,0,0,0.0,0.0,0,0,0,0,0,0,0,0,0")); diff --git a/src/test/java/org/traccar/protocol/PolteProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PolteProtocolDecoderTest.java index 592267b9e..8bf109d11 100644 --- a/src/test/java/org/traccar/protocol/PolteProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PolteProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class PolteProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PolteProtocolDecoder(null); + var decoder = inject(new PolteProtocolDecoder(null)); verifyPosition(decoder, request(HttpMethod.POST, "/", buffer("{\"_id\":\"5f75cf7b02c5023bfc0beaf7\",\"location\":{\"LocationMetrics\":{\"EnvironmentDensity\":1,\"LocationType\":2,\"carrierInfo\":{\"aux\":{\"PLMN\":\"310410\",\"country\":\"United States\",\"name\":\"ATT Wireless Inc\"},\"crs\":{\"PLMN\":\"310410\",\"country\":\"United States\",\"name\":\"ATT Wireless Inc\"}},\"hdop\":1850000,\"leversion\":\"2.2.18-20200729T140651\",\"towercount\":1},\"altitude\":0.0011297669261693954,\"confidence\":783.7972188868215,\"detected_at\":1601556342,\"latitude\":29.77368956725161,\"longitude\":-98.26530342694024,\"towerDB\":\"default\",\"ueToken\":\"ALT12503DE04336CB2E3A4A113FCDE05DF05A6F\",\"uid\":\"WZuDMv5Je\"},\"report\":{\"battery\":{\"count\":555,\"level\":100,\"voltage\":3.52},\"event\":3,\"time\":\"2020-10-01T12:45:48.207Z\"},\"time\":\"2020-10-01T12:45:42Z\",\"ueToken\":\"ALT12503DE04336CB2E3A4A113FCDE05DF05A6F\",\"uid\":\"WZuDMv5Je\"}"))); diff --git a/src/test/java/org/traccar/protocol/PortmanProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PortmanProtocolDecoderTest.java index 37798d960..8bc16d373 100644 --- a/src/test/java/org/traccar/protocol/PortmanProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PortmanProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class PortmanProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PortmanProtocolDecoder(null); + var decoder = inject(new PortmanProtocolDecoder(null)); verifyPosition(decoder, text( "$EXT,P0RTMANGRANT,A,210609201710,N0951.6879W08357.0129,0,0,NA,NA,11,25,174700.25,NA,01820000,108")); diff --git a/src/test/java/org/traccar/protocol/PortmanProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/PortmanProtocolEncoderTest.java index 61f6c4a4e..b4c334a0c 100644 --- a/src/test/java/org/traccar/protocol/PortmanProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/PortmanProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class PortmanProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeEngineStop() { + public void testEncodeEngineStop() throws Exception { - var encoder = new PortmanProtocolEncoder(null); + var encoder = inject(new PortmanProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -22,9 +22,9 @@ public class PortmanProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeEngineResume() { + public void testEncodeEngineResume() throws Exception { - var encoder = new PortmanProtocolEncoder(null); + var encoder = inject(new PortmanProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/PretraceProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PretraceProtocolDecoderTest.java index 8a4f257f5..5dbde7846 100644 --- a/src/test/java/org/traccar/protocol/PretraceProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PretraceProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class PretraceProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PretraceProtocolDecoder(null); + var decoder = inject(new PretraceProtocolDecoder(null)); verifyPosition(decoder, text( "(867967021915915U1110A1701201500102238.1700N11401.9324E000264000000000009001790000000,&P11A4,F1050^47")); diff --git a/src/test/java/org/traccar/protocol/PretraceProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/PretraceProtocolEncoderTest.java index 403c89e9e..d3218d4a8 100644 --- a/src/test/java/org/traccar/protocol/PretraceProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/PretraceProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class PretraceProtocolEncoderTest extends ProtocolTest { @Test public void testEncodePositionPeriodic() throws Exception { - var encoder = new PretraceProtocolEncoder(null); + var encoder = inject(new PretraceProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -25,7 +25,7 @@ public class PretraceProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeCustom() throws Exception { - var encoder = new PretraceProtocolEncoder(null); + var encoder = inject(new PretraceProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/PricolProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PricolProtocolDecoderTest.java index a9373e22e..8c2081641 100644 --- a/src/test/java/org/traccar/protocol/PricolProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PricolProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class PricolProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PricolProtocolDecoder(null); + var decoder = inject(new PricolProtocolDecoder(null)); verifyPosition(decoder, binary( "3c5052493030303350020000011402110b222b0455152e4e001de819ca450000000000000003820249000000000000000000000000000000000000000040003e")); diff --git a/src/test/java/org/traccar/protocol/ProgressProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ProgressProtocolDecoderTest.java index 6e59f2876..9129a3079 100644 --- a/src/test/java/org/traccar/protocol/ProgressProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ProgressProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ProgressProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ProgressProtocolDecoder(null); + var decoder = inject(new ProgressProtocolDecoder(null)); verifyNull(decoder, binary( "020037000100000003003131310f003335343836383035313339303036320f00323530303136333832383531353535010000000100000000000000e6bb97b6")); diff --git a/src/test/java/org/traccar/protocol/PstFrameDecoderTest.java b/src/test/java/org/traccar/protocol/PstFrameDecoderTest.java index 96993b97b..172d85df6 100644 --- a/src/test/java/org/traccar/protocol/PstFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PstFrameDecoderTest.java @@ -8,7 +8,7 @@ public class PstFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PstFrameDecoder(); + var decoder = inject(new PstFrameDecoder()); verifyFrame( binary("2fafac5a050f0000e0022fafac5a01891e882bbfdd06dd577c9865620a0efe524c419f940b6710f5ba0c86e5868ffc97c77eaaf166a31dba63f9894e98a91b9486c94e79ce537359737a5e9385431a590eb20b5115a2b7939e4e66ae"), diff --git a/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java index 445c333c1..880caf727 100644 --- a/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/PstProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class PstProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new PstProtocolDecoder(null); + var decoder = inject(new PstProtocolDecoder(null)); verifyPosition(decoder, binary( "2faf97de06000024db0551380cbb08070b040000015a0c09b50177e5100a1822da0d010d0f0451380628101451380cc384b800488a84036901b202d3010001061103ffff00150203523687")); diff --git a/src/test/java/org/traccar/protocol/PstProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/PstProtocolEncoderTest.java index abcfa29ec..6c3ff71b6 100644 --- a/src/test/java/org/traccar/protocol/PstProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/PstProtocolEncoderTest.java @@ -7,9 +7,9 @@ import org.traccar.model.Command; public class PstProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeEngineStop() { + public void testEncodeEngineStop() throws Exception { - var encoder = new PstProtocolEncoder(null); + var encoder = inject(new PstProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -20,9 +20,9 @@ public class PstProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeEngineResume() { + public void testEncodeEngineResume() throws Exception { - var encoder = new PstProtocolEncoder(null); + var encoder = inject(new PstProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Pt215ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Pt215ProtocolDecoderTest.java index 24cfd316a..a5f5d7e77 100644 --- a/src/test/java/org/traccar/protocol/Pt215ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt215ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Pt215ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Pt215ProtocolDecoder(null); + var decoder = inject(new Pt215ProtocolDecoder(null)); verifyNull(decoder, binary( "58580d010359339075435451010d0a")); diff --git a/src/test/java/org/traccar/protocol/Pt3000ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Pt3000ProtocolDecoderTest.java index 44f57601c..f7b278139 100644 --- a/src/test/java/org/traccar/protocol/Pt3000ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt3000ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Pt3000ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Pt3000ProtocolDecoder(null); + var decoder = inject(new Pt3000ProtocolDecoder(null)); verifyPosition(decoder, text( "%356939010012099,$GPRMC,124945.752,A,4436.6245,N,01054.4634,E,0.11,358.52,060408,,,A,+393334347445,N028d"), diff --git a/src/test/java/org/traccar/protocol/Pt502FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Pt502FrameDecoderTest.java index 2559ad145..854c789b8 100644 --- a/src/test/java/org/traccar/protocol/Pt502FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt502FrameDecoderTest.java @@ -8,7 +8,7 @@ public class Pt502FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Pt502FrameDecoder(); + var decoder = inject(new Pt502FrameDecoder()); verifyFrame( binary("24504844302c3936302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110800f0014003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00e5292800ef450020a2800a2801d49400b450014b40052e2800a69340094a05007fffd0e5d14b10055b51b00c76a00527273494005250014500251400525001450015347c25003a928010d25007ffd1e52909a00290d0014b40052d0014500145002e297b50018a280109a6d002d2e2803fffd2e7a04da3777a94fbd0025140052500145002514005250014940054e381400b494008690d007fffd3e4f345001486800a5a005a2800a2801680280168a002909e280100cd028016a48937bfb5007fffd4c5038a42280128a004a280128a003ad2500251400945002a8cb0a9a80133450026692803ffd5e4e8a004a2801694500145002d18a005c5140052e280109a69a0029680140abb147b139eb401ffd6c62290d00251400949400114940052500252d002525003e31c93525002521a004a4a00ffd7e4a8a00281400a29d40094b40053ba500252d0018a31400d3cd250018cd2d005ab58777ccdd074ab645007ffd0c72290d00348a2801280"), diff --git a/src/test/java/org/traccar/protocol/Pt502ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Pt502ProtocolDecoderTest.java index a68471c95..f310b2227 100644 --- a/src/test/java/org/traccar/protocol/Pt502ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt502ProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Pt502ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Pt502ProtocolDecoder(null); + var decoder = inject(new Pt502ProtocolDecoder(null)); verifyNull(decoder, binary( "24504844302c3936302cffd8ffdb008400140e0f120f0d14121012171514181e32211e1c1c1e3d2c2e243249404c4b47404645505a736250556d5645466488656d777b8182814e608d978c7d96737e817c011517171e1a1e3b21213b7c5346537c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7c7cffc000110800f0014003012100021101031101ffdd0004000affc401a20000010501010101010100000000000000000102030405060708090a0b100002010303020403050504040000017d01020300041105122131410613516107227114328191a1082342b1c11552d1f02433627282090a161718191a25262728292a3435363738393a434445464748494a535455565758595a636465666768696a737475767778797a838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae1e2e3e4e5e6e7e8e9eaf1f2f3f4f5f6f7f8f9fa0100030101010101010101010000000000000102030405060708090a0b1100020102040403040705040400010277000102031104052131061241510761711322328108144291a1b1c109233352f0156272d10a162434e125f11718191a262728292a35363738393a434445464748494a535455565758595a636465666768696a737475767778797a82838485868788898a92939495969798999aa2a3a4a5a6a7a8a9aab2b3b4b5b6b7b8b9bac2c3c4c5c6c7c8c9cad2d3d4d5d6d7d8d9dae2e3e4e5e6e7e8e9eaf2f3f4f5f6f7f8f9faffda000c03010002110311003f00e5292800ef450020a2800a2801d49400b450014b40052e2800a69340094a05007fffd0e5d14b10055b51b00c76a00527273494005250014500251400525001450015347c25003a928010d25007ffd1e52909a00290d0014b40052d0014500145002e297b50018a280109a6d002d2e2803fffd2e7a04da3777a94fbd0025140052500145002514005250014940054e381400b494008690d007fffd3e4f345001486800a5a005a2800a2801680280168a002909e280100cd028016a48937bfb5007fffd4c5038a42280128a004a280128a003ad2500251400945002a8cb0a9a80133450026692803ffd5e4e8a004a2801694500145002d18a005c5140052e280109a69a0029680140abb147b139eb401ffd6c62290d00251400949400114940052500252d002525003e31c93525002521a004a4a00ffd7e4a8a00281400a29d40094b40053ba500252d0018a31400d3cd250018cd2d005ab58777ccdd074ab645007ffd0c72290d00348a2801280")); diff --git a/src/test/java/org/traccar/protocol/Pt502ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Pt502ProtocolEncoderTest.java index 62b83c61c..c97093e26 100644 --- a/src/test/java/org/traccar/protocol/Pt502ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt502ProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeCustom() throws Exception { - var encoder = new Pt502ProtocolEncoder(null); + var encoder = inject(new Pt502ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -25,7 +25,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeOutputControl() throws Exception { - var encoder = new Pt502ProtocolEncoder(null); + var encoder = inject(new Pt502ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -40,7 +40,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeTimezone() throws Exception { - var encoder = new Pt502ProtocolEncoder(null); + var encoder = inject(new Pt502ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -55,7 +55,7 @@ public class Pt502ProtocolEncoderTest extends ProtocolTest { @Test public void testEncodeAlarmSpeed() throws Exception { - var encoder = new Pt502ProtocolEncoder(null); + var encoder = inject(new Pt502ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Pt60ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Pt60ProtocolDecoderTest.java index ad987240c..b198ac28e 100644 --- a/src/test/java/org/traccar/protocol/Pt60ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Pt60ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Pt60ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Pt60ProtocolDecoder(null); + var decoder = inject(new Pt60ProtocolDecoder(null)); verifyNull(decoder, text( "@B#@|01|006|864891030184954|9425010450971470|20181213093127|2|1|")); diff --git a/src/test/java/org/traccar/protocol/R12wProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/R12wProtocolDecoderTest.java index acb7277b5..a363022f0 100644 --- a/src/test/java/org/traccar/protocol/R12wProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/R12wProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class R12wProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new R12wProtocolDecoder(null); + var decoder = inject(new R12wProtocolDecoder(null)); verifyNull(decoder, text( "$HX,0001,860721009104316,e92c,933402042499509,55792760080,12345678,01,a8d940a9,#,50,")); diff --git a/src/test/java/org/traccar/protocol/RaceDynamicsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RaceDynamicsProtocolDecoderTest.java index 22902079a..ff40c19a3 100644 --- a/src/test/java/org/traccar/protocol/RaceDynamicsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RaceDynamicsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RaceDynamicsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RaceDynamicsProtocolDecoder(null); + var decoder = inject(new RaceDynamicsProtocolDecoder(null)); verifyNull(decoder, text( "$GPRMC,12,260819,100708,862549040661129,")); diff --git a/src/test/java/org/traccar/protocol/RadarProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RadarProtocolDecoderTest.java index be1e4de0b..b5a2555b1 100644 --- a/src/test/java/org/traccar/protocol/RadarProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RadarProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RadarProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RadarProtocolDecoder(null); + var decoder = inject(new RadarProtocolDecoder(null)); verifyPositions(decoder, binary( "361800011459015cb497554c01c101ff003500050038000207ff831c04c01f1c00555cb464895cb46487ff7f04eafeffdbd80000079402ead0000000110000000000120d2aff150000000000000002000a00050002436c61726f0000000000008b00000003764500037653005207ff831c04c01f1c00555cb4648a5cb46489ff7f04eafeffdbd80000079402ead0000000010000000000120e00ff150000000000000002000800060002436c61726f0000000000008d00000003764600037654000207ff831c04c01f1c00555cb464d85cb464d7ff7f04eafeffdbd80000079402ead0000000110000000000120e2aff150000000000000002000700070003436c61726f0000000000008d000000037694000376a2005207ff831c04c01f1c00555cb464d95cb464d9ff7f04eafeffdbd80000079402eac0000000010000000000120e00ff150000000000000002000700070003436c61726f0000000000008d000000037695000376a3000207ff831c04c01f1c00555cb465065cb46504ff7f04eafeffdbd80000079402ead0000000110000000000120e2aff150000000000000000000500060005436c61726f0000000000008d0000000376c2000376d07ed7")); diff --git a/src/test/java/org/traccar/protocol/RaveonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RaveonProtocolDecoderTest.java index 1b111ee5d..3da671dbf 100644 --- a/src/test/java/org/traccar/protocol/RaveonProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RaveonProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RaveonProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RaveonProtocolDecoder(null); + var decoder = inject(new RaveonProtocolDecoder(null)); verifyPosition(decoder, text( "$PRAVE,0001,0001,3308.9051,-11713.1164,195348,1,10,168,31,13.3,3,-83,0,0,,1003.4*66")); diff --git a/src/test/java/org/traccar/protocol/RecodaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RecodaProtocolDecoderTest.java index 803cfb48a..5bdfd6816 100644 --- a/src/test/java/org/traccar/protocol/RecodaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RecodaProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RecodaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RecodaProtocolDecoder(null); + var decoder = inject(new RecodaProtocolDecoder(null)); verifyNull(decoder, binary( "01100020480000000300000030393535360000000000000001000000303030303000000000000000000000000000000000000000006100004531313037353500ffffffffffff0000")); diff --git a/src/test/java/org/traccar/protocol/RetranslatorProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RetranslatorProtocolDecoderTest.java index 4af77cfbf..eb591a5f6 100644 --- a/src/test/java/org/traccar/protocol/RetranslatorProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RetranslatorProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RetranslatorProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RetranslatorProtocolDecoder(null); + var decoder = inject(new RetranslatorProtocolDecoder(null)); verifyPosition(decoder, binary( "74000000333533393736303133343435343835004B0BFB70000000030BBB000000270102706F73696E666F00A027AFDF5D9848403AC7253383DD4B400000000000805A40003601460B0BBB0000001200047077725F657874002B8716D9CE973B400BBB00000011010361766C5F696E707574730000000001")); diff --git a/src/test/java/org/traccar/protocol/RfTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RfTrackProtocolDecoderTest.java new file mode 100644 index 000000000..df19f01c6 --- /dev/null +++ b/src/test/java/org/traccar/protocol/RfTrackProtocolDecoderTest.java @@ -0,0 +1,19 @@ +package org.traccar.protocol; + +import io.netty.handler.codec.http.HttpMethod; +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class RfTrackProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new RfTrackProtocolDecoder(null)); + + verifyPosition(decoder, request(HttpMethod.POST, "/deviceDataUpload.do", + buffer("gsm={\"n\":0,\"b\":[{\"l\":6166,\"b\":19,\"c\":21423},{\"l\":6166,\"b\":18,\"c\":21416},{\"l\":6166,\"b\":17,\"c\":21383},{\"l\":6166,\"b\":13,\"c\":21422},{\"l\":6166,\"b\":13,\"c\":21435},{\"l\":6169,\"b\":11,\"c\":21311}],\"c\":460}&wifi=[{\"l\":-49,\"t\":\"lianqin20\",\"m\":\"30-B4-9E-DD-F8-2D\"}]&mt=1073709094&i=358477047125172&gps={\"a\":30.0,\"y\":31.251563,\"s\":4,\"t\":1589764496654,\"z\":0.0,\"x\":121.360346}&dbm=-53&td=1589720501123&rc=0&bar=1001.85065&u_ids=[8441644.1,53036.1]&t=1589764500713&bat=12380&v=T2.142.2_2.0_R03&i_ids=[4247328.1,53036.1,10522408.1]&idt=140736414711817&id=39163"))); + + } + +} diff --git a/src/test/java/org/traccar/protocol/RitiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RitiProtocolDecoderTest.java index e0890a5fc..0d7eeb0df 100644 --- a/src/test/java/org/traccar/protocol/RitiProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RitiProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RitiProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RitiProtocolDecoder(null); + var decoder = inject(new RitiProtocolDecoder(null)); verifyPosition(decoder, binary( "3b28a2a2056315316d4000008100000000000000005f710000244750524d432c3138303535332e3030302c412c353532342e383437312c4e2c30313133342e313837382c452c302e30302c2c3032313231332c2c2c412a37340d0a00000000000000000000000000000000040404")); diff --git a/src/test/java/org/traccar/protocol/RoboTrackFrameDecoderTest.java b/src/test/java/org/traccar/protocol/RoboTrackFrameDecoderTest.java index eaf83458d..e4b30538c 100644 --- a/src/test/java/org/traccar/protocol/RoboTrackFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RoboTrackFrameDecoderTest.java @@ -8,7 +8,7 @@ public class RoboTrackFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RoboTrackFrameDecoder(); + var decoder = inject(new RoboTrackFrameDecoder()); verifyFrame( binary("00524f424f545241434b00000000000000383638323034303032323533343136313233343536373839303132312e313261000000312e353761000000312e3030000000003e"), diff --git a/src/test/java/org/traccar/protocol/RoboTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RoboTrackProtocolDecoderTest.java index 40218efdb..db1617c9e 100644 --- a/src/test/java/org/traccar/protocol/RoboTrackProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RoboTrackProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class RoboTrackProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RoboTrackProtocolDecoder(null); + var decoder = inject(new RoboTrackProtocolDecoder(null)); verifyNull(decoder, binary( "00524f424f545241434b00000000000000383638323034303032323533343136313233343536373839303132312e313261000000312e353761000000312e3030000000003e")); diff --git a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java index 71313e449..b301507fb 100644 --- a/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RstProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class RstProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RstProtocolDecoder(null); + var decoder = inject(new RstProtocolDecoder(null)); verifyNull(decoder, text( "RST;A;RST-MINIv2;V7.04;008051261;124;29;04-04-2021 17:27:26;04-04-2021 17:27:26;-1.280811;-47.931755;7353;79;1;14;7315;26;10;0;1855;0;0;0;0;5;5;-1.280821;-47.931747;04-04-2021 17:52:23;6;-1.280863;-47.931770;04-04-2021 18:12:19;5;-1.280844;-47.931763;04-04-2021 17:28:02;5;-1.280900;-47.931770;04-04-2021 19:04:27;4;-1.280843;-47.931747;04-04-2021 18:21:45;04-04-2021 19:29:59;04-04-2021 19:29:59;-1.280770;-47.931595;1;15;0;0;0;0;FIM;")); diff --git a/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java index 64ac6a57e..89d4a02cc 100644 --- a/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/RuptelaProtocolDecoderTest.java @@ -8,7 +8,10 @@ public class RuptelaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new RuptelaProtocolDecoder(null); + var decoder = inject(new RuptelaProtocolDecoder(null)); + + verifyNull(decoder, binary( + "002e000316d53d58d6020f4573303430302e30332e36382e30340000c2b3090d0e950000827b000003e80000003c003c1681")); verifyPositions(decoder, binary( "00800003167d765c155d01000160cd0a310000faae43f7176ee45702332b0c12000006070d05007300cfff260082008600870088000f00d7021100d801c900061d0000c500001e0e988300008900008b000002d0000c9bca720c889a0b047e00000000000000007f0000000000000000800000000000000000810000000000000000a341")); diff --git a/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java index 409cd4da5..0c4fc6767 100644 --- a/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/RuptelaProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class RuptelaProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new RuptelaProtocolEncoder(null); + var encoder = inject(new RuptelaProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/S168ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/S168ProtocolDecoderTest.java index d4918e121..2b7f40c82 100644 --- a/src/test/java/org/traccar/protocol/S168ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/S168ProtocolDecoderTest.java @@ -8,7 +8,16 @@ public class S168ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new S168ProtocolDecoder(null); + var decoder = inject(new S168ProtocolDecoder(null)); + + verifyAttributes(decoder, text( + "S168#861118010104168#00ec#0016#SYNC:0093;STATUS:91,51")); + + verifyPosition(decoder, text( + "S168#861118010104168#0715#0124#LOCA:W;CELL:6,1cc,0,5847,2c54cc1,1d,5847,cc98145,1b,5847,6259d03,e,5847,cc98141,1d,5847,6259e03,27,5847,32113ce,28;GDATA:V,0,220205152238,0.0,0.0,0,0,0;ALERT:0000;STATUS:99,52;WIFI:5,8C-AB-8E-9D-73-18,-56,60-3A-7C-E2-D3-85,-72,62-3A-7C-A2-D3-85,-72,00-00-00-00-00-00,-75,50-70-97-B1-80-1F,-82")); + + verifyPosition(decoder, text( + "S168#358511039001705#003a#01ca#LOCA:G;CELL:6,1cc,0,2479,de11150,2e,2479,d6e4546,31,2479,d6e4547,39,778c,787cc30,39,778c,787cc31,40,253f,6195502,32;GDATA:A,5,220117220950,22.779583,113.820633,5,296,35;ALERT:0080;STATUS:98,73;;FARM:0,0009,0000,010a,20220117220950;WIFI:10,CC-08-FB-A5-49-B3,-28,08-40-F3-7F-6C-A9,-59,A4-29-40-65-2C-42,-74,80-89-17-A5-6F-7B,-82,80-EA-07-82-93-C6,-82,FC-37-2B-34-D6-A1,-83,34-6B-5B-A9-49-15,-83,BC-46-99-B3-51-10,-84,BC-54-FC-53-0A-D1,-84,3C-CD-57-67-D1-32,-85")); verifyNull(decoder, text( "S168#358511139046180#00c9#0009#SYNC:0000")); diff --git a/src/test/java/org/traccar/protocol/SabertekFrameDecoderTest.java b/src/test/java/org/traccar/protocol/SabertekFrameDecoderTest.java index ced40acd0..15b1d0451 100644 --- a/src/test/java/org/traccar/protocol/SabertekFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SabertekFrameDecoderTest.java @@ -10,7 +10,7 @@ public class SabertekFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SabertekFrameDecoder(); + var decoder = inject(new SabertekFrameDecoder()); assertEquals( binary("2c3939393939393939392c332c34302c36352c372c302c312c2d32352e3738313636362c32382e3235343730322c34302c3236382c313431342c382c35353632332c"), diff --git a/src/test/java/org/traccar/protocol/SabertekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SabertekProtocolDecoderTest.java index 148695dcd..6aafa325f 100644 --- a/src/test/java/org/traccar/protocol/SabertekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SabertekProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SabertekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SabertekProtocolDecoder(null); + var decoder = inject(new SabertekProtocolDecoder(null)); verifyPosition(decoder, text( ",999999999,3,40,65,7,0,1,-25.781666,28.254702,40,268,1414,8,55623,")); diff --git a/src/test/java/org/traccar/protocol/SanavProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SanavProtocolDecoderTest.java index 223f4f12f..d0ae6fabf 100644 --- a/src/test/java/org/traccar/protocol/SanavProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SanavProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SanavProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SanavProtocolDecoder(null); + var decoder = inject(new SanavProtocolDecoder(null)); verifyPosition(decoder, text( "imei=353197040023431&rmc=$GPRMC,015258.000,A,2457.8101,N,12125.5393,E,0.00,0.00,210111,,*18,AUTO,0300,2.1,10,466,97,34E7,3391,74,466,9 7,3F2D,3391,65,466,97,39C9,3391,79,466,97,3F2C,3391,81,466,97,0000,00 00,83,466,97,0000,0000,85,466,97,0000,0000,85,1,24")); diff --git a/src/test/java/org/traccar/protocol/SanulProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SanulProtocolDecoderTest.java index 23bd6d80b..57398dd84 100644 --- a/src/test/java/org/traccar/protocol/SanulProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SanulProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SanulProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SanulProtocolDecoder(null); + var decoder = inject(new SanulProtocolDecoder(null)); verifyNull(decoder, binary( "aa007020000100000000000033353333353830313831353431313700000000000000000000")); diff --git a/src/test/java/org/traccar/protocol/SatsolProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SatsolProtocolDecoderTest.java index dcd51063c..0fe16377d 100644 --- a/src/test/java/org/traccar/protocol/SatsolProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SatsolProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SatsolProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SatsolProtocolDecoder(null); + var decoder = inject(new SatsolProtocolDecoder(null)); verifyPositions(decoder, binary( "f0e1bf4cb2ec1600e1005f8791e901000000c959515c2cc24a03aeadcd010e01a800250001090201878e92e901000000cb59515c2dc24a03b8adcd018801a8001d0001080201325993e901000000cc59515c2fc24a03bfadcd01ab01a800220001080201dd8194e901000000cd59515c32c24a03ceadcd015801a8002500010802015f3795e905000900ce59515c32c24a03d8adcd01f600a700250001091401000000000000000000863496e901000000cf59515c34c24a03ddadcd019b00a700280001090201714197e904000600cf59515c34c24a03ddadcd019b00a7002800010a1401becd07001901")); diff --git a/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java index 7e2812714..66d5f5e69 100644 --- a/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SigfoxProtocolDecoderTest.java @@ -10,7 +10,7 @@ public class SigfoxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SigfoxProtocolDecoder(null); + var decoder = inject(new SigfoxProtocolDecoder(null)); verifyPosition(decoder, request(HttpMethod.POST, "/", buffer("{ \"device\":\"BFE47E\", \"time\":1590497040, \"data\":\"10297eb01e621122070000be\", \"seqNumber\":8, \"deviceTypeId\":\"5ecb8bfac563d620cc9e6798\", \"ack\":false }"))); diff --git a/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java index d264895fc..0d7eb4f16 100644 --- a/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SiwiProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SiwiProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SiwiProtocolDecoder(null); + var decoder = inject(new SiwiProtocolDecoder(null)); verifyPosition(decoder, text( "$SIWI,868957040831465,44,E,,,1,1,1,16.79,0,0,5,A,17.204447,78.355087,534,44,140955,180221,11,1,15,5,4322,0,0,0,0,0,0,1.0,1.6CPTASF_6.60,0!")); diff --git a/src/test/java/org/traccar/protocol/SkypatrolProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SkypatrolProtocolDecoderTest.java index a248056f8..e59e3c3f0 100644 --- a/src/test/java/org/traccar/protocol/SkypatrolProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SkypatrolProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SkypatrolProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SkypatrolProtocolDecoder(null); + var decoder = inject(new SkypatrolProtocolDecoder(null)); verifyNull(decoder, binary( "000a02171101303131373232303031333537393833060200000006202020202020202020312020202020202030313137323230303133353739383320")); diff --git a/src/test/java/org/traccar/protocol/SmartSoleProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SmartSoleProtocolDecoderTest.java index 740d1b62c..258eb0fce 100644 --- a/src/test/java/org/traccar/protocol/SmartSoleProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SmartSoleProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SmartSoleProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SmartSoleProtocolDecoder(null); + var decoder = inject(new SmartSoleProtocolDecoder(null)); verifyPosition(decoder, text( "#GTXRP=359366080000385,8,180514200051,34.041981,-118.255806,60,1,1,7,1.80,180514200051,4.16,11")); diff --git a/src/test/java/org/traccar/protocol/SmokeyProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SmokeyProtocolDecoderTest.java index d806fd790..de025c18e 100644 --- a/src/test/java/org/traccar/protocol/SmokeyProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SmokeyProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SmokeyProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SmokeyProtocolDecoder(null); + var decoder = inject(new SmokeyProtocolDecoder(null)); verifyAttributes(decoder, binary( "534d0300865101019383025f0403000000000b86250200000c0000028f000102f8cc0900127f08")); diff --git a/src/test/java/org/traccar/protocol/SolarPoweredProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SolarPoweredProtocolDecoderTest.java index 7202aaefb..445628f6d 100644 --- a/src/test/java/org/traccar/protocol/SolarPoweredProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SolarPoweredProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class SolarPoweredProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SolarPoweredProtocolDecoder(null); + var decoder = inject(new SolarPoweredProtocolDecoder(null)); verifyAttribute(decoder, binary( "7e850256553309440011003e81131914030600332301a61ed709209ff40014b89082020f0283100000f908000000440000003d1f19021784114161726f6e34475630312d323030333031057e"), diff --git a/src/test/java/org/traccar/protocol/SpotProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SpotProtocolDecoderTest.java index 7f8e2b58f..03d0e97f0 100644 --- a/src/test/java/org/traccar/protocol/SpotProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SpotProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class SpotProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SpotProtocolDecoder(null); + var decoder = inject(new SpotProtocolDecoder(null)); verifyPositions(decoder, request(HttpMethod.POST, "/", buffer( "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n", diff --git a/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java index 1710ccbb9..0a6ad0163 100644 --- a/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/StarLinkProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class StarLinkProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new StarLinkProtocolDecoder(null); + var decoder = inject(new StarLinkProtocolDecoder(null)); decoder.setFormat("#IMEI#,#EDT#,#PDT#,#LAT#,#LONG#,#SPD#,#IGN#,#ODO#,#DUR#,#TDUR#,#LAC#,#CID#,#VIN#,#VBAT#,#EID#,#EDSC#,#DRV#,#SATU#,#CSS#,#OUT1#,#OUT2#,#CFL#"); diff --git a/src/test/java/org/traccar/protocol/StarcomProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StarcomProtocolDecoderTest.java index 851d4eac6..84c470970 100644 --- a/src/test/java/org/traccar/protocol/StarcomProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/StarcomProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class StarcomProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new StarcomProtocolDecoder(null); + var decoder = inject(new StarcomProtocolDecoder(null)); verifyPosition(decoder, text( "|unit=416307,unittype=5,address=186.167.243.28,kind=14,software_version=14.02.18,hardware_type=17,gps_type=6,longitude=-67.85891,latitude=10.21988,datetime_actual=2019/05/07 21:59:38,network=TCPIP.1|\r\n")); diff --git a/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java index 5d22344fa..072c19942 100644 --- a/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/StartekProtocolDecoderTest.java @@ -9,7 +9,15 @@ public class StartekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new StartekProtocolDecoder(null); + var decoder = inject(new StartekProtocolDecoder(null)); + + verifyAttribute(decoder, text( + "&&x164,869926040743375,000,0,,220705205955,A,33.326001,44.445318,10,1.2,0,57,8,925,418|40|038C|000083CD,31,00000015,00,00,0016|016A|0000|0000,1,,,686|33||44|99|14|124|11|8D"), + Position.KEY_FUEL_CONSUMPTION, 1.1); + + verifyAttribute(decoder, text( + "&&R187,860294046453690,000,0,,220105160656,A,22.994986,72.499711,15,0.9,2,222,55,121135784,404|98|147B|0000376A,24,0000001F,02,00,052E|01A3|0000|0000,1,010000|020000,,853|6|10|105|73|41|125|34|52"), + Position.KEY_FUEL_LEVEL, null); verifyPosition(decoder, text( "&&o142,860262050066062,000,27,,211111070826,V,28.653435,-106.077455,0,0.0,0,151,1412,918,0|0|4708|01402D19,6,0000001A,02,00,04C0|016C|0000|0000,1,,,BB")); diff --git a/src/test/java/org/traccar/protocol/StartekProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/StartekProtocolEncoderTest.java index 7eeb19edf..f04d0cb67 100644 --- a/src/test/java/org/traccar/protocol/StartekProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/StartekProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class StartekProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeEngineStop() { + public void testEncodeEngineStop() throws Exception { - var encoder = new StartekProtocolEncoder(null); + var encoder = inject(new StartekProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/StbProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/StbProtocolDecoderTest.java index 74b30f9eb..c618ac21c 100644 --- a/src/test/java/org/traccar/protocol/StbProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/StbProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class StbProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new StbProtocolDecoder(null); + var decoder = inject(new StbProtocolDecoder(null)); verifyAttributes(decoder, text( "{\"attrList\":[{\"id\":\"02101001\",\"value\":\"510101051161205774\"},{\"id\":\"02105001\",\"value\":\"-61\"},{\"id\":\"02102001\",\"value\":\"1\"},{\"doorId\":\"1\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"1\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"1\",\"id\":\"02103001\",\"value\":\"0\"},{\"doorId\":\"1\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"2\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"2\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"2\",\"id\":\"02103001\",\"value\":\"0\"},{\"doorId\":\"2\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"3\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"3\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"3\",\"id\":\"02103001\",\"value\":\"0\"},{\"doorId\":\"3\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"4\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"4\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"4\",\"id\":\"02103001\",\"value\":\"0\"},{\"doorId\":\"4\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"5\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"5\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"5\",\"id\":\"02103001\",\"value\":\"1\"},{\"doorId\":\"5\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"6\",\"id\":\"02104001\",\"value\":\"2\"},{\"doorId\":\"6\",\"id\":\"02106001\",\"value\":\"BT106002320JPZZ210718002\"},{\"doorId\":\"6\",\"id\":\"02109001\",\"value\":\"98\"},{\"doorId\":\"6\",\"id\":\"02110001\",\"value\":\"100\"},{\"doorId\":\"6\",\"id\":\"01118001\",\"value\":\"27\"},{\"doorId\":\"6\",\"id\":\"01119001\",\"value\":\"26\"},{\"doorId\":\"6\",\"id\":\"01120001\",\"value\":\"28\"},{\"doorId\":\"6\",\"id\":\"02114001\",\"value\":\"0\"},{\"doorId\":\"6\",\"id\":\"02116001\",\"value\":\"0\"},{\"doorId\":\"6\",\"id\":\"02117001\",\"value\":\"0\"},{\"doorId\":\"6\",\"id\":\"01121001\",\"value\":\"2\"},{\"doorId\":\"6\",\"id\":\"02130001\",\"value\":\"0\"},{\"doorId\":\"6\",\"id\":\"01122001\",\"value\":\"4\"},{\"doorId\":\"6\",\"id\":\"02001001\",\"value\":\"000\"},{\"doorId\":\"6\",\"id\":\"02002001\",\"value\":\"000\"},{\"doorId\":\"6\",\"id\":\"01116001\",\"value\":\"20\"},{\"doorId\":\"6\",\"id\":\"01117001\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117002\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117003\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117004\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117005\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117006\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117007\",\"value\":\"3325\"},{\"doorId\":\"6\",\"id\":\"01117008\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117009\",\"value\":\"3325\"},{\"doorId\":\"6\",\"id\":\"01117010\",\"value\":\"3326\"},{\"doorId\":\"6\",\"id\":\"01117011\",\"value\":\"3326\"},{\"doorId\":\"6\",\"id\":\"01117012\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117013\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117014\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117015\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117016\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117017\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117018\",\"value\":\"3323\"},{\"doorId\":\"6\",\"id\":\"01117019\",\"value\":\"3324\"},{\"doorId\":\"6\",\"id\":\"01117020\",\"value\":\"3323\"},{\"batteryId\":\"BT106002320JPZZ210718002\",\"doorId\":\"6\",\"id\":\"02103001\",\"value\":\"1\"},{\"batteryId\":\"BT106002320JPZZ210718002\",\"doorId\":\"6\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"7\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"7\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"7\",\"id\":\"02103001\",\"value\":\"1\"},{\"doorId\":\"7\",\"id\":\"02118001\",\"value\":\"1\"},{\"doorId\":\"8\",\"id\":\"02104001\",\"value\":\"0\"},{\"doorId\":\"8\",\"id\":\"02106001\",\"value\":\"\"},{\"doorId\":\"8\",\"id\":\"02103001\",\"value\":\"0\"},{\"doorId\":\"8\",\"id\":\"02118001\",\"value\":\"1\"},{\"id\":\"02111001\",\"value\":\"0.0\"},{\"id\":\"02112001\",\"value\":\"0.0\"},{\"id\":\"02107001\",\"value\":\"229.1\"},{\"id\":\"02108001\",\"value\":\"1.005\"},{\"id\":\"02120001\",\"value\":\"143.76\"},{\"id\":\"02113001\",\"value\":\"29\"},{\"id\":\"02119001\",\"value\":\"1\"}],\"devId\":\"CHZD08KPD0210425046\",\"isFull\":1,\"msgType\":310,\"txnNo\":\"1636707944778\"}")); diff --git a/src/test/java/org/traccar/protocol/Stl060ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Stl060ProtocolDecoderTest.java index e13f74604..3ef4b1901 100644 --- a/src/test/java/org/traccar/protocol/Stl060ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Stl060ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Stl060ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Stl060ProtocolDecoder(null); + var decoder = inject(new Stl060ProtocolDecoder(null)); verifyPosition(decoder, text( "$1,357804048043099,D001,AP29AW0963,23/02/14,14:06:54,17248488N,078342226E,0.08,193.12,1,1,1,1,1,A"), diff --git a/src/test/java/org/traccar/protocol/SuntechFrameDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechFrameDecoderTest.java index 99cbeac2f..6d0351a8e 100644 --- a/src/test/java/org/traccar/protocol/SuntechFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SuntechFrameDecoderTest.java @@ -8,7 +8,11 @@ public class SuntechFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SuntechFrameDecoder(); + var decoder = inject(new SuntechFrameDecoder()); + + verifyFrame( + binary("53543330305545583b3531313639393339383b34353b3331353b32303232303632333b31383a32343a35383b3661313332393b2d32392e3735343934373b2d3035372e3038353838353b3030302e3030303b3030302e30303b31303b313b37323b302e30303b3030303030303b31323b0201100110011090011001100110011001100110fe3b39303b3030303030303b332e393b313b30303030303030303030303030303b30"), + decoder.decode(null, null, binary("53543330305545583b3531313639393339383b34353b3331353b32303232303632333b31383a32343a35383b3661313332393b2d32392e3735343934373b2d3035372e3038353838353b3030302e3030303b3030302e30303b31303b313b37323b302e30303b3030303030303b31323b0201100110011090011001100110011001100110fe3b39303b3030303030303b332e393b313b30303030303030303030303030303b300d"))); verifyFrame( binary("81004e05200013383fffff3401000301130a0512080400000000000000000000000047f9d5846a06810072225214010100020300a8002604c1000004b000000470000025a100000000000025c4000000a6"), diff --git a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java index a9720f437..107c03d36 100644 --- a/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SuntechProtocolDecoderTest.java @@ -1,5 +1,6 @@ package org.traccar.protocol; +import org.junit.Ignore; import org.junit.Test; import org.traccar.ProtocolTest; import org.traccar.model.Position; @@ -7,80 +8,20 @@ import org.traccar.model.Position; public class SuntechProtocolDecoderTest extends ProtocolTest { @Test - public void testDecodeTemperature() throws Exception { - - var decoder = new SuntechProtocolDecoder(null); - - decoder.setHbm(true); - decoder.setIncludeAdc(true); - - verifyAttribute(decoder, buffer( - "ST600STT;008594432;20;492;20200212;18:58:30;060bb0e1;334;20;36bb;45;+19.337897;-099.064489;000.398;000.00;12;1;5049883;13.61;100100;2;1198;013762;4.2;1;4.68"), - Position.PREFIX_ADC + 1, 4.68); - - decoder.setIncludeTemp(true); - - verifyAttribute(decoder, buffer( - "ST600STT;008350848;35;523;20191102;13:49:46;0bf14fdb;334;20;2f19;57;+20.466737;-100.825455;000.006;000.00;11;1;10274175;11.36;00000000;1;0300;018353;4.2;1;0.00;;;;00000000000000;0;28EE56B911160234:+13.7;:;:"), - Position.PREFIX_TEMP + 2, 13.7); + public void testDecode() throws Exception { - verifyPosition(decoder, buffer( - "ST300STT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:")); + var decoder = inject(new SuntechProtocolDecoder(null)); verifyPosition(decoder, buffer( - "ST300EVT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;2;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:")); - - verifyPosition(decoder, buffer( - "ST600STT;008349958;35;523;20181112;00:49:30;0bf10d4e;334;20;2f19;22;+20.552718;-100.824478;050.021;095.41;12;1;1303603;14.30;10000000;4;8911;001987;4.1;0;0.00;;;;00000000000000;0;2826C8A70800000C:+26.6;:;:")); - - } - - @Test - public void testDecodeRpm() throws Exception { - - var decoder = new SuntechProtocolDecoder(null); - - decoder.setHbm(true); - decoder.setIncludeRpm(true); + "ALT;0840037569;FFFFFF;84;1.0.6;0;20221228;11:33:05;00004490;724;11;05D3;33;-22.845935;-46.322000;0.00;0.00;18;0;00000001;00000000;99;;;;08E3800F;4.1;12.37;0;0;0;0;4;;;;")); verifyAttribute(decoder, buffer( - "ST300STT;907131077;04;706;20190227;23:59:34;cc719;-12.963490;-038.499587;000.067;000.00;7;1;57095;12.50;000000;1;0337;000207;0.0;1;0;012E717F010000;1"), - Position.KEY_RPM, 0); - - } - - @Test - public void testDecodeHours() throws Exception { - - var decoder = new SuntechProtocolDecoder(null); - - decoder.setHbm(true); - - verifyAttribute(decoder, buffer( - "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); - - } - - @Test - public void testDecodeDriver() throws Exception { - - var decoder = new SuntechProtocolDecoder(null); - - verifyAttribute(decoder, buffer( - "ST300HTE;511050566;45;308;20200909;13:38:38;0;12.50;001354;0.0;1;0;1;1;0;-27.636632;-052.277933;-27.636675;-052.277947;000.000;002.296;0;00000000000000"), - Position.KEY_DRIVER_UNIQUE_ID, "00000000000000"); + "ALT;0950030205;3FFFFF;95;1.0.11;0;20221017;21:41:30;02F2F402;334;20;0F1D;45;+25.791061;-100.170745;0.00;0.00;18;1;00000101;00000000;42;2;"), + Position.KEY_ALARM, Position.ALARM_SOS); verifyAttribute(decoder, buffer( - "ST300HTE;100850001;04;248;20110101;00:13:52;167559;12.28;004005;0.0;1;0;3;3;0;-22.881018;-047.070831;-22.881018;-047.070831;000.000;000.000;0;0;3;0;0;0;01E04D44160000"), - Position.KEY_DRIVER_UNIQUE_ID, "01E04D44160000"); - - } - - @Test - public void testDecode() throws Exception { - - var decoder = new SuntechProtocolDecoder(null); + "RES;4309999001;04;02;TEST"), + Position.KEY_RESULT, "04;02;TEST"); verifyPosition(decoder, buffer( "BLE;1140000053;114;1.0.1;20211001;17:27:09;+28.433465;-82.565891;1;-43;-46;-41;ACB89523EF68;247;0;0")); @@ -91,6 +32,17 @@ public class SuntechProtocolDecoderTest extends ProtocolTest { verifyNull(decoder, buffer( "BSA;0820012345;001FFF;82;1.0.0;1;20191203;17:00:51;+32.691615;-117.297160;1;-55;68:11:6A:FD:1A:A7;6AA5;1DE8")); + verifyAttributes(decoder, binary( + "53543330305545583b3531313639393339383b34353b3331353b32303232303632333b31383a32343a35383b3661313332393b2d32392e3735343934373b2d3035372e3038353838353b3030302e3030303b3030302e30303b31303b313b37323b302e30303b3030303030303b31323b0201100110011090011001100110011001100110fe3b39303b3030303030303b332e393b313b30303030303030303030303030303b30")); + + verifyAttribute(decoder, buffer( + "ST300UEX;511248287;45;311;20220701;18:42:08;14c943;-22.975257;-043.373065;000.000;000.00;0;0;0;12.14;100010;19;RFID:008FB2BEBA39\r\n;3E;000135;4.1;1;00000000000000;0"), + "serial", "RFID:008FB2BEBA39"); + + verifyAttribute(decoder, buffer( + "ST300UEX;100850000;01;010;20081017;07:41:56;2F100;+37.478519;+126.886819;000.012;000.00;9;1;0;15.30;001100;25;Welcome to Suntech World!;12;0;4.5;1"), + "serial", "Welcome to Suntech World!"); + verifyAttribute(decoder, buffer( "ST300UEX;511331307;45;311;20210420;12:41:01;12361;-01.280825;-047.931773;000.000;000.00;16;1;0;12.54;000000;23;GTSL|6|1|0|9255143|2|;6F;000276;0.0;1;00000000000000;0"), Position.KEY_DRIVER_UNIQUE_ID, "9255143"); @@ -257,4 +209,87 @@ public class SuntechProtocolDecoderTest extends ProtocolTest { } + @Ignore + @Test + public void testDecodeCrash() throws Exception { + + var decoder = inject(new SuntechProtocolDecoder(null)); + + verifyAttribute(decoder, binary( + "4352523b303931303030303036333b313b313b303135303b16011c150f0ad82f6c0000000000ae037085fbff7700fd00faff6300f30000006800fb000d007100fa00f32f6c00000000005e044a80fcff6f000301e1ff5d00e900e1ff6400e600f4ff5b00ec000a306c00000000002104248306006c000501fcff5b00e00001006e000101eeff4e00e10022306c00000000005c041a7e00006a00010100005d00f800b5ff7cffdf0050009300fc003b44350d"), + Position.KEY_G_SENSOR, ""); + + } + + @Test + public void testDecodeTemperature() throws Exception { + + var decoder = inject(new SuntechProtocolDecoder(null)); + + decoder.setHbm(true); + decoder.setIncludeAdc(true); + + verifyAttribute(decoder, buffer( + "ST600STT;008594432;20;492;20200212;18:58:30;060bb0e1;334;20;36bb;45;+19.337897;-099.064489;000.398;000.00;12;1;5049883;13.61;100100;2;1198;013762;4.2;1;4.68"), + Position.PREFIX_ADC + 1, 4.68); + + decoder.setIncludeTemp(true); + + verifyAttribute(decoder, buffer( + "ST600STT;008350848;35;523;20191102;13:49:46;0bf14fdb;334;20;2f19;57;+20.466737;-100.825455;000.006;000.00;11;1;10274175;11.36;00000000;1;0300;018353;4.2;1;0.00;;;;00000000000000;0;28EE56B911160234:+13.7;:;:"), + Position.PREFIX_TEMP + 2, 13.7); + + verifyPosition(decoder, buffer( + "ST300STT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:")); + + verifyPosition(decoder, buffer( + "ST300EVT;205173382;07;564;20160322;23:23:18;232e19;+19.288278;-099.128750;000.122;000.00;9;1;478391;11.53;000100;2;1;9498;079324;4.3;1;0.00;0.00;0.00;00000000000000;0;2898E16006000058:-20.8;2861626006000039:+2.5;:")); + + verifyPosition(decoder, buffer( + "ST600STT;008349958;35;523;20181112;00:49:30;0bf10d4e;334;20;2f19;22;+20.552718;-100.824478;050.021;095.41;12;1;1303603;14.30;10000000;4;8911;001987;4.1;0;0.00;;;;00000000000000;0;2826C8A70800000C:+26.6;:;:")); + + } + + @Test + public void testDecodeRpm() throws Exception { + + var decoder = inject(new SuntechProtocolDecoder(null)); + + decoder.setHbm(true); + decoder.setIncludeRpm(true); + + verifyAttribute(decoder, buffer( + "ST300STT;907131077;04;706;20190227;23:59:34;cc719;-12.963490;-038.499587;000.067;000.00;7;1;57095;12.50;000000;1;0337;000207;0.0;1;0;012E717F010000;1"), + Position.KEY_RPM, 0); + + } + + @Test + public void testDecodeHours() throws Exception { + + var decoder = inject(new SuntechProtocolDecoder(null)); + + decoder.setHbm(true); + + verifyAttribute(decoder, buffer( + "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); + + } + + @Test + public void testDecodeDriver() throws Exception { + + var decoder = inject(new SuntechProtocolDecoder(null)); + + verifyAttribute(decoder, buffer( + "ST300HTE;511050566;45;308;20200909;13:38:38;0;12.50;001354;0.0;1;0;1;1;0;-27.636632;-052.277933;-27.636675;-052.277947;000.000;002.296;0;00000000000000"), + Position.KEY_DRIVER_UNIQUE_ID, "00000000000000"); + + verifyAttribute(decoder, buffer( + "ST300HTE;100850001;04;248;20110101;00:13:52;167559;12.28;004005;0.0;1;0;3;3;0;-22.881018;-047.070831;-22.881018;-047.070831;000.000;000.000;0;0;3;0;0;0;01E04D44160000"), + Position.KEY_DRIVER_UNIQUE_ID, "01E04D44160000"); + + } + } diff --git a/src/test/java/org/traccar/protocol/SupermateProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SupermateProtocolDecoderTest.java index 29ec670aa..e96c9b62d 100755 --- a/src/test/java/org/traccar/protocol/SupermateProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SupermateProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SupermateProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SupermateProtocolDecoder(null); + var decoder = inject(new SupermateProtocolDecoder(null)); verifyPosition(decoder, text( "2:359672050130411:1:*,00000000,XT,A,10031b,140b28,80ad4c72,81ba2d2c,06ab,238c,020204010000,12,0,0000,0003e6")); diff --git a/src/test/java/org/traccar/protocol/SviasProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SviasProtocolDecoderTest.java index 8a3a74753..fb9053706 100644 --- a/src/test/java/org/traccar/protocol/SviasProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SviasProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SviasProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SviasProtocolDecoder(null); + var decoder = inject(new SviasProtocolDecoder(null)); verifyPosition(decoder, text( "[7061,3041,57,20324277,710,40618,141342,-93155840,-371754060,0,20469,0,16,1,0,0,11323,100,9,,32,4695")); diff --git a/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java index 10b033985..923b7abfb 100644 --- a/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/SwiftechProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class SwiftechProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new SwiftechProtocolDecoder(null); + var decoder = inject(new SwiftechProtocolDecoder(null)); verifyPosition(decoder, text( "@@861551041946971,,0,102040,1023.9670,N,07606.8160,E,2.26,151220,A,0127,1,1,03962,00000,#")); diff --git a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java index ba981598d..1622f64f2 100644 --- a/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/T55ProtocolDecoderTest.java @@ -9,7 +9,10 @@ public class T55ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new T55ProtocolDecoder(null); + var decoder = inject(new T55ProtocolDecoder(null)); + + verifyPosition(decoder, text( + "$PUBX,00,130209.00,3650.51159,N,01346.10602,E,785.947,D3,4.1,5.2,0.163,87.43,-0.054,7.0,0.88,1.21,0.88,24,01012,0*6D")); verifyPosition(decoder, text( "QZE,868994033976700,35,28062020,113553,22.13673,114.57263,0,22,A,0")); @@ -121,7 +124,7 @@ public class T55ProtocolDecoderTest extends ProtocolTest { // Maxon devices can send NMEA before identification - var decoder = new T55ProtocolDecoder(null); + var decoder = inject(new T55ProtocolDecoder(null)); verifyNull(decoder, text( "$GPRMC,012006,A,4828.10,N,1353.52,E,0.00,0.00,180915,020.3,E*42")); diff --git a/src/test/java/org/traccar/protocol/T57FrameDecoderTest.java b/src/test/java/org/traccar/protocol/T57FrameDecoderTest.java index dd5929b04..40d5bc9e9 100644 --- a/src/test/java/org/traccar/protocol/T57FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/T57FrameDecoderTest.java @@ -8,7 +8,7 @@ public class T57FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new T57FrameDecoder(); + var decoder = inject(new T57FrameDecoder()); verifyFrame( binary("2a5435372346312354353731313137303031233330313131372330303038343323323233342e31333033234e2330383832362e313731342345232b302e3234322c2b302e3130392c2d302e37383923302e30303023362e323030303023413223342e3223"), diff --git a/src/test/java/org/traccar/protocol/T57ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T57ProtocolDecoderTest.java index 376aab1da..2e097562b 100644 --- a/src/test/java/org/traccar/protocol/T57ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/T57ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class T57ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new T57ProtocolDecoder(null); + var decoder = inject(new T57ProtocolDecoder(null)); verifyPosition(decoder, text( "*T57#F1#T571117001#301117#000843#2234.1303#N#08826.1714#E#+0.242,+0.109,-0.789#0.000#6.20000#A2#4.2#")); diff --git a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java index 1dd4e8619..10d0aad59 100644 --- a/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/T800xProtocolDecoderTest.java @@ -9,7 +9,10 @@ public class T800xProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new T800xProtocolDecoder(null); + var decoder = inject(new T800xProtocolDecoder(null)); + + verifyAttributes(decoder, binary( + "2525110055000208677300508924902206262035310c540045004c00430045004c0004454447450847534d20313930300f323134303734323036373835323839143839333430373131373930303936383037363846")); verifyAttributes(decoder, binary( "27271000247bd00860112047066487210407034238000005d7d17365e625ff640a730148")); diff --git a/src/test/java/org/traccar/protocol/T800xProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/T800xProtocolEncoderTest.java index 1d17ee5d5..b2d7c57a2 100644 --- a/src/test/java/org/traccar/protocol/T800xProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/T800xProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class T800xProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new T800xProtocolEncoder(null); + var encoder = inject(new T800xProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java index 56af8830a..36c9d9148 100644 --- a/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TaipProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class TaipProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TaipProtocolDecoder(null); + var decoder = inject(new TaipProtocolDecoder(null)); verifyAttribute(decoder, text( ">RUS00,111220124402-3138067-06417623000012200FF,000000000000000000000000000,0000000111,15640422,00000,+25.5,00000,51;ID=CST3G0443;#IP1:089F;*34<"), diff --git a/src/test/java/org/traccar/protocol/TechTltProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TechTltProtocolDecoderTest.java index c5de8e62a..b4617cb61 100644 --- a/src/test/java/org/traccar/protocol/TechTltProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TechTltProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TechTltProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TechTltProtocolDecoder(null); + var decoder = inject(new TechTltProtocolDecoder(null)); verifyPosition(decoder, text( "002422269*POS=Y,16:21:20,25/11/09,3809.8063N,01444.7438E,4.17,117.23,0.4,09,40076,56341\r\n"), diff --git a/src/test/java/org/traccar/protocol/TechtoCruzFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TechtoCruzFrameDecoderTest.java new file mode 100644 index 000000000..36c3b578b --- /dev/null +++ b/src/test/java/org/traccar/protocol/TechtoCruzFrameDecoderTest.java @@ -0,0 +1,25 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +import static org.junit.Assert.assertEquals; + +public class TechtoCruzFrameDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new TechtoCruzFrameDecoder()); + + assertEquals( + buffer("$$A35,RESPO|G33|8612345678910|CRUZ,*E3"), + decoder.decode(null, null, buffer("$$A35,RESPO|G33|8612345678910|CRUZ,*E3"))); + + assertEquals( + buffer("$$A120,8612345678910,211005105836,A,FLEX,KCB 947C,000.0,0,-1.38047,S,36.93951,E,1648.4,243.140,21,28,12.1,3.7,0,1,0,0,0,*F6"), + decoder.decode(null, null, buffer("$$A120,8612345678910,211005105836,A,FLEX,KCB 947C,000.0,0,-1.38047,S,36.93951,E,1648.4,243.140,21,28,12.1,3.7,0,1,0,0,0,*F6"))); + + } + +} diff --git a/src/test/java/org/traccar/protocol/TechtoCruzProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TechtoCruzProtocolDecoderTest.java index 8f4a7915d..459401469 100644 --- a/src/test/java/org/traccar/protocol/TechtoCruzProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TechtoCruzProtocolDecoderTest.java @@ -8,11 +8,14 @@ public class TechtoCruzProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TechtoCruzProtocolDecoder(null); + var decoder = inject(new TechtoCruzProtocolDecoder(null)); verifyPosition(decoder, text( "$$A120,8612345678910,211005105836,A,FLEX,KCB 947C,000.0,0,-1.38047,S,36.93951,E,1648.4,243.140,21,28,12.1,3.7,0,1,0,0,0,*F6")); + verifyNull(decoder, text( + "$$A35,RESPO|G33|8612345678910|CRUZ,*E3")); + } } diff --git a/src/test/java/org/traccar/protocol/TekFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TekFrameDecoderTest.java index f315e6432..98b2b80c4 100644 --- a/src/test/java/org/traccar/protocol/TekFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TekFrameDecoderTest.java @@ -8,7 +8,7 @@ public class TekFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TekFrameDecoder(); + var decoder = inject(new TekFrameDecoder()); verifyFrame( binary("020315048715E70861074028023219026200400A0340002C007F0009000000000000000000402842064028420641284206402844064128440640284406402844064028440641284406402844060010010C04052B000253000000000001060A0000000000000228330000FF0000FF360014B394"), diff --git a/src/test/java/org/traccar/protocol/TekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TekProtocolDecoderTest.java index a371ffe6b..17910a8d6 100644 --- a/src/test/java/org/traccar/protocol/TekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TekProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TekProtocolDecoder(null); + var decoder = inject(new TekProtocolDecoder(null)); verifyPosition(decoder, binary( "0501E304E00E76086107502100455111492C33332C3137303935342E302C353235352E393933344E2C30303833322E34333935572C322E312C3133342E382C322C302E30302C302E302C302E302C3234303931352C30362C3C45")); diff --git a/src/test/java/org/traccar/protocol/TelemaxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TelemaxProtocolDecoderTest.java index 8c3650f4e..9f36b3f96 100644 --- a/src/test/java/org/traccar/protocol/TelemaxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TelemaxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TelemaxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TelemaxProtocolDecoder(null); + var decoder = inject(new TelemaxProtocolDecoder(null)); verifyNull(decoder, text( "%067374070128")); diff --git a/src/test/java/org/traccar/protocol/TelicFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TelicFrameDecoderTest.java index 125b61d48..dc6cc58c6 100644 --- a/src/test/java/org/traccar/protocol/TelicFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TelicFrameDecoderTest.java @@ -8,7 +8,7 @@ public class TelicFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TelicFrameDecoder(); + var decoder = inject(new TelicFrameDecoder()); verifyFrame( binary("303032363230333339337c3232367c31307c303032303034303130"), diff --git a/src/test/java/org/traccar/protocol/TelicProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TelicProtocolDecoderTest.java index 03824d91b..214bb06c7 100644 --- a/src/test/java/org/traccar/protocol/TelicProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TelicProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TelicProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TelicProtocolDecoder(null); + var decoder = inject(new TelicProtocolDecoder(null)); verifyNull(decoder, text( "0026355565071347499|206|01|001002008")); diff --git a/src/test/java/org/traccar/protocol/TeltonikaFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaFrameDecoderTest.java index 7787907b6..adc768460 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaFrameDecoderTest.java @@ -8,10 +8,10 @@ public class TeltonikaFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TeltonikaFrameDecoder(); + var decoder = inject(new TeltonikaFrameDecoder()); verifyFrame( - binary("000F313233343536373839303132333435"), + binary("ff"), decoder.decode(null, null, binary("FF000F313233343536373839303132333435"))); verifyFrame( diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java index 082d410c2..ba64642f2 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolDecoderTest.java @@ -9,12 +9,27 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TeltonikaProtocolDecoder(null, false); + var decoder = inject(new TeltonikaProtocolDecoder(null, false)); verifyNull(decoder, binary( "000F313233343536373839303132333435")); verifyPositions(decoder, binary( + "00000000000000a28e0100000183ac617e3001123eb99b1e142db4000000000000000000001d000900f000005000001503004500011e1801212d01242a012722012a18001100b5000000b600000018000000cd151000431c2d011f6981012047d701226981012347d901256981012647d8012869810129e6f304b0000304b1000304b2000304b30003000100f10000639d0002000b0000000214bf12fe000e0000000029d18c95000001000051b6")); + + verifyPositions(decoder, binary( + "00000000000004258e0400000182a701b49301d5d90ab7ebe4aae101be003d12000000f7003d000e00f70100ef0000f00000500500150200c800004501000100001d00001400001600001700007157010701001d00b5000b00b60006004230400018000000cd223f00ce741700430f8900440000000d00010011ffe50012001f0013ffce000f03e800190bb8001a0bb8001b0bb8001c0bb800560bb800680bb8006a0bb8006c0bb8010e0000011100000114000001170000014f0000015000000151000001520000000a00f100011d2a00c700000000001000b9addc000c0000acb600040000000001320000000001330000000001340000000001350000000001c1000000000003000b000000d14675f36000ee0000000000000000000e0000000003fd509f0005014b0000014c0000014d0000014e0000018300222d3333373333382e0100000053a6fb624588040001ba86064f0eae51c0fdaf4d3de500000182a701b82001d5d90ab7ebe4aae101be003d12000000f0003c000d00ef0000f00100500500150200c800004501000100001d00001400001600001700007152010701001d00b5000900b60006004217e50018000000cd223f00ce741700430f5c00440000000d00010011fed60012fd1d0013f1f2000f03e800190bb8001a0bb8001b0bb8001c0bb800560bb800680bb8006a0bb8006c0bb8010e0000011100000114000001170000014f0000015000000151000001520000000a00f100011d2a00c700000000001000b9addc000c0000acb600040000000001320000000001330000000001340000000001350000000001c1000000000003000b000000d14675f36000ee0000000000000000000e0000000003fd509f0005014b0000014c0000014d0000014e0000018300222d3333373333352e353833332d303730373139362e323333332b3030302e3434362f00000182a701bc0801d5d90ab7ebe4aae101be003d12000000fc003d000e00ef0000f00100500500150200c800004501000100001d0000140000160000170000714d01070100fc01001d00b5000900b60006004217e50018000000cd223f00ce741700430f5c00440000000d00010011fed60012fd1d0013f1f2000f03e800190bb8001a0bb8001b0bb8001c0bb800560bb800680bb8006a0bb8006c0bb8010e0000011100000114000001170000014f0000015000000151000001520000000a00f100011d2a00c700000000001000b9addc000c0000acb600040000000001320000000001330000000001340000000001350000000001c1000000000003000b000000d14675f36000ee0000000000000000000e0000000003fd509f0005014b0000014c0000014d0000014e0000018300222d3333373333352e353833332d303730373139362e323333332b3030302e3434362f00000182a7018d8d01d5d8ffa6ebe4a0ca01be006111000000f70001000100f70500000000000000000400003a10")); + + verifyPositions(decoder, binary( + "00000000000003831004000001735ace37f80000e3b9331c71e290006900e211005100fd072e1600010100160300470300f00100150400b20000c80000ef01009000004f00005101005201005300005538006e00006f00007a03007d00007f5600890000fd0200fe1f09004326b00044000000b5000b00b6000600427029001800540046015d00ce4ec10080000f0f00f10000515400cd007404ab00d80f5022a1005000000054005400000000005600015568005700000060005800000420006800001113006d303330300071fffd8c85008700000020008800000002008a000155f5008b0000b86000000001735ace3ca80000e3b08a1c71dd29006900e311005100fd072e1600010100160300470300f00100150400b20000c80000ef01009000004f00005101005201005300005537006e00006f00007a03007d00007f5600890000fd0200fe1d09004326ac0044000000b5000b00b600060042701f001800540046015d00ce4ec10080000f0f00f10000515400cd007404ab00d80f5022ce00500000005400540000000000560001556800570000006000580000041f006800001113006d303330300071fffd8c85008700000020008800000002008a000155f5008b0000b86000000001735ace3fc80000e3a7c01c71d7c2006900e311005100fd072e1600010100160300470300f00100150400b20000c80000ef01009000004f00005101005201005300005537006e00006f00007a03007d00007f5600890000fd0200fe2309004326ac0044000000b5000b00b6000600427015001800540046015e00ce4ec10080000f0f00f10000515400cd007404ab00d80f5022e700500000005400540000000000560001556800570000006000580000041f006800001113006d303330300071fffd8c85008700000020008800000002008a000155f5008b0000b86000000001735ace3ffa0000e3a7c01c71d7c2006900e311005100fd072e1600010100160300470300f00100150400b20000c80000ef01009000004f00005101005201005300005537006e00006f00007a03007d00007f5600890000fd0300fe2309004326ac0044000000b5000b00b6000600427015001800540046015e00ce4ec10080000f0f00f10000515400cd007404ab00d80f5022e700500000005400540000000000560001556800570000006000580000041f006800001113006d303330300071fffd8c85008700000020008800000002008a000155f5008b0000b86000040000eb85")); + + verifyPositions(decoder, binary( + "00000000000000e708030000018293d62060000de1f6a62159767e00000000000000000b074504f00050041500c801ef004f630342320043000344000001f100006019000000018291b0c790000de1f6a62159767e006e0144070000ef12074503f00050051505c800ef004f0207b5000eb6000b423324180000ce00dc43001144000004c700000007f100006019cd0003c7776300ea4e2e000000018291aff0b8000de1f91f21597405006f00f61300080012074503f00150051504c800ef014f0207b50009b600054236c1180008ce00dc43003f44000004c700000003f100006019cd0003c7776300ea4e2700030000a48d")); + + verifyPositions(decoder, binary( + "00000000000000da08030000017fcedf499600280431be0eded45d0038012d100000fa100901000200b300b4004501500415034702fa00054232a1180000cd3b2fce281d43001f02c700000006f10000a029000000017fcedea99600280432070eded3dd00380046130009000f0801010200b300b400450150051502470205423276180009cd3b2fce281d43001f02c700000027f10000a0290000000179d50853180027f65d3f0ed67212001500f1110061000f0801010200b300b4004501500515034702054234f4180061cd53d1ce28c043003e02c700000147f1000000290003000052cb")); + + verifyPositions(decoder, binary( "00000000000000b98e0200000179555c7bf8010b3a1cfbebc142b00000000000000000ec000f000900f00000150000c80000450200710100740001070100fa0000ec01000500b500000018000000430d560044000000190000000100f1000000000000000000000179555c83c8010b3a1cfbebc142b0000000000000000185000f000900f00000150000c80000450200710100740001070100fa00018511000500b500000018000000430d560044000000190000000100f100000000000000000200003251")); verifyPositions(decoder, binary( @@ -110,6 +125,9 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "000000000000004a08010000015ebc1da508002411926621f15246010b00b913005e000f06ef01f00150011505c800450108b5000bb6000642381b18005ecd0318ce19cd430f5844000001f1000061a900010000c8e1")); + verifyNull(decoder, binary( + "ff")); + decoder.setExtended(true); verifyPositions(decoder, false, binary( @@ -124,7 +142,7 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { @Test public void testDecodePhoto() throws Exception { - var decoder = new TeltonikaProtocolDecoder(null, false); + var decoder = inject(new TeltonikaProtocolDecoder(null, false)); verifyNull(decoder, binary( "000F313233343536373839303132333435")); @@ -144,7 +162,7 @@ public class TeltonikaProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeConnectionless() throws Exception { - var decoder = new TeltonikaProtocolDecoder(null, true); + var decoder = inject(new TeltonikaProtocolDecoder(null, true)); verifyPositions(decoder, false, binary( "0049cafe0122000f33353734353430373237313339373508010000015d3766f6a800003eef961ec6215e0063006d09003100070401000200f001c8000242381c18003201c7000000e10001")); diff --git a/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java index 008a2b9dd..d7e1149aa 100644 --- a/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/TeltonikaProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class TeltonikaProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new TeltonikaProtocolEncoder(null); + var encoder = inject(new TeltonikaProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/TeraTrackProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TeraTrackProtocolDecoderTest.java new file mode 100644 index 000000000..fc66f53bb --- /dev/null +++ b/src/test/java/org/traccar/protocol/TeraTrackProtocolDecoderTest.java @@ -0,0 +1,21 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class TeraTrackProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new TeraTrackProtocolDecoder(null)); + + verifyAttributes(decoder, text( + "{\"MDeviceID\":\"022043756090\",\"DiviceType\":\"1\",\"DataType\":\"1\",\"DataLength\":\"69\",\"DateTime\":\"2022-03-09 10:56:01\",\"Latitude\":\"-6.846451\",\"Longitude\":\"39.316324\",\"LongitudeState\":\"1\",\"LatitudeState\":\"0\",\"Speed\":\"90\",\"Mileage\":\"0\",\"FenceAlarm\":\"0\",\"AreaAlarmID\":\"0\",\"LockCutOff\":\"0\",\"SealTampered\":\"0\",\"MessageAck\":\"1\",\"LockRope\":\"1\",\"LockStatus\":\"1\",\"LockOpen\":\"0\",\"PasswordError\":\"0\",\"CardNo\":\"60000644\",\"IllegalCard\":\"0\",\"LowPower\":\"0\",\"UnCoverBack\":\"0\",\"CoverStatus\":\"1\",\"LockStuck\":\"0\",\"Power\":\"79\",\"GSM\":\"16\",\"IMEI\":\"860922043756090\",\"Index\":\"20\",\"Slave\":[]}")); + + verifyAttributes(decoder, text( + "{\"MDeviceID\":\"074054558620\",\"DeviceType\":\"1\",\"DataType\":\"2\",\"DataLength\":\"0913\",\"DateTime\":\"2022-02-22 23:35:35\",\"Latitude\":\"-6.826699\",\"Longitude\":\"39.279008\",\"LatitudeState\":\"0\",\"LongitudeState\":\"1\",\"Speed\":\"0\",\"Mileage\":\"0\",\"FenceAlarm\":\"0\",\"AreaAlarmID\":\"0\",\"LockCutOff\":\"0\",\"SealTempered\":\"1\",\"MessageAck\":\"1\",\"LockRope\":\"0\",\"LockStatus\":\"0\",\"LockOpen\":\"1\",\"PasswordError\":\"0\",\"CardNo\":\"60060198\",\"IllegalCard\":\"0\",\"LowPower\":\"0\",\"UnCoverBack\":\"1\",\"CoverStatus\":\"0\",\"LockStuck\":\"1\",\"Power\":\"90\",\"GSM\":\"14\",\"IMEI\":\"861774054558620\",\"Index\":\"39\",\"Slave\":[{\"SDeviceId\":\"685304\",\"SPower\":\"00\",\"SLockCutOff\":\"0\",\"SLockOpen\":\"1\",\"SUnCoverBack\":\"0\",\"SCoverStatus\":\"1\",\"STimeOut\":\"1\",\"SLockRope\":\"0\",\"SSealTempered\":\"0\",\"SLockStuck\":\"0\"},{\"SDeviceId\":\"224779\",\"SPower\":\"00\",\"SLockCutOff\":\"0\",\"SLockOpen\":\"1\",\"SUnCoverBack\":\"0\",\"SCoverStatus\":\"1\",\"STimeOut\":\"1\",\"SLockRope\":\"0\",\"SSealTempered\":\"0\",\"SLockStuck\":\"0\"}]}")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/ThinkPowerProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ThinkPowerProtocolDecoderTest.java index ff808e667..2085112ec 100644 --- a/src/test/java/org/traccar/protocol/ThinkPowerProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ThinkPowerProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ThinkPowerProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ThinkPowerProtocolDecoder(null); + var decoder = inject(new ThinkPowerProtocolDecoder(null)); verifyNull(decoder, binary( "0103002C01020F38363737333030353038323030343606544C3930344111522D312E302E31372E32303231303431300011C3")); diff --git a/src/test/java/org/traccar/protocol/ThinkRaceProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ThinkRaceProtocolDecoderTest.java index 39e7ed473..859dd4f89 100644 --- a/src/test/java/org/traccar/protocol/ThinkRaceProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/ThinkRaceProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class ThinkRaceProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new ThinkRaceProtocolDecoder(null); + var decoder = inject(new ThinkRaceProtocolDecoder(null)); verifyNull(decoder, binary( "48415349483031343730303134382C8000100134363030303134363139363239343806FF")); diff --git a/src/test/java/org/traccar/protocol/ThurayaProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/ThurayaProtocolDecoderTest.java new file mode 100644 index 000000000..90431fa24 --- /dev/null +++ b/src/test/java/org/traccar/protocol/ThurayaProtocolDecoderTest.java @@ -0,0 +1,24 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class ThurayaProtocolDecoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + var decoder = inject(new ThurayaProtocolDecoder(null)); + + verifyPositions(decoder, binary( + "235400437101072bca3c0201348b9a00014c9f085493fc02200c5411470000000042323a300001348b9a00014d03085493ea02200c5010000000000042323a3000f2c1")); + + verifyPosition(decoder, binary( + "2354002b5101072bca3c01348b9a00013fba000000000000000010000000000042323a3000174f4e00f9de")); + + verifyNull(decoder, binary( + "235400d88115071e37d691030133342e3233362e3133302e3637000000001e56313030320030000700080102030405060708020101010101020201030103030302020000007800000078000004b000001c20050a64000015b3800015b374657374696e67003132333435360002010f28393031303539383938303134373738000043383a592c43373a592c43333a592c43323a592c43313a592c42353a592c42343a592c42323a592c42313a592c41323a592c41313a590045313a592c45373a590065746973616c61742e61650047455400322e3130d6de")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/Tk102ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tk102ProtocolDecoderTest.java index 2185fda29..3bcc9994a 100644 --- a/src/test/java/org/traccar/protocol/Tk102ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tk102ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Tk102ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tk102ProtocolDecoder(null); + var decoder = inject(new Tk102ProtocolDecoder(null)); verifyNull(decoder, buffer( "[\u00800000000000\u000821315452]")); diff --git a/src/test/java/org/traccar/protocol/Tk103FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Tk103FrameDecoderTest.java index 57df2ac5b..87c3d9317 100644 --- a/src/test/java/org/traccar/protocol/Tk103FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tk103FrameDecoderTest.java @@ -9,7 +9,7 @@ public class Tk103FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tk103FrameDecoder(); + var decoder = inject(new Tk103FrameDecoder()); verifyFrame( binary("283836343735353535353535353535352C445733422C3133313131372C412C353536322E30323837304E2C30313334382E3038313934452C312E3539372C3232333730372C3239312E36352C2D302E31302C3429"), diff --git a/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java index 321d0cb50..8b3177136 100644 --- a/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tk103ProtocolDecoderTest.java @@ -9,7 +9,13 @@ public class Tk103ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tk103ProtocolDecoder(null); + var decoder = inject(new Tk103ProtocolDecoder(null)); + + verifyAttributes(decoder, text( + "(027046434858BZ00,{460,0,20949,58711}\n{460,0,20494,54003}\n{460,0,20951,19569}\n,01000000)")); + + verifyAttributes(decoder, text( + "(027045009305BP05355227045009305,{413,2,30073,16724}\n{413,2,30073,16730}\n{413,2,30073,49860}\n,01000000)")); verifyPosition(decoder, text( "(868822040452227,DW3B,150421,A,4154.51607N,45.78950E,0.050,103142,0.000,595.200,7,0)")); diff --git a/src/test/java/org/traccar/protocol/Tk103ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Tk103ProtocolEncoderTest.java index c34674128..359e432c7 100644 --- a/src/test/java/org/traccar/protocol/Tk103ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Tk103ProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class Tk103ProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodeOutputControl() { + public void testEncodeOutputControl() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -23,9 +23,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeEngineStop() { + public void testEncodeEngineStop() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -36,9 +36,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionSingle() { + public void testEncodePositionSingle() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -49,9 +49,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionPeriodic() { + public void testEncodePositionPeriodic() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -63,9 +63,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionStop() { + public void testEncodePositionStop() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -76,9 +76,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeGetVersion() { + public void testEncodeGetVersion() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -89,9 +89,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeRebootDevice() { + public void testEncodeRebootDevice() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -102,9 +102,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeSetOdometer() { + public void testEncodeSetOdometer() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -115,9 +115,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionSingleAlternative() { + public void testEncodePositionSingleAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -128,9 +128,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionPeriodicAlternative() { + public void testEncodePositionPeriodicAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -141,9 +141,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodePositionStopAlternative() { + public void testEncodePositionStopAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -154,9 +154,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeGetVersionAlternative() { + public void testEncodeGetVersionAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -167,9 +167,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeRebootDeviceAlternative() { + public void testEncodeRebootDeviceAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -180,9 +180,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeIdentificationAlternative() { + public void testEncodeIdentificationAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -193,9 +193,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeSosOnAlternative() { + public void testEncodeSosOnAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -207,9 +207,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeSosOffAlternative() { + public void testEncodeSosOffAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -221,9 +221,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeCustom() { + public void testEncodeCustom() throws Exception { - var encoder = new Tk103ProtocolEncoder(null); + var encoder = inject(new Tk103ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -235,9 +235,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeCustomAlternative() { + public void testEncodeCustomAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -249,9 +249,9 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeSetConnectionAlternative() { + public void testEncodeSetConnectionAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); @@ -264,14 +264,14 @@ public class Tk103ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeSosNumberAlternative() { + public void testEncodeSosNumberAlternative() throws Exception { - var encoder = new Tk103ProtocolEncoder(null, true); + var encoder = inject(new Tk103ProtocolEncoder(null, true)); Command command = new Command(); command.setDeviceId(1); command.setType(Command.TYPE_SOS_NUMBER); - command.set(Command.KEY_INDEX, "0"); + command.set(Command.KEY_INDEX, 0); command.set(Command.KEY_PHONE, "+55555555555"); command.set(Command.KEY_DEVICE_PASSWORD, "232323"); diff --git a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java index b747fa960..a6a9f836e 100644 --- a/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tlt2hProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tlt2hProtocolDecoder(null); + var decoder = inject(new Tlt2hProtocolDecoder(null)); verifyNull(decoder, text( "#860517049471362#MT700#0000#AUTO#1\r\n", @@ -81,6 +81,13 @@ public class Tlt2hProtocolDecoderTest extends ProtocolTest { "#357671031289215#V600#0000#AUTOLOW#1\r\n", "#00735e1c$GPRMC,115647.000,A,5553.6524,N,02632.3128,E,0.00,0.0,130614,0.0,W,A*28")); + verifyPositions(decoder, false, text( + "#860186058100000#MT700#0000#AUTO#1\r\n", + "#39#262,03,8CE6,A672$WIFI,154928.00,A,-74,3CA62F52615B,-82,A0E4CB83852D,,,050123*28\r\n##\r\n")); + + verifyPositions(decoder, false, text( + "#860186058100000#MT700#0000#AUTO#1\r\n", + "#39#262,03,8CE6,A672$GPRMC,115419.00,V,,,,,,,050123,,,A*7D\r\n##\r\n")); } } diff --git a/src/test/java/org/traccar/protocol/TlvProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TlvProtocolDecoderTest.java index 54d66dac9..d6d1b7275 100644 --- a/src/test/java/org/traccar/protocol/TlvProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TlvProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TlvProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TlvProtocolDecoder(null); + var decoder = inject(new TlvProtocolDecoder(null)); verifyNull(decoder, binary( "30430f383630323437303330303934333931ff10393233323132323030303834353433340f533636385f415f56312e30315f454eff1130303a30433a45373a30303a30303a30300132")); diff --git a/src/test/java/org/traccar/protocol/TmgFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TmgFrameDecoderTest.java index 886470745..9cdcb6169 100644 --- a/src/test/java/org/traccar/protocol/TmgFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TmgFrameDecoderTest.java @@ -8,7 +8,7 @@ public class TmgFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TmgFrameDecoder(); + var decoder = inject(new TmgFrameDecoder()); verifyNull( decoder.decode(null, null, binary("2424242424"))); diff --git a/src/test/java/org/traccar/protocol/TmgProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TmgProtocolDecoderTest.java index 722df5306..6d3c36005 100644 --- a/src/test/java/org/traccar/protocol/TmgProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TmgProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TmgProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TmgProtocolDecoder(null); + var decoder = inject(new TmgProtocolDecoder(null)); verifyPosition(decoder, text( "$loc,869309013800417,08032014,094459,1,2826.1956,N,07659.7690,E,0.0,2.5,4441,31,6,95,1,LLLL,NNTN,HH,0.15,0.26,HR38AU1389,0,SW0.1a")); diff --git a/src/test/java/org/traccar/protocol/TopflytechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TopflytechProtocolDecoderTest.java index dbc7210e0..b49345a42 100644 --- a/src/test/java/org/traccar/protocol/TopflytechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TopflytechProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TopflytechProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TopflytechProtocolDecoder(null); + var decoder = inject(new TopflytechProtocolDecoder(null)); verifyPosition(decoder, text( "(880316890094910BP00XG00b600000000L00074b54S00000000R0C0F0014000100f0130531152205A0706.1395S11024.0965E000.0251.25")); diff --git a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java index 331be974c..5e7ec1136 100644 --- a/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TopinProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class TopinProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TopinProtocolDecoder(null); + var decoder = inject(new TopinProtocolDecoder(null)); verifyNull(decoder, binary( "787801080D0A")); @@ -18,6 +18,10 @@ public class TopinProtocolDecoderTest extends ProtocolTest { "78780d0103593390754169634d0d0a")); verifyAttribute(decoder, binary( + "7878006921120412565802010601071e4a9764071e4a9864010d0a"), + Position.KEY_ALARM, Position.ALARM_VIBRATION); + + verifyAttribute(decoder, binary( "787801940D0A"), Position.KEY_ALARM, Position.ALARM_VIBRATION); diff --git a/src/test/java/org/traccar/protocol/TopinProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/TopinProtocolEncoderTest.java index d3ff13941..a69f389ac 100644 --- a/src/test/java/org/traccar/protocol/TopinProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/TopinProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class TopinProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new TopinProtocolEncoder(null); + var encoder = inject(new TopinProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/TotemFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TotemFrameDecoderTest.java index 95949c51b..175c32848 100644 --- a/src/test/java/org/traccar/protocol/TotemFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TotemFrameDecoderTest.java @@ -8,7 +8,7 @@ public class TotemFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TotemFrameDecoder(); + var decoder = inject(new TotemFrameDecoder()); verifyFrame( binary("24243030323542423836323031303033373239343836313345"), diff --git a/src/test/java/org/traccar/protocol/TotemProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TotemProtocolDecoderTest.java index e16774782..df5734568 100644 --- a/src/test/java/org/traccar/protocol/TotemProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TotemProtocolDecoderTest.java @@ -8,7 +8,10 @@ public class TotemProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TotemProtocolDecoder(null); + var decoder = inject(new TotemProtocolDecoder(null)); + + verifyPosition(decoder, text( + "$$0111AA353081090067318|0804400022070722520240400005B364ED5003107300001.700000002245.3919N10231.6952W000001860E")); verifyPosition(decoder, text( "$$0112E5864606045334223|201112223514,-68.923106,-22.455926,$Cloud,1738,621,730,12100,0,0,255,0,40,40,0,0,255,|13")); diff --git a/src/test/java/org/traccar/protocol/TotemProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/TotemProtocolEncoderTest.java index 51e5bac92..97a044b51 100644 --- a/src/test/java/org/traccar/protocol/TotemProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/TotemProtocolEncoderTest.java @@ -11,14 +11,28 @@ public class TotemProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new TotemProtocolEncoder(null); + var encoder = inject(new TotemProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(2); - command.setType(Command.TYPE_ENGINE_STOP); + command.setType(Command.TYPE_REBOOT_DEVICE); command.set(Command.KEY_DEVICE_PASSWORD, "000000"); - assertEquals("*000000,025,C,1#", encoder.encodeCommand(command)); + assertEquals("$$0020CF000000,0061D", encoder.encodeCommand(command)); + + } + + @Test + public void testSmsEncode() throws Exception { + + var encoder = inject(new TotemProtocolSmsEncoder(null)); + + Command command = new Command(); + command.setDeviceId(2); + command.setType(Command.TYPE_REBOOT_DEVICE); + command.set(Command.KEY_DEVICE_PASSWORD, "000000"); + + assertEquals("*000000,006#", encoder.encodeCommand(command)); } diff --git a/src/test/java/org/traccar/protocol/Tr20ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tr20ProtocolDecoderTest.java index def280b04..e4917c872 100644 --- a/src/test/java/org/traccar/protocol/Tr20ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tr20ProtocolDecoderTest.java @@ -8,7 +8,10 @@ public class Tr20ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tr20ProtocolDecoder(null); + var decoder = inject(new Tr20ProtocolDecoder(null)); + + verifyPosition(decoder, text( + "%%m13,L,221221103115,N1237.2271W00801.9500,000,000,B13.1:F0.0,04020000,253,CFG:133.00|")); verifyPosition(decoder, text( "%%TR20GRANT,L,210602170135,N0951.1733W08356.7672,000,000,C80:F0,00020008,108,CFG:6980.00|")); diff --git a/src/test/java/org/traccar/protocol/Tr900ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tr900ProtocolDecoderTest.java index d3d35b356..96ddf4175 100644 --- a/src/test/java/org/traccar/protocol/Tr900ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tr900ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Tr900ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tr900ProtocolDecoder(null); + var decoder = inject(new Tr900ProtocolDecoder(null)); verifyPosition(decoder, text( ">00001001,4,1,150626,131252,W05830.2978,S3137.2783,,00,348,18,00,003-000,0,3,11111011*3b!"), diff --git a/src/test/java/org/traccar/protocol/TrackboxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TrackboxProtocolDecoderTest.java index caac520e1..10603db1c 100644 --- a/src/test/java/org/traccar/protocol/TrackboxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TrackboxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TrackboxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TrackboxProtocolDecoder(null); + var decoder = inject(new TrackboxProtocolDecoder(null)); verifyNull(decoder, text( "a=connect&v=11&i=111111111111111")); diff --git a/src/test/java/org/traccar/protocol/TrakMateProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TrakMateProtocolDecoderTest.java index ef99527d7..7542b3456 100644 --- a/src/test/java/org/traccar/protocol/TrakMateProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TrakMateProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TrakMateProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TrakMateProtocolDecoder(null); + var decoder = inject(new TrakMateProtocolDecoder(null)); verifyPosition(decoder, text( "^TMSTP|352984083995323|116|13.07809|77.55979|131508|131118|0.0|146.51|7|0|71 -2 248|0|13.1|0.0|10.5|1|0|0|0|#")); diff --git a/src/test/java/org/traccar/protocol/TramigoFrameDecoderTest.java b/src/test/java/org/traccar/protocol/TramigoFrameDecoderTest.java index 80e6a6e81..a093d94e9 100644 --- a/src/test/java/org/traccar/protocol/TramigoFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TramigoFrameDecoderTest.java @@ -8,7 +8,7 @@ public class TramigoFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TramigoFrameDecoder(); + var decoder = inject(new TramigoFrameDecoder()); verifyFrame( binary("8000ed2bb0009c000101bee000050b09633d925b5472616d69676f3a205472697020737461727465642c2053686f636b2053656e736f722c206174204b696e6720437265656b20526f61642d46726565746f776e205374726565742c20506f727420486172636f7572742c205269766572732c204e472c20342e37363336312c20372e30313836382c2030373a31383a333620536570203320454f46"), diff --git a/src/test/java/org/traccar/protocol/TramigoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TramigoProtocolDecoderTest.java index 8b556b356..c2d13d199 100644 --- a/src/test/java/org/traccar/protocol/TramigoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TramigoProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TramigoProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TramigoProtocolDecoder(null); + var decoder = inject(new TramigoProtocolDecoder(null)); verifyAttributes(decoder, binary( "8000c426b000a6000101c557037598050d5c8a595472616d69676f3a204d6f76696e672c20302e3132206b6d2045206f66204c617275742054696e2049736c616d6963205072696d617279205363686f6f6c2c2054616970696e672c20506572616b2c204d592c20342e38333134392c203130302e37333038352c204e572077697468207370656564203130206b6d2f682c2030303a34393a30382041756720392020454f46")); diff --git a/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java index 44735abcb..6dc28d89e 100644 --- a/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TrvProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TrvProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TrvProtocolDecoder(null); + var decoder = inject(new TrvProtocolDecoder(null)); verifyNull(decoder, text( "TRVAP00352121088015548")); @@ -65,6 +65,9 @@ public class TrvProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "TRVAP10080524A2232.9806N11404.9355E000.1061830323.8706000908000502,460,0,9520,3671,00,zh-cn,00")); + verifyPosition(decoder, text( + "TRVYP14220217A5235.7885N00724.1840E000.0130919177.561000050660000200004,262,01,14635,52789,FritzBox7|DC-39-8F-7E-94-73|-89&FritzBox7|24-4E-5D-71-C3-9C|-90&MY_IOT|80-B4-F7-77-9C-7C|-81&MYAP|44-D4-F7-77-9C-7C|-80#")); + } } diff --git a/src/test/java/org/traccar/protocol/Tt8850ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Tt8850ProtocolDecoderTest.java index 5d0e86a3f..3f5c60daa 100644 --- a/src/test/java/org/traccar/protocol/Tt8850ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Tt8850ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Tt8850ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Tt8850ProtocolDecoder(null); + var decoder = inject(new Tt8850ProtocolDecoder(null)); verifyPosition(decoder, text( "\u0000\u0004,007F,0,GTFRI,020102,867844000667538,4142726856,0,0,1,3,1.6,0,997.3,-66.830786,10.483394,20171212171418,0734,0004,041A,4220,69,20171212171657,FF61")); diff --git a/src/test/java/org/traccar/protocol/TytanProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TytanProtocolDecoderTest.java index 1cab0f8b1..de6f3a6ff 100644 --- a/src/test/java/org/traccar/protocol/TytanProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TytanProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class TytanProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TytanProtocolDecoder(null); + var decoder = inject(new TytanProtocolDecoder(null)); verifyPositions(decoder, binary( "B500192000001405125652CA9B1A325FC98D11A9990018020118FC0D")); diff --git a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java index fba8f7db4..4a861fb06 100644 --- a/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/TzoneProtocolDecoderTest.java @@ -8,7 +8,10 @@ public class TzoneProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new TzoneProtocolDecoder(null); + var decoder = inject(new TzoneProtocolDecoder(null)); + + verifyAttributes(decoder, binary( + "545a003724240407020200000180322000001610160b151019100000000c010a07320101088600007dca000baa102837016a0114025500000169e80d0a")); verifyAttributes(decoder, binary( "545a004d24240407010d0000018032100000031515090c052c2100000022030a033400201347000056860a03340020134700002feb0a03340020134700007d96000baa10211f01810127022d000001ebe00d0a")); diff --git a/src/test/java/org/traccar/protocol/UlbotechFrameDecoderTest.java b/src/test/java/org/traccar/protocol/UlbotechFrameDecoderTest.java index 77afbb50f..534287e0a 100644 --- a/src/test/java/org/traccar/protocol/UlbotechFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UlbotechFrameDecoderTest.java @@ -8,7 +8,7 @@ public class UlbotechFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new UlbotechFrameDecoder(); + var decoder = inject(new UlbotechFrameDecoder()); verifyFrame( binary("f8010103515810532780699f7e2e3f010e015ee4c906bde45c00000000008b0304004000000404002c776005060373193622110b00240b00fee8ffff807dffff606d0b00fee9af000000af0000000b00feee7d78807dffffffff100101cc2af8"), diff --git a/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java index b7c6d2d45..52f2520cc 100644 --- a/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UlbotechProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class UlbotechProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new UlbotechProtocolDecoder(null); + var decoder = inject(new UlbotechProtocolDecoder(null)); verifyPosition(decoder, binary( "f801010353323083177450a703f6f0010efe55a31a0923d01400050070007003040a42000004040070cca00506039b1876220f060800000000000000000725310553410c0c9e310d05310f4641100440311119411f00476101810f8000310487411f00480804203a14c009033320159310f8")); diff --git a/src/test/java/org/traccar/protocol/UlbotechProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/UlbotechProtocolEncoderTest.java index 288f8dc70..50e9321ce 100644 --- a/src/test/java/org/traccar/protocol/UlbotechProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/UlbotechProtocolEncoderTest.java @@ -7,9 +7,9 @@ import org.traccar.model.Command; public class UlbotechProtocolEncoderTest extends ProtocolTest { @Test - public void testEncode() { + public void testEncode() throws Exception { - var encoder = new UlbotechProtocolEncoder(null); + var encoder = inject(new UlbotechProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java index 8c12f48f7..8d32eebb1 100644 --- a/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UproProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class UproProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new UproProtocolDecoder(null); + var decoder = inject(new UproProtocolDecoder(null)); verifyPosition(decoder, buffer( "*HQ201999999,BA&A1656512233362911356523660000230618&B0100060010&C00000<6<&F0000&R2405&V0109&W0000003E&K00100&T65&I54600027A00FCB6227A00FCA5727A00E955327A00E8B5327A00F9748&Y54600027A000000FCB6227A000000FCA5727A000000E955327A000000E8B5327A000000F9748&b00A7E81007607#")); @@ -53,7 +53,7 @@ public class UproProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, buffer( "*MG201693502000034964,AB&A0800253335360507036975710000091116&P0730000032d2a94d&B0000000000&N13&Z12&U_P\0\0\0\u0004\0\0\0\0\0\0\0\0\0\0"), - position("2016-11-09 08:00:25.000", true, -33.58934, -70.61626)); + position("2016-11-09 08:00:25.000", false, -33.58934, -70.61626)); verifyNull(decoder, buffer( "*MG20113800138000,AH")); @@ -69,7 +69,7 @@ public class UproProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, buffer( "*AI200905300036,AH&A0317264913209801844913060000251115&B0500000000&C0;4?72:9&F0000"), - position("2015-11-25 03:17:26.000", false, 49.22016, 18.74855)); + position("2015-11-25 03:17:26.000", true, 49.22016, 18.74855)); verifyPosition(decoder, buffer( "*AI2000905300036,AS&A1647304913209801844913060000251115&B0400000000&C0;4?72:9&F0000")); diff --git a/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java index 753063d26..40776278d 100644 --- a/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/UuxProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class UuxProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new UuxProtocolDecoder(null); + var decoder = inject(new UuxProtocolDecoder(null)); verifyNull(decoder, binary( "81910b01ff")); diff --git a/src/test/java/org/traccar/protocol/V680ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/V680ProtocolDecoderTest.java index 59b6dbea9..105dc8339 100644 --- a/src/test/java/org/traccar/protocol/V680ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/V680ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class V680ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new V680ProtocolDecoder(null); + var decoder = inject(new V680ProtocolDecoder(null)); verifyPosition(decoder, text( "#867967020910610#01234567890#1#0000#AUT#1#0500000000120000#114.036291,E,22.665795,N,111.00,000.00#111116#193333##"), diff --git a/src/test/java/org/traccar/protocol/VisiontekProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/VisiontekProtocolDecoderTest.java index b079346c9..042b66cae 100644 --- a/src/test/java/org/traccar/protocol/VisiontekProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/VisiontekProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class VisiontekProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new VisiontekProtocolDecoder(null); + var decoder = inject(new VisiontekProtocolDecoder(null)); verifyPosition(decoder, text( "$1,117,28,01,16,15,05,48,1725.0518N,07824.5298E,0620,11,0,185,2062,0,0,0,1,1,1,1,24,00.0000,00.3740,00.0000,VAJRA V1.00,A")); diff --git a/src/test/java/org/traccar/protocol/VnetProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/VnetProtocolDecoderTest.java index d43176a45..25cc03781 100644 --- a/src/test/java/org/traccar/protocol/VnetProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/VnetProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class VnetProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new VnetProtocolDecoder(null); + var decoder = inject(new VnetProtocolDecoder(null)); verifyNull(decoder, binary( "24240000140029111909062986818303379282604c452e322e30302ea32b020f0000d3552323")); diff --git a/src/test/java/org/traccar/protocol/Vt200FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Vt200FrameDecoderTest.java index 91cc3d317..7d039dc8f 100644 --- a/src/test/java/org/traccar/protocol/Vt200FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Vt200FrameDecoderTest.java @@ -8,7 +8,7 @@ public class Vt200FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Vt200FrameDecoder(); + var decoder = inject(new Vt200FrameDecoder()); verifyFrame( binary("28631037309456208400340102dc0906171616454415760201144494473f920a0c0000030500200100417c1f383a9d1090510000006a00007000000e00180ee129"), diff --git a/src/test/java/org/traccar/protocol/Vt200ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Vt200ProtocolDecoderTest.java index 791751c27..25ce5550a 100644 --- a/src/test/java/org/traccar/protocol/Vt200ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Vt200ProtocolDecoderTest.java @@ -9,7 +9,7 @@ public class Vt200ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Vt200ProtocolDecoder(null); + var decoder = inject(new Vt200ProtocolDecoder(null)); verifyPosition(decoder, binary( "28192030961807208200210101b919011818375801245774036424612500160917000003aa008800007b00aa3429")); diff --git a/src/test/java/org/traccar/protocol/VtfmsFrameDecoderTest.java b/src/test/java/org/traccar/protocol/VtfmsFrameDecoderTest.java index c03511160..e381153a2 100644 --- a/src/test/java/org/traccar/protocol/VtfmsFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/VtfmsFrameDecoderTest.java @@ -10,7 +10,7 @@ public class VtfmsFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new VtfmsFrameDecoder(); + var decoder = inject(new VtfmsFrameDecoder()); assertEquals( buffer("(863071010087648,0HK44,00,000,14,2,9,,A,114946,180313,11.0244,076.9768,282,000,00000,00000,K,0000128,1,12.8,,200,2.501,,4.001,0,0,0,0,0,0,0,,)105"), diff --git a/src/test/java/org/traccar/protocol/VtfmsProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/VtfmsProtocolDecoderTest.java index 1d4fa7f21..4925d9769 100644 --- a/src/test/java/org/traccar/protocol/VtfmsProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/VtfmsProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class VtfmsProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new VtfmsProtocolDecoder(null); + var decoder = inject(new VtfmsProtocolDecoder(null)); verifyPosition(decoder, text( "(861359037432331,0EF87,00,0,21,2,01,,A,154559,230119,1101.4046,07656.3859,241,000,00078,00000,K,0000812,1,12.7,,,,,,1,0,0,0,1,1,1,+919566531111*+919994462226,)054"), diff --git a/src/test/java/org/traccar/protocol/WatchFrameDecoderTest.java b/src/test/java/org/traccar/protocol/WatchFrameDecoderTest.java index 91bccb4c0..42464c6fe 100644 --- a/src/test/java/org/traccar/protocol/WatchFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WatchFrameDecoderTest.java @@ -8,7 +8,7 @@ public class WatchFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WatchFrameDecoder(); + var decoder = inject(new WatchFrameDecoder()); verifyFrame( binary("5b33472a3335323636313039303134333135302a303030412a4c4b2c302c302c3130305d"), diff --git a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java index 98e83f491..7eb167a74 100644 --- a/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WatchProtocolDecoderTest.java @@ -1,25 +1,36 @@ package org.traccar.protocol; -import io.netty.buffer.ByteBuf; import org.junit.Test; -import org.traccar.Context; import org.traccar.ProtocolTest; +import org.traccar.database.MediaManager; import org.traccar.model.Position; -import static org.junit.Assert.assertEquals; +import static org.mockito.Mockito.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; public class WatchProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WatchProtocolDecoder(null); + var decoder = inject(new WatchProtocolDecoder(null)); + + verifyNull(decoder, binary( + "5b5a4a2a3738393436383035303034323639322a303033342a303433392a4a58544b2c302c77617463685f375f32303232303532363039333935342c312c362c2321414d520a0c0a3c3f96d98367e9468ea245320c0a3c3f96d98367e9468ea245320c0a3c3f96d98367e9468ea245320c389814ffcd762fe49d50ae7a2e0cb528aefbf76911df05c2fbe17d050c2200cff77ef0df4d9b4ab9a4340c449814dbe7c63fa82bc3750d800cc48abbffddb0df8e8fda95e5980c49982ff6cf65f9377d02a39c3aaa0c389805f2ff42c1b80e0a0eb1dc0c2998e9defe15cfa3bdbe80d3540c7298c2f6d9239e3eae3c4a81660c490034dbfd513fedad0c2fc3900cc40039b7f71bb0657ba75558c40cd7813b97ff7219777ec7f401260c7d040003bff6f75fdb898a6ba1140cecd127f7f83357cb73a68a5f680cb081d4f6e749e6af8ed367bc480cec1815dfffd2dbed358112af320ccc21179fffbd17a3a61c133b380c920047defc72a784770ec0fe400c383c42f6faebe76fa736e9d1be0c4918e7decddc67ec9afd87ff220cc418e6bffe6cf6c9ac1f83c3900ca6cad1ffe3da24e1be3b547d03c00c6b00b8fee77f60a76d3e7d0292e20c2918b7bfff76387b793d3a36300c7d0400b7fff7f63ae513ac6f74de0c980016fbff7d01f9b30fca67c7220caa982ff6dbd7bf3d8dfed143ec0c44982fdfcb7b517e26f6ea52420c0ed19cfedb438f179d3fc50ec40c008ad2ffff635fe28dc1ec1f860c76cb7d05bffda53eaebe4d201ae20ccccaffbbfd3db4abb6ddf39d0e0c6b00acfeff406fe4a12661caf80c76982fbffffeb17b2f65472f300c7d04c24bf6ef1b10e47f73fc10b40c76036cfecd4e7837145a6a8e900ccccaf2beeba36fbaa36feb60640c7d0400dfffff73bfa3b87d0256a1700c7d04e4efd6efc23b651eb73e77780ccc1813ffffb39f6baa6f3195080c00007afffee0b9df6346ca08d00c6bca7d04feff4d64a7b56f9855da0c769819fbfd954ea5bd7d040ba6420c4c4c09bfffd5f6c57d01930e7d01220cc48a22dffe30bfcbaf08a795140c7d040433b7ff3cba5f3e336a40060cecbd2bfaf775bea7bde7e095ee0cc4caaef7fb623feeaab69eabc20c8c0021bffd1ea4a1b090175a920c7d046445fbdfc1abe910b0ca56160c7d0440cbd7ef03893c7f7d02e1a8c20c85e42dff5fdaa145759d326b5a0ccc4084f75f8eeb7b15e4eb4ff80c6bc22ef7d7eaf8df3b8ff678cc0cca4026f3cf7518fd731ceca3560cec041ffbe7655eaf822f04c4fe0c7d0478e3fbfcb5dfc8a81fdbb9e20cc418e6d7ff777f26affe37cc020cd7977cbff7d0aecb9727be6a0c0c00bde1f2d797fc8754ed09d4ae0cc498279f7e729fcb9eff70c1a60c7d0478e5bfffc67eef953fda69aa0c7200f1bbf7e891ef5a287cb5b80c983629fee5555f739f8a29279a0c76d103bef73f55a6bf89ba8ce40cc46424f6ded9a194167a067d05880cc4780efeffc37fae944d89bfb40c4464bffffb6dd54e8344394a5c0c49781ffffc653feaa31af59ac00cc464cebfd76ae4e8a55d5b5a4a2a3738393436383035303034323639322a303033352a303434332a4a58544b2c302c77617463685f375f32303232303532363039333935342c322c362c5f24fbbc0c7d04983effcfe35fbd8fff7ce6f60c448a1dfbd715bec3b42448e58a0c0e0421bf5f17ebc31a43301bc40c768ababf4f66cf629ee31fe9900c6b6426bf5f4eb7669dacc439140c945733bff9351e7d04ab6be54ef60ccc98bfbffbf67f63b78d8f42880c7d0400c6f7fffab5cbae8e8275da0c0097ffdefff5dfafb0c4727d04980ccc78d1f6ff1a6b7e37631059fa0c760045f3fd853fea877d03aa87440cc40022f7ffa8b5c58f6e80c58e0ccc4c1f9ffff32fa7af87de04560cb09801f6fdd32efcbdad9495b60c6b987d05bff72d61eb687d05a9f9e20cca57c7ffff6cb1fe3387ea596e0c629823dedfbfc50b97965e44ea0c4918ccbfd7cc75e59fff92e9ee0c8c78e7faff707ffda60ec3ada60c30c217befffcb8f3290f06d75e0c0e8a7bb7dff3eec7b7928ef6680c38ca1cdeff272ba012597d051a520c0018dfffeff27d01e369b3bcd7d80c98146eb2fc7f45c38e1ce53e120c3d5700ff7fd44bee28aa089d900c007157bffffe30302d7d0583585c0ccc5747bfe7f73cff7d02de1098240c7d047865f6feca71d70bdfaab6a20cecb946bfd966be74b61a06c6660c441612ffe7eb966a8c2886cf760ccc7827bffd653ff7980a62e9320c00ca98f7fc1b311a3986700cc20c490017bfff70cfe7bb455637320c6228afbf7e6da4c59763b693740cccc2b5fee1951975760e4a9dca0c0000faffdb255f6f86af4be6fc0cccc2ffdfff7d0225efbc847c42760cb48a8fdffbe23ff1a78782cbe60c7d04980cffff6e6dfc75a6c65a500ce62808bfff24f853748a9537400cb4004ebfeb6e70aa4314903e8c0cb46408ff72d62f44945f64897d040cccca7abfff2db5c6bfcc345e700c7d04c24dd6fd5f95638f78974a800cc4caffffffb17d01c36bdd7d047c2e0c7d0436d1f7f8917f83af7fc5c2180c070449f6fe570f128577c8c97d040c7d047813f6df3fd17d026b6790d1b80cc400c9d6d92dc56497843ed10a0c44986effffe13fef8eef7c717a0c7d049872bbfdad3abe2be0d60b240c4900adbf7d02dfa4ef960fdf23580c629845fefc5a650fbf8b0d4cda0c7d040076b7ef273fe78fce983ae40c4a00ded7ff629f7fab4531501c0c6200b7ffedf13fe6a68f01fb6c0cc49809f77fdb91517fb39e8ba00c760009bf7fd6afe7b46921f27a0cecbd1df6faf99120776e807d03fe0c98ca23fbff3749fb5ed3909c160cc44cbbbfffbd70e77d0367bc2e740c499816f77fe2ffe08edd7d048c9e0c940021beff1df0f1338c2f1a3a0c7d040083feebba1c756e5760c2200c94981dfffdf921b92b99909ba40c7d04984ebbdf7ff0c77d025a1fbfc00c7657b3ff77f4befcae2bf625640c62ca53f7fdb35f2e92af3bd5c60c7d049878bbdfc0dfc1bdaa1918000cc404bbbfefb41ee6b50a39bf180c767874f7fb8ee156320ee600020c69981cffffe0fff6bb2764acaa0cec781bfbff7d0324eb9b4b4d5d5b5a4a2a3738393436383035303034323639322a303033362a303433302a4a58544b2c302c77617463685f375f32303232303532363039333935342c332c362c73580c07ca4fbbfff5bec5abcfac465c0c0042a8beff316aed38fe4603dc0c7d04577d04fefdc929f7294ce7520c0c76984dfaff402fe68ebe113b000c7d0436a6fed465ff4f8d8e3306300c44e434f7f79e84abb8fa081be80c983636bef7e128bf7d03d34c71c80cd7982dffd54cac94536beab1320c058bd6bfff701fe69d1a39d1e80c76caedb77ffea0e47febb469440c0098b2bef5e55eed981672b1c40cd800d1bef4bda58daf7d01d309180c08cadffbfc31799f5613fab2da0c7d049828beffa5eea0bd09a14c2e0c0000e59feb5f9dff7f4945e98e0cc40046ffcfe57fb58f7d053dd9e20c7d040047d7ffd38f67aa9db8d38c0c7698d2df5fe2efc6bb0f5a18220c980367bbfd95dae73e3bf2b59a0c49813796fdf5efab9d3ed7d3d80c9800ebd7fdb831ae8f91811e920c7d04ca74bbff5cdcf45605c25f140c013e029fbfe7ffc299376b409a0c7510009e7d02010f68824cccead60cb13b00f7d5821e6c8d594a06880c75ec00f6e782e8f06b0c610d1a0cc09843dfef117fa5b3aef236f40cdcc208ffff4831f83703ca20c00cc09800bf7fd71eec9ba34e3c200c650f6bffd5bc4dbe7ec5b0f1d80c0d1c1f92ef917fa0b96023eac00c8efb1db6bfa42eed9f69051d4e0c8eff23b2fe4486d56ef44f702e0c8ebc1b9657d46eeea852ac337e0c8efb1f96d9877fc9b34c38f1540c121c2796df13577c727f8cedec0ca9107d05afdd6a9d957ab76c02560c121c2dd6bfd33fa5b844f27d02340cb11037b6e3962e6eaf52d6e7460c2b1c3db2dfe61eef9aad3dcc0a0c542e42d763e709fe723a83ae7c0c7cfa56bf7fedb8763c3f8ab2c00ca40022efff2411604d22a485e00c228adcbfdfcd748293c66b0bf20cb10f0097ff806dcf7a0a640d6e0c5a0400b7e3030ef4ae0a6046f80cb82812fe7b04d77e4bab11894a0c541c24b2dd53fea5891e3824420ca9fb26b2d7156fa485049cac420ca91c2d9edb2487526c2e2260fa0ca9bc25b65ff28e41a34232c0f00c8efb25b649e51ec39c0ae6703a0c70f425a6c820dfaf2f8124c8960c80f42794b323aed9ca9b6924be0cb93b278e3e8d929c36bb70b6360c587b27524f85857d056d214841660cda2f278b4c876eb3186e5acc540ce6832f6e3f0d82f81226e6dc3a0c0b922feff50a03d03c98ae28360c03d62befb54ab611de0c8addee0c84d626b7fdb4461556dc0153040c0b0f27ff5781c5c2b32f6762140c49bf2dfaf521969b702ecb11d80c7d050f27cfed75bfab95dc4af3180c011c3d8e7451df80a5cd0948080c7c2e35f2c7b0becca22e50769e0c7c1c3d965e628f46a9a58ae6100c7c2e3b965f4a6b5ebd1436b0b00c7c863eaedf18c7816cdeeed7e20c2b3e3df6b73952b2b1abc048a00c7cfb3db6cd67ae68cda18af9d60c2bff3e96df12ff61b39627cd580c7c863fd6cd810ee595d85ee6645d5b5a4a2a3738393436383035303034323639322a303033372a303433372a4a58544b2c302c77617463685f375f32303232303532363039333935342c342c362c0c7cff3fb65f812fe196dc62d8360c7c2e3db2de738fae9ca7c7236c0c2b2e3d96df6c1d775a3df5a47e0c7c3e3f96fe943dc07e81e170700c75503fb7d6a6197f1b08df85440c5a133ab6d6a0e68f3acb04b7b00cfa293fd6cfc20c390d5265d3c80c581347b278077d03dc22d9e49c680ce64d47924e8dcdffe9be19dc100cb90f4f9e612d2201961c2e111c0c003b4febb58a96c809ab5a71040ce6d759fbddba54b2aa9d9d983e0cc029576ecf1f703099d84994520c4029579e7d0281577073f5629dd80c5a2952b6fed177177d01e57d0175c20cd8647d044f7e3c58aba523ddb0720cb56753d3e9c6799f95938401f60c756414ff5f00fb57bc4d7e111c0c7c085573ef743ee19ca30057e00c752e5ab77e34eec69f3cbe53940c542e4d96d6e7ff03854a9506620c7cff55b6efca197610a86606180c7cfb55b67eb25f4b999c002bf20c7c107d03beeb451fad8d042492740cb8f05eb5ff664f679c1cc991c60ce1671bffd33d9445b57d0584c7d60c07781dfef5e3ee81b45ff8a8c80cc40072b7dfe6fe6e978257253a0cb1131fe6783035868e439b00d80c583b27b17ecb53dd165c3422180c703b2fbeb18d023e14d90304700c3cce2b93cdc2e6b3550a5546160cb13b3b72fe24273859059b52040c224d34edc742f6bb7c877d02b5940cb84d37cdcfcbc3f03a041cf4ac0ca4923a9f3b74e805b235cce8660c759000fbfd90565072aa7d03bb520cb592017f411dcbe80a0cc420360c09d6528fcf2e25b382ee46d75a0ce2e853d3cfb617fd7d023f05e0780c07cc3bbabfa9f6cec5aa48ac600c404208fb678a4cf16a9c09098c0cf14244fbdfc2afe7932fe57d02900c011c369e7d0264a8570a54f9a2e80cb1103daed6249fe59dc888c2ac0cb1103573c5f697be759923ecc80c705f7d059effaaa4b09b976f375a0c804223bbed89767d041693edab180cb49819d7eb5a8573bb10c951540c3c643af74f021f25b6dd3b7d02040c07982bd73fb31fe38f09a227a40c037610ff7d03c6058098fef936a80c03b808debbe055a1a71319128c0c6b8f2e9e3bb52d71c226d3141a0cdab82d7fa9d416167a1cb950020c03c32bb23ee9e3743f3b6853060cc02937adb5157d05f4a6960c1b680c4076365e6b754bda9394a7aa720c06293ef23313fb1b94bcc2c09a0ce676006bbd8e0417941b90d23c0cb9294f7d01fd3d65748cf6d1cc220c03767d035e3a65e6f2514ab1db060ce6d965bf4035f65c79a9e4446a0ce62921dbf46457b56cd65f6c500c584d6bba7ea8166edd6cf7693a0cb939227bfca25f82a7c4202f2e0c06ce2b9a4f0d95f39eb43c22840c06901eef6fd15fe48f452000e00c62023afbffb269beba0ee0ac540ce6ec00f37b8139f2026e80f1440c22501dfe7d017d03ed8c3ff6803f240cc48ae3b7fd725e63a347cd64100c0094f8efdeb0a9f35c83eb06b00c005d5b5a4a2a3738393436383035303034323639322a303033382a303433332a4a58544b2c302c77617463685f375f32303232303532363039333935342c352c362c6647deef2df57fb68fd76b660c44e43cbfefc0beec867d025c3f920cb4507d01ff6f42ee6c1f58a0db0e0c7d045701ff7f19f9f90fdff037c20c4404259efcd47d02a52b7ef6df0e0c7d04d128f3578db14779993109560ce1e41ecffd2851af49256b1ecc0c7d049837ffff707168db3dd1ac240cc09419f7f39a7d013d6ec1b4e55c0cc4881cff5f49f55fadc52285a40c06ce9ad7dbb8349b97031ac3b00c407d049d9bed74dfadad950eab560c06799ffac7a924b18bdf11c3d40c8054a2f777522e65be921a77240c8042a19bff706fe5b7e3e7d0360cd82840bff3f4fe429bea0081560c0064419fd9157f8b9c797e92c20cc47fe2b7d5e6ee45bf0524010e0c0894299e7d037e4553bcbbc0989e0c40501bbbdc926f8daf53885e0a0c80971ffee559f5bf98ed54cf140c00581abbffac75b88b14d5e3780c5a046dd66fd7bfe5b7ca749df40c403672bbcfe47ee797860ded5e0cb5502efb7ee2ffc7bbdc27d0880c44ca08fbf7031ecd9321d21ef40cdc9806fefde36f0699ad1569420c22cb1bfbdc974fcb900ab601440c00cb1cfbdfd2f7d2730b0b46680c0b4203dfef309fe0adc121e2080c225829feeb901f25b926343bae0c624204dfff4875b69ceda4df4c0c499886ffe7301e8e8bf9ef0a260cdce408dbef829fe45337e98d860c010800ef76088d8015f3b2c84e0c755c3ecfc898f50fbcdb9344220c7c7d03459349337d01e4949da1b4ec0c7cf046ae6e4a90df3552070a5e0c7cf045d23fbba0951147986eca0c7536426e6ef2ef0b7d01c22fd2960cb8284e9db92d40552988334f200cb8024acdbfea90d13b545fe35e0cb8f04d5e48659d48b97c1096140c7c084f79df4402702126bf358a0cb8a74d4def66535e145638d12e0c543e4d8edfa2531b15a340eb800cb83e4eafbd9031291a8563e4780c54a74ef1c7300da79aa94bb67d050cb8f04eba6fb0325813871511b80ce20ff6fffd404ed58ecf264c8e0c7c0f1cb3fe1a36fb7187c379d00c7c3e52f6727d0261ca8bdd1361b80cb8d64d9a4fb1cfe0aadaaa7d05c40c2b2e44b2bfb9b4dcad9d7d0200280c7c3b47d5db803fc2aee71a77f00c7c1343b2bfa06ee6ad3228f10a0c7c3b4a76477fe7650b0c809ca80c54d74b92dbc327134514d6126e0c7c5f4a8f4f74efaaa5cd0a43bc0c7c104bb64ff5ce604fa2028b680c7cff4aaec7f7a9394cc4c599e60cb8ce52eeb553d215a6a466b4120c750f4fae5f9816c04a0a3f751e0c75e04f73c58e96bb4b925a4c680cb80f4b6e3fe1635614bbdeccbc0c7c3b4faf7e825e42d473ee76800ce298578ffcb61f0af936387bbe0cb800e39bf62410681583e0d2b20cb4987d05ff7f297bf69eaf4cd8b40cb57815bf7f300fcffe9fae966a0cb497acd75fd37f648d00d141a00cc48af9fffe1a3b979b8f8573e80c29bff1bf4b94c6fd7c3eec075e0c7cce1f5d5b5a4a2a3738393436383035303034323639322a303033392a303065352a4a58544b2c302c77617463685f375f32303232303532363039333935342c362c362c8f5cf9f34fa6edceb18c0ca4ce436e7d02d329de94b63eb11a0cb894438f44cf753dbc1a83b4560cb8e44391eff729d4155a231bf40cb59443f373b4288492cd6e38160c5a42049bfec8678ad42bce0c560cb12e39fec3d1fe24b5572ee0be0cb1ce35fe33688455aa74e3ffa40cb1d635df4b704160ae864a7d03440cb10f3267dbf4a21d540ca1051c0cb11337724f8747f5547d054e91660cb1a73692df964f3bbb0758d41a0cfe05b60c314460297eae4185f20cad673ceb6dfa05ddbe0278d5de5d")); + + verifyPosition(decoder, buffer( + "[3G*9031853319*004E*UD2,220322,055105,A,22.761162,N,114.360192,E,0,0,47,14,100,64,0,0,00000008,0,0]")); verifyAttribute(decoder, buffer( "[3G*2104326058*000E*btemp2,1,35.29]"), Position.PREFIX_TEMP + 1, 35.29); verifyPosition(decoder, buffer( + "[SG*9159059735*0066*UD2,230322,082138,A,59.55285,N,016.66185,E,0.0,000,26,14,80,70,0,50,00000000,1,1,240,7,34505,80806406,,00]")); + + verifyPosition(decoder, buffer( "[SG*9059056143*0053*UD,251021,223408,A,41.46500,N,081.53128,W,0.926,000,0,00,70,70,0,50,00000000,0,1,,,,00]")); verifyPosition(decoder, buffer( @@ -131,22 +142,26 @@ public class WatchProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, buffer( "[ZJ*014111001350304*0038*008a*UD,070318,021027,V,00.000000,N,000.000000,E,0,0,0,0,100,18,1000,50,00000000,4,255,460,0,9346,5223,42,9346,5214,20,9784,4083,11,9346,5221,5]")); + + verifyPosition(decoder, buffer( + "[3G*8800000015*00DD*UD,010120,025946,V,0.0,N,0.0,E,22.0,0,-1,0,100,98,0,0,00000000,0,5,eduroam,f4:db:e6:d2:a8:00,-53,eduroam,f4:db:e6:da:d0:80,-79,eduroam,78:0c:f0:24:f9:80,-82,Lions,b0:be:76:0a:05:9a,-82,tubs-guest,f4:db:e6:d2:a8:01,-53,0.0]")); } @Test public void testDecodeVoiceMessage() throws Exception { - var decoder = new WatchProtocolDecoder(null); - - verifyNull(decoder.decode(null, null, buffer("[CS*1234567890*0004*TK,1]"))); + var decoder = inject(new WatchProtocolDecoder(null)); - ByteBuf data = binary("7d5b5d2c2aff"); + var mediaManager = mock(MediaManager.class); + when(mediaManager.writeFile(any(), any(), any())).thenReturn("mock.amr"); + decoder.setMediaManager(mediaManager); - Object decodedObject = decoder.decode(null, null, concatenateBuffers(buffer("[CS*1234567890*000e*TK,#!AMR"), data.resetReaderIndex(), buffer("]"))); - assertEquals("1234567890/mock.amr", ((Position) decodedObject).getAttributes().get("audio")); + verifyAttribute(decoder, concatenateBuffers( + buffer("[CS*1234567890*000e*TK,#!AMR"), binary("7d5b5d2c2aff"), buffer("]")), + Position.KEY_AUDIO, "mock.amr"); - verifyFrame(concatenateBuffers(buffer("#!AMR"), data.resetReaderIndex()), ((MockMediaManager) Context.getMediaManager()).readFile("1234567890/mock.amr")); + verify(mediaManager).writeFile(any(), any(), any()); } diff --git a/src/test/java/org/traccar/protocol/WatchProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/WatchProtocolEncoderTest.java index bcfc8df41..c83c103c3 100644 --- a/src/test/java/org/traccar/protocol/WatchProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/WatchProtocolEncoderTest.java @@ -9,7 +9,7 @@ public class WatchProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new WatchProtocolEncoder(null); + var encoder = inject(new WatchProtocolEncoder(null)); Command command; @@ -58,9 +58,9 @@ public class WatchProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeTimezone() { + public void testEncodeTimezone() throws Exception { - var encoder = new WatchProtocolEncoder(null); + var encoder = inject(new WatchProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java index 7387f5325..6953784fb 100644 --- a/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WialonProtocolDecoderTest.java @@ -8,12 +8,15 @@ public class WialonProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WialonProtocolDecoder(null); + var decoder = inject(new WialonProtocolDecoder(null)); verifyNull(decoder, text( "#L#2.0;42001300083;;CE45")); verifyAttributes(decoder, text( + "#D#NA;NA;5429.681944502211763;N;02654.60403650999069;E;NA;NA;NA;NA;NA;NA;NA;1.0;NA;m1:1:9196679,d1:1:15397,t1:1:20,b1:1:162,fuel1:2:21588.0,pv1:2:35.98,finish:1:1;0x9b0")); + + verifyAttributes(decoder, text( "#D#120319;112003;NA;NA;NA;NA;0.000;NA;NA;0;NA;NA;NA;NA;NA;101_521347:1:521246,101_158:1:510,101_521055:1:510,101_521055_2.9:1:509,101_521056:1:3;626B")); verifyNull(decoder, text( diff --git a/src/test/java/org/traccar/protocol/WliFrameDecoderTest.java b/src/test/java/org/traccar/protocol/WliFrameDecoderTest.java index 2e0d86a61..45c86ae1a 100644 --- a/src/test/java/org/traccar/protocol/WliFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WliFrameDecoderTest.java @@ -8,7 +8,7 @@ public class WliFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WliFrameDecoder(); + var decoder = inject(new WliFrameDecoder()); verifyFrame( binary("0231000101bba758c900010034000500ff001001258fc9013e80ed00001183350101e20006003200090030000a0032000b003331000c0031000d00343438000e003530000f003100100031303800130032001b003134001c0033392c33352c32382c33382c34302c33372c33332c33382c33352c34322c33372c3335001d003130001e0038002300343235002400303100250031303432320026003336343733002700323800280037002900312c312c312c312c31302e3232352e3135312e3230342c36353533352c302c39392c39392c3235352c3235352c3235352c323535002a0030002c0030003000300032003000330031003400ff001c0214130502061b0101258fc9013e80ed000001e2000000000000004d004500302c323031392f30352f30322c30363a33333a30302c323031392f30352f30322c30363a32363a3230005a003000f100352c302c342c302c2d312c2d3100f2003300f3003100f50038363634323530333137303639323400f600312c302c302c3431322c3000f70038343437373200f80032312c31312c302c302c302c302c2c2c2c2c2c302c3000f9003300fa00393100fb0032313100fc0032313000ff00313535363737383533340003"), diff --git a/src/test/java/org/traccar/protocol/WliProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WliProtocolDecoderTest.java index 6f86a9fd9..e74b1df06 100644 --- a/src/test/java/org/traccar/protocol/WliProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WliProtocolDecoderTest.java @@ -8,11 +8,14 @@ public class WliProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WliProtocolDecoder(null); + var decoder = inject(new WliProtocolDecoder(null)); verifyNull(decoder, binary( "0232776c693a30343930333332303332343103")); + verifyAttributes(decoder, binary( + "0231000101536c27e40001003400dbd20030363a34323a303000dbd30030352f30322f31390004002d3100060030000a00343235000b003031000c003130343232000d003336343733000e003239000f0037001000312c312c312c312c31302e3230322e33342e33312c36353533352c302c39392c39392c3235352c3235352c3235352c323535001100300013003000140033001500343237001600333700170031001800313038001900320031003000320030004500302c323031392f30352f30322c30363a34313a34312c323031392f30352f30322c30363a33353a303800f100342c302c332c302c2d312c2d3100f2003300f3003100f50038363634323530333137303639323400f600312c302c302c3431322c3000f70038343437373200f800302c3330302c302c302c302c302c2c2c2c2c2c302c3000f9003300fa00393100fb0032313100fc0032313000ff00313535363737393332300003")); + verifyPosition(decoder, binary( "0231000101bba758c900010034000500ff001001258fc9013e80ed00001183350101e20006003200090030000a0032000b003331000c0031000d00343438000e003530000f003100100031303800130032001b003134001c0033392c33352c32382c33382c34302c33372c33332c33382c33352c34322c33372c3335001d003130001e0038002300343235002400303100250031303432320026003336343733002700323800280037002900312c312c312c312c31302e3232352e3135312e3230342c36353533352c302c39392c39392c3235352c3235352c3235352c323535002a0030002c0030003000300032003000330031003400ff001c0214130502061b0101258fc9013e80ed000001e2000000000000004d004500302c323031392f30352f30322c30363a33333a30302c323031392f30352f30322c30363a32363a3230005a003000f100352c302c342c302c2d312c2d3100f2003300f3003100f50038363634323530333137303639323400f600312c302c302c3431322c3000f70038343437373200f80032312c31312c302c302c302c302c2c2c2c2c2c302c3000f9003300fa00393100fb0032313100fc0032313000ff00313535363737383533340003")); diff --git a/src/test/java/org/traccar/protocol/WondexFrameDecoderTest.java b/src/test/java/org/traccar/protocol/WondexFrameDecoderTest.java index 85a878aef..a1cbfe737 100644 --- a/src/test/java/org/traccar/protocol/WondexFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WondexFrameDecoderTest.java @@ -11,7 +11,7 @@ public class WondexFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WondexFrameDecoder(); + var decoder = inject(new WondexFrameDecoder()); assertNull( decoder.decode(null, null, binary("f0d70b0001ca9a3b"))); diff --git a/src/test/java/org/traccar/protocol/WondexProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WondexProtocolDecoderTest.java index 111cc9fbe..72ba8e163 100644 --- a/src/test/java/org/traccar/protocol/WondexProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WondexProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class WondexProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WondexProtocolDecoder(null); + var decoder = inject(new WondexProtocolDecoder(null)); verifyPosition(decoder, buffer( "2005010051,19990925063830,26.106181,44.440225,0,0,0,7,2,0.0,0,,,0")); diff --git a/src/test/java/org/traccar/protocol/WondexProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/WondexProtocolEncoderTest.java index ed0af844e..f482871dd 100644 --- a/src/test/java/org/traccar/protocol/WondexProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/WondexProtocolEncoderTest.java @@ -10,7 +10,7 @@ public class WondexProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new WondexProtocolEncoder(null); + var encoder = inject(new WondexProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(2); diff --git a/src/test/java/org/traccar/protocol/WristbandProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/WristbandProtocolDecoderTest.java index 10381168e..b901820fe 100644 --- a/src/test/java/org/traccar/protocol/WristbandProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/WristbandProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class WristbandProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new WristbandProtocolDecoder(null); + var decoder = inject(new WristbandProtocolDecoder(null)); verifyNotNull(decoder, binary( "000102004459583836383730343034343735303035357c56312e307c317c7b4630342331382c30372c332c3539303139322c33303a31382c30372c332c3539303139322c33307d0d0afffefc")); diff --git a/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java b/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java index aeca95376..34437862c 100644 --- a/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Xexun2FrameDecoderTest.java @@ -8,12 +8,16 @@ public class Xexun2FrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Xexun2FrameDecoder(); + var decoder = inject(new Xexun2FrameDecoder()); verifyFrame( binary("faaf0014000286147503139003400032f2b001002f4260b0d6a0008019104a3378323130333135317c323130333132303100704020308715758089502023015648643670faaf"), decoder.decode(null, null, binary("faaf0014000286147503139003400032f2b001002f4260b0d6a0008019104a3378323130333135317c323130333132303100704020308715758089502023015648643670faaf"))); + verifyFrame( + binary("FAAF123456FAAF123456FBBF123456FAAF"), + decoder.decode(null, null, binary("FAAF123456FBBF01123456FBBF02123456FAAF"))); + } } diff --git a/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java b/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java new file mode 100644 index 000000000..d327930b5 --- /dev/null +++ b/src/test/java/org/traccar/protocol/Xexun2FrameEncoderTest.java @@ -0,0 +1,21 @@ +package org.traccar.protocol; + +import io.netty.buffer.ByteBuf; +import io.netty.buffer.Unpooled; +import org.junit.Test; +import org.traccar.ProtocolTest; + +public class Xexun2FrameEncoderTest extends ProtocolTest { + + @Test + public void testDecode() throws Exception { + + Xexun2FrameEncoder encoder = new Xexun2FrameEncoder(); + + ByteBuf result = Unpooled.buffer(); + encoder.encode(null, binary("FAAF123456FAAF123456FBBF123456FAAF"), result); + verifyFrame(binary("FAAF123456FBBF01123456FBBF02123456FAAF"), result); + + } + +} diff --git a/src/test/java/org/traccar/protocol/Xexun2ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Xexun2ProtocolDecoderTest.java index 89c499016..48ba1a691 100644 --- a/src/test/java/org/traccar/protocol/Xexun2ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Xexun2ProtocolDecoderTest.java @@ -8,7 +8,10 @@ public class Xexun2ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Xexun2ProtocolDecoder(null); + var decoder = inject(new Xexun2ProtocolDecoder(null)); + + verifyPositions(decoder, false, binary( + "faaf00140a5a8618810536243350005ed8e101005b64622880401b001482060864cc2296f840daa22aa884f008c87483c291efddc4f09fc2f49db3c058ef68005a9abe1ae8299d6449bac4e984e0c1d6baa8469d265ff2b60100cc00080000fb2e0013572a3600000002000000000000faaf")); verifyPositions(decoder, false, binary( "FAAF00140004863921033475388000AFB7D203003800380038F9608A7B801E0060820205788A205DF523D97844FDB90443D37844FDB90465CFB4FBF946B0E8CEF639095803F8CC00000002350000004000FA608A7BA81E0060820205788A205DF523D97844FDB90443D2F639095803F8CFB4FBF946B0E8CE7844FDB90465CD00000002350000004000FB608A7BD01E0060820205788A205DF523D97844FDB90443D2F639095803F8CFB4FBF946B0E8CE7844FDB90465CD00000002350000004000FAAF")); @@ -22,6 +25,10 @@ public class Xexun2ProtocolDecoderTest extends ProtocolTest { verifyPositions(decoder, binary( "FAAF00140CF18626490454584530002BF2DD0200130013D360EFD7F514006402010D46322C4A450BA026D460EFD7FA14006402010D46322C4A450BA026FAAF")); + verifyPositions(decoder, binary( + "FAAF0014000C8622050512345670002DF3A001002A0062D9047400005E0280001E47001B400D4BA732DF505E40B4153AAF78FEF00109000000000042B36666FAAF"), + position("2022-07-21 07:47:00.000", true, 51.68715, 0.06103)); + } } diff --git a/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java new file mode 100644 index 000000000..483bc85fa --- /dev/null +++ b/src/test/java/org/traccar/protocol/Xexun2ProtocolEncoderTest.java @@ -0,0 +1,29 @@ +package org.traccar.protocol; + +import org.junit.Test; +import org.traccar.ProtocolTest; +import org.traccar.model.Command; + +public class Xexun2ProtocolEncoderTest extends ProtocolTest { + + @Test + public void testEncode() throws Exception { + + var encoder = inject(new Xexun2ProtocolEncoder(null)); + + Command command; + + command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_POWER_OFF); + verifyCommand(encoder, command, binary("FAAF0007000112345678901234500004FEBC6F663D31FAAF")); + + command = new Command(); + command.setDeviceId(1); + command.setType(Command.TYPE_POSITION_PERIODIC); + command.set(Command.KEY_FREQUENCY, 150); + verifyCommand(encoder, command, binary("FAAF0007000112345678901234500015F90E747261636B696E675F73656E643D3135302C313530FAAF")); + + } + +} diff --git a/src/test/java/org/traccar/protocol/XexunFrameDecoderTest.java b/src/test/java/org/traccar/protocol/XexunFrameDecoderTest.java index 43b8bdc0e..9bc39fc97 100644 --- a/src/test/java/org/traccar/protocol/XexunFrameDecoderTest.java +++ b/src/test/java/org/traccar/protocol/XexunFrameDecoderTest.java @@ -8,7 +8,7 @@ public class XexunFrameDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new XexunFrameDecoder(); + var decoder = inject(new XexunFrameDecoder()); verifyFrame( binary("4750524d432c3230353933352e3030302c412c353134302e343335302c4e2c3530312e303638362c452c302e30302c302e30302c3132313031352c30302c303030302e302c412a37302c462c2c696d65693a3335393538373031343731383339322c"), diff --git a/src/test/java/org/traccar/protocol/XexunProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/XexunProtocolDecoderTest.java index d2caa9c55..f7599b4c3 100644 --- a/src/test/java/org/traccar/protocol/XexunProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/XexunProtocolDecoderTest.java @@ -6,9 +6,9 @@ import org.traccar.ProtocolTest; public class XexunProtocolDecoderTest extends ProtocolTest { @Test - public void testDecode() throws Exception { + public void testDecodeSimple() throws Exception { - var decoder = new XexunProtocolDecoder(null, false); + var decoder = inject(new XexunProtocolDecoder(null, false)); verifyAttributes(decoder, text( "GPRMC,.000,A,0.000000,S,0.0000,W,0.00,0.00,,00,0000.0,A*55,L,,imei:353579010727036,")); @@ -53,7 +53,12 @@ public class XexunProtocolDecoderTest extends ProtocolTest { verifyPosition(decoder, text( "GPRMC,043435.000,A,811.299200,S,11339.9500,E,0.93,29.52,160313,00,0000.0,A*65,F,,imei:359585014597923,")); - decoder = new XexunProtocolDecoder(null, true); + } + + @Test + public void testDecodeFull() throws Exception { + + var decoder = inject(new XexunProtocolDecoder(null, true)); verifyPosition(decoder, text( "171007160505,,GPRMC,160505.000,A,5323.4680,N,00252.4202,W,000.0,129.7,071017,,,A*7A,F,ACCStart, imei:864504031916915,10,41.1,F:4.28V,1,135,19824,234,15,0062,B7D5")); diff --git a/src/test/java/org/traccar/protocol/XirgoProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/XirgoProtocolDecoderTest.java index f3a56a79d..db9c829aa 100644 --- a/src/test/java/org/traccar/protocol/XirgoProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/XirgoProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class XirgoProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeCustom() throws Exception { - var decoder = new XirgoProtocolDecoder(null); + var decoder = inject(new XirgoProtocolDecoder(null)); decoder.setForm("UID,EV,D,T,LT,LN,AL,GSPT,HD,SV,HP,BV,CQ,GS,SI,IG,OT"); @@ -31,7 +31,7 @@ public class XirgoProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeNew() throws Exception { - var decoder = new XirgoProtocolDecoder(null); + var decoder = inject(new XirgoProtocolDecoder(null)); verifyPosition(decoder, text( "$$352054058132185,4001,2017/04/21,00:01:05,32.54659,-116.90670,143.2,0,0,0,598,0.0,12,0.9,765840,7.0,14.5,19,1,1,0011,8.5,63.2,5,21999,184,255,671,207,100,185##")); @@ -59,7 +59,7 @@ public class XirgoProtocolDecoderTest extends ProtocolTest { @Test public void testDecodeOld() throws Exception { - var decoder = new XirgoProtocolDecoder(null); + var decoder = inject(new XirgoProtocolDecoder(null)); verifyPosition(decoder, text( "$$354660046140722,6001,2013/01/22,15:36:18,25.80907,-80.32531,7.1,19,165.2,11,0.8,11.1,17,1,1,3.9,2##"), diff --git a/src/test/java/org/traccar/protocol/XirgoProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/XirgoProtocolEncoderTest.java index 4f01aa72b..76e2f960d 100644 --- a/src/test/java/org/traccar/protocol/XirgoProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/XirgoProtocolEncoderTest.java @@ -11,7 +11,7 @@ public class XirgoProtocolEncoderTest extends ProtocolTest { @Test public void testEncode() throws Exception { - var encoder = new XirgoProtocolEncoder(null); + var encoder = inject(new XirgoProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Xrb28ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Xrb28ProtocolDecoderTest.java index 3197ba854..8ed175a74 100644 --- a/src/test/java/org/traccar/protocol/Xrb28ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Xrb28ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Xrb28ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Xrb28ProtocolDecoder(null); + var decoder = inject(new Xrb28ProtocolDecoder(null)); verifyAttributes(decoder, text( "*SCOR,OM,123456789123456,Q0,412,80,28#")); diff --git a/src/test/java/org/traccar/protocol/Xrb28ProtocolEncoderTest.java b/src/test/java/org/traccar/protocol/Xrb28ProtocolEncoderTest.java index 357da8f7b..a66efecc2 100644 --- a/src/test/java/org/traccar/protocol/Xrb28ProtocolEncoderTest.java +++ b/src/test/java/org/traccar/protocol/Xrb28ProtocolEncoderTest.java @@ -9,9 +9,9 @@ import static org.junit.Assert.assertEquals; public class Xrb28ProtocolEncoderTest extends ProtocolTest { @Test - public void testEncodePositionPeriodic() { + public void testEncodePositionPeriodic() throws Exception { - var encoder = new Xrb28ProtocolEncoder(null); + var encoder = inject(new Xrb28ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); @@ -23,9 +23,9 @@ public class Xrb28ProtocolEncoderTest extends ProtocolTest { } @Test - public void testEncodeCustom() { + public void testEncodeCustom() throws Exception { - var encoder = new Xrb28ProtocolEncoder(null); + var encoder = inject(new Xrb28ProtocolEncoder(null)); Command command = new Command(); command.setDeviceId(1); diff --git a/src/test/java/org/traccar/protocol/Xt013ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Xt013ProtocolDecoderTest.java index f8ddd35c3..007af984e 100644 --- a/src/test/java/org/traccar/protocol/Xt013ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Xt013ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Xt013ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Xt013ProtocolDecoder(null); + var decoder = inject(new Xt013ProtocolDecoder(null)); verifyPosition(decoder, text( "TK,862950021650364,150131090859,+53.267863,+5.767363,0,38,12,0,F,204,08,C94,336C,24,,4.09,1,,,,,,,,"), diff --git a/src/test/java/org/traccar/protocol/Xt2400ProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/Xt2400ProtocolDecoderTest.java index 1b3f6fcbb..35cb3c3fa 100644 --- a/src/test/java/org/traccar/protocol/Xt2400ProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/Xt2400ProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class Xt2400ProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new Xt2400ProtocolDecoder(null); + var decoder = inject(new Xt2400ProtocolDecoder(null)); decoder.setConfig("\n:wycfg pcr[1] 012801030405060708090a1213c8545657585a656e7d2cd055595d5e71797a7b7c7e7f80818285866b\n"); diff --git a/src/test/java/org/traccar/protocol/YwtProtocolDecoderTest.java b/src/test/java/org/traccar/protocol/YwtProtocolDecoderTest.java index 1d29b1282..81afe53a3 100644 --- a/src/test/java/org/traccar/protocol/YwtProtocolDecoderTest.java +++ b/src/test/java/org/traccar/protocol/YwtProtocolDecoderTest.java @@ -8,7 +8,7 @@ public class YwtProtocolDecoderTest extends ProtocolTest { @Test public void testDecode() throws Exception { - var decoder = new YwtProtocolDecoder(null); + var decoder = inject(new YwtProtocolDecoder(null)); verifyPosition(decoder, text( "%RP,1222102985:1,170509033842,E102.146563,N14.582175,,0,320,10,0,00-00-00-00-00-00-00-00-00-00-00-00,,1db2-02b3-52004,3>941.523-32,7>1,19>-16,20>30.9V")); diff --git a/src/test/java/org/traccar/reports/ReportUtilsTest.java b/src/test/java/org/traccar/reports/ReportUtilsTest.java index deb17ddd2..4bf668064 100644 --- a/src/test/java/org/traccar/reports/ReportUtilsTest.java +++ b/src/test/java/org/traccar/reports/ReportUtilsTest.java @@ -1,9 +1,20 @@ package org.traccar.reports; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +import org.apache.velocity.app.VelocityEngine; +import org.junit.Before; +import org.junit.Test; +import org.traccar.BaseTest; +import org.traccar.api.security.PermissionsService; +import org.traccar.config.Config; +import org.traccar.helper.model.PositionUtil; +import org.traccar.model.Device; +import org.traccar.model.Position; +import org.traccar.reports.common.ReportUtils; +import org.traccar.reports.common.TripsConfig; +import org.traccar.reports.model.StopReportItem; +import org.traccar.reports.model.TripReportItem; +import org.traccar.storage.Storage; +import org.traccar.storage.StorageException; import java.text.DateFormat; import java.text.ParseException; @@ -15,15 +26,23 @@ import java.util.Iterator; import java.util.List; 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; -import org.traccar.reports.model.TripsConfig; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; public class ReportUtilsTest extends BaseTest { + + private Storage storage; + + @Before + public void init() throws StorageException { + storage = mock(Storage.class); + when(storage.getObject(any(), any())).thenReturn(mock(Device.class)); + } private Date date(String time) throws ParseException { DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); @@ -38,35 +57,39 @@ public class ReportUtilsTest extends BaseTest { position.setTime(date(time)); position.setValid(true); position.setSpeed(speed); + position.set(Position.KEY_MOTION, speed > 0); position.set(Position.KEY_TOTAL_DISTANCE, totalDistance); return position; } - + @Test public void testCalculateDistance() { Position startPosition = new Position(); startPosition.set(Position.KEY_TOTAL_DISTANCE, 500.0); Position endPosition = new Position(); endPosition.set(Position.KEY_TOTAL_DISTANCE, 700.0); - assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 200.0, 10); + assertEquals(PositionUtil.calculateDistance(startPosition, endPosition, true), 200.0, 10); startPosition.set(Position.KEY_ODOMETER, 50000); endPosition.set(Position.KEY_ODOMETER, 51000); - assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 1000.0, 10); + assertEquals(PositionUtil.calculateDistance(startPosition, endPosition, true), 1000.0, 10); } @Test public void testCalculateSpentFuel() { + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + mock(TripsConfig.class), mock(VelocityEngine.class), null); Position startPosition = new Position(); Position endPosition = new Position(); - assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.0, 0.01); + assertEquals(reportUtils.calculateFuel(startPosition, endPosition), 0.0, 0.01); startPosition.set(Position.KEY_FUEL_LEVEL, 0.7); endPosition.set(Position.KEY_FUEL_LEVEL, 0.5); - assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), 0.2, 0.01); + assertEquals(reportUtils.calculateFuel(startPosition, endPosition), 0.2, 0.01); } @Test - public void testDetectTripsSimple() throws ParseException { + public void testDetectTripsSimple() throws Exception { List<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), @@ -79,14 +102,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:07:00.000", 0, 3000)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<TripReport> trips = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class); + var trips = reportUtils.detectTripsAndStops(mock(Device.class), data, false, TripReportItem.class); assertNotNull(trips); assertFalse(trips.isEmpty()); - TripReport itemTrip = trips.iterator().next(); + TripReportItem itemTrip = trips.iterator().next(); assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime()); assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime()); @@ -95,15 +120,14 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - Collection<StopReport> stops = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var stops = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(stops); assertFalse(stops.isEmpty()); - Iterator<StopReport> iterator = stops.iterator(); + Iterator<StopReportItem> iterator = stops.iterator(); - StopReport itemStop = iterator.next(); + StopReportItem itemStop = iterator.next(); assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime()); @@ -118,7 +142,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectTripsSimpleWithIgnition() throws ParseException { + public void testDetectTripsSimpleWithIgnition() throws Exception { List<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), @@ -133,14 +157,16 @@ public class ReportUtilsTest extends BaseTest { data.get(5).set(Position.KEY_IGNITION, false); TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<TripReport> trips = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class); + var trips = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, TripReportItem.class); assertNotNull(trips); assertFalse(trips.isEmpty()); - TripReport itemTrip = trips.iterator().next(); + TripReportItem itemTrip = trips.iterator().next(); assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime()); assertEquals(date("2016-01-01 00:05:00.000"), itemTrip.getEndTime()); @@ -149,8 +175,7 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - trips = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class); + trips = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, TripReportItem.class); assertNotNull(trips); assertFalse(trips.isEmpty()); @@ -164,15 +189,14 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(3000, itemTrip.getDistance(), 0.01); - Collection<StopReport> stops = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var stops = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(stops); assertFalse(stops.isEmpty()); - Iterator<StopReport> iterator = stops.iterator(); + Iterator<StopReportItem> iterator = stops.iterator(); - StopReport itemStop = iterator.next(); + StopReportItem itemStop = iterator.next(); assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime()); @@ -187,7 +211,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectTripsWithFluctuation() throws ParseException { + public void testDetectTripsWithFluctuation() throws Exception { List<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), @@ -204,14 +228,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:11:00.000", 0, 7000)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<TripReport> trips = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class); + var trips = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, TripReportItem.class); assertNotNull(trips); assertFalse(trips.isEmpty()); - TripReport itemTrip = trips.iterator().next(); + TripReportItem itemTrip = trips.iterator().next(); assertEquals(date("2016-01-01 00:02:00.000"), itemTrip.getStartTime()); assertEquals(date("2016-01-01 00:09:00.000"), itemTrip.getEndTime()); @@ -220,15 +246,14 @@ public class ReportUtilsTest extends BaseTest { assertEquals(10, itemTrip.getMaxSpeed(), 0.01); assertEquals(7000, itemTrip.getDistance(), 0.01); - Collection<StopReport> stops = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var stops = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(stops); assertFalse(stops.isEmpty()); - Iterator<StopReport> iterator = stops.iterator(); + Iterator<StopReportItem> iterator = stops.iterator(); - StopReport itemStop = iterator.next(); + StopReportItem itemStop = iterator.next(); assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getEndTime()); @@ -243,7 +268,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectStopsOnly() throws ParseException { + public void testDetectStopsOnly() throws Exception { Collection<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), @@ -254,14 +279,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:05:00.000", 0, 0)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<StopReport> result = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var result = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(result); assertFalse(result.isEmpty()); - StopReport itemStop = result.iterator().next(); + StopReportItem itemStop = result.iterator().next(); assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime()); @@ -270,7 +297,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectStopsWithTripCut() throws ParseException { + public void testDetectStopsWithTripCut() throws Exception { Collection<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 0, 0), @@ -281,14 +308,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:05:00.000", 2, 0)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<StopReport> result = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var result = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(result); assertFalse(result.isEmpty()); - StopReport itemStop = result.iterator().next(); + StopReportItem itemStop = result.iterator().next(); assertEquals(date("2016-01-01 00:00:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getEndTime()); @@ -297,7 +326,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectStopsStartedFromTrip() throws ParseException { + public void testDetectStopsStartedFromTrip() throws Exception { Collection<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 2, 0), @@ -308,14 +337,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:05:00.000", 0, 0)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<StopReport> result = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var result = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(result); assertFalse(result.isEmpty()); - StopReport itemStop = result.iterator().next(); + StopReportItem itemStop = result.iterator().next(); assertEquals(date("2016-01-01 00:02:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:05:00.000"), itemStop.getEndTime()); @@ -324,7 +355,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectStopsMoving() throws ParseException { + public void testDetectStopsMoving() throws Exception { Collection<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 5, 0), @@ -335,9 +366,11 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:05:00.000", 5, 0)); TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<StopReport> result = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var result = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(result); assertTrue(result.isEmpty()); @@ -345,7 +378,7 @@ public class ReportUtilsTest extends BaseTest { } @Test - public void testDetectTripAndStopByGap() throws ParseException { + public void testDetectTripAndStopByGap() throws Exception { Collection<Position> data = Arrays.asList( position("2016-01-01 00:00:00.000", 7, 100), @@ -358,14 +391,16 @@ public class ReportUtilsTest extends BaseTest { position("2016-01-01 00:25:00.000", 5, 900)); TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01); + ReportUtils reportUtils = new ReportUtils( + mock(Config.class), storage, mock(PermissionsService.class), + tripsConfig, mock(VelocityEngine.class), null); - Collection<TripReport> trips = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, TripReport.class); + var trips = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, TripReportItem.class); assertNotNull(trips); assertFalse(trips.isEmpty()); - TripReport itemTrip = trips.iterator().next(); + TripReportItem itemTrip = trips.iterator().next(); assertEquals(date("2016-01-01 00:00:00.000"), itemTrip.getStartTime()); assertEquals(date("2016-01-01 00:04:00.000"), itemTrip.getEndTime()); @@ -374,13 +409,12 @@ public class ReportUtilsTest extends BaseTest { assertEquals(7, itemTrip.getMaxSpeed(), 0.01); assertEquals(600, itemTrip.getDistance(), 0.01); - Collection<StopReport> stops = ReportUtils.detectTripsAndStops( - new TestIdentityManager(), null, data, tripsConfig, false, StopReport.class); + var stops = reportUtils.detectTripsAndStops(mock(Device.class) ,data, false, StopReportItem.class); assertNotNull(stops); assertFalse(stops.isEmpty()); - StopReport itemStop = stops.iterator().next(); + StopReportItem itemStop = stops.iterator().next(); assertEquals(date("2016-01-01 00:04:00.000"), itemStop.getStartTime()); assertEquals(date("2016-01-01 00:24:00.000"), itemStop.getEndTime()); diff --git a/src/test/java/org/traccar/speedlimit/OverpassSpeedLimitProviderTest.java b/src/test/java/org/traccar/speedlimit/OverpassSpeedLimitProviderTest.java index dcac78f80..202983f1e 100644 --- a/src/test/java/org/traccar/speedlimit/OverpassSpeedLimitProviderTest.java +++ b/src/test/java/org/traccar/speedlimit/OverpassSpeedLimitProviderTest.java @@ -3,19 +3,20 @@ package org.traccar.speedlimit; import org.junit.Ignore; import org.junit.Test; +import javax.ws.rs.client.Client; +import javax.ws.rs.client.ClientBuilder; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.fail; public class OverpassSpeedLimitProviderTest { + private final Client client = ClientBuilder.newClient(); + @Ignore @Test - public void test() throws Exception { - testLocationProvider(); - } - - public void testLocationProvider() throws Exception { - SpeedLimitProvider provider = new OverpassSpeedLimitProvider("http://8.8.8.8/api/interpreter"); + public void testOverpass() throws Exception { + SpeedLimitProvider provider = new OverpassSpeedLimitProvider(client, "http://8.8.8.8/api/interpreter"); provider.getSpeedLimit(34.74767, -82.48098, new SpeedLimitProvider.SpeedLimitProviderCallback() { @Override |