aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/helper/TestIdentityManager.java13
-rw-r--r--test/org/traccar/protocol/Gps103ProtocolEncoderTest.java29
2 files changed, 38 insertions, 4 deletions
diff --git a/test/org/traccar/helper/TestIdentityManager.java b/test/org/traccar/helper/TestIdentityManager.java
index a4ddeeb09..d279241e4 100644
--- a/test/org/traccar/helper/TestIdentityManager.java
+++ b/test/org/traccar/helper/TestIdentityManager.java
@@ -4,17 +4,22 @@ import org.traccar.database.IdentityManager;
import org.traccar.model.Device;
public class TestIdentityManager implements IdentityManager {
+
+ private final Device device;
+
+ public TestIdentityManager() {
+ device = new Device();
+ device.setId(1);
+ device.setUniqueId("123456789012345");
+ }
@Override
public Device getDeviceById(long id) {
- return null;
+ return device;
}
@Override
public Device getDeviceByUniqueId(String imei) {
- Device device = new Device();
- device.setId(new Long(1));
- device.setUniqueId("123456789012345");
return device;
}
diff --git a/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java
new file mode 100644
index 000000000..74091d0e0
--- /dev/null
+++ b/test/org/traccar/protocol/Gps103ProtocolEncoderTest.java
@@ -0,0 +1,29 @@
+package org.traccar.protocol;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.model.Command;
+
+public class Gps103ProtocolEncoderTest {
+
+ @Test
+ public void testDecode() throws Exception {
+
+ Gps103ProtocolEncoder encoder = new Gps103ProtocolEncoder();
+
+ Command command = new Command();
+ command.setDeviceId(1);
+ command.setType(Command.TYPE_POSITION_FIX);
+
+ Map<String, Object> other = new HashMap<>();
+ other.put(Command.KEY_FREQUENCY, 300l);
+
+ command.setOther(other);
+
+ Assert.assertEquals("**,imei:123456789012345,C,05m", encoder.encodeCommand(command));
+
+ }
+
+}