aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/traccar/ProtocolTest.java51
1 files changed, 26 insertions, 25 deletions
diff --git a/src/test/java/org/traccar/ProtocolTest.java b/src/test/java/org/traccar/ProtocolTest.java
index 0726000be..273520155 100644
--- a/src/test/java/org/traccar/ProtocolTest.java
+++ b/src/test/java/org/traccar/ProtocolTest.java
@@ -28,6 +28,7 @@ import java.util.TimeZone;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@@ -159,7 +160,7 @@ public class ProtocolTest extends BaseTest {
private void verifyDecodedList(Object decodedObject, boolean checkLocation, Position expected) {
assertNotNull(decodedObject, "list is null");
- assertTrue(decodedObject instanceof List, "not a list");
+ assertInstanceOf(List.class, decodedObject, "not a list");
assertFalse(((List<?>) decodedObject).isEmpty(), "list is empty");
for (Object item : (List<?>) decodedObject) {
@@ -171,7 +172,7 @@ public class ProtocolTest extends BaseTest {
private void verifyDecodedPosition(Object decodedObject, boolean checkLocation, boolean checkAttributes, Position expected) {
assertNotNull(decodedObject, "position is null");
- assertTrue(decodedObject instanceof Position, "not a position");
+ assertInstanceOf(Position.class, decodedObject, "not a position");
Position position = (Position) decodedObject;
@@ -225,55 +226,55 @@ public class ProtocolTest extends BaseTest {
}
if (attributes.containsKey(Position.KEY_INDEX)) {
- assertTrue(attributes.get(Position.KEY_INDEX) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_INDEX));
}
if (attributes.containsKey(Position.KEY_HDOP)) {
- assertTrue(attributes.get(Position.KEY_HDOP) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_HDOP));
}
if (attributes.containsKey(Position.KEY_VDOP)) {
- assertTrue(attributes.get(Position.KEY_VDOP) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_VDOP));
}
if (attributes.containsKey(Position.KEY_PDOP)) {
- assertTrue(attributes.get(Position.KEY_PDOP) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_PDOP));
}
if (attributes.containsKey(Position.KEY_SATELLITES)) {
- assertTrue(attributes.get(Position.KEY_SATELLITES) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_SATELLITES));
}
if (attributes.containsKey(Position.KEY_SATELLITES_VISIBLE)) {
- assertTrue(attributes.get(Position.KEY_SATELLITES_VISIBLE) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_SATELLITES_VISIBLE));
}
if (attributes.containsKey(Position.KEY_RSSI)) {
- assertTrue(attributes.get(Position.KEY_RSSI) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_RSSI));
}
if (attributes.containsKey(Position.KEY_ODOMETER)) {
- assertTrue(attributes.get(Position.KEY_ODOMETER) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_ODOMETER));
}
if (attributes.containsKey(Position.KEY_RPM)) {
- assertTrue(attributes.get(Position.KEY_RPM) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_RPM));
}
if (attributes.containsKey(Position.KEY_FUEL_LEVEL)) {
- assertTrue(attributes.get(Position.KEY_FUEL_LEVEL) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_FUEL_LEVEL));
}
if (attributes.containsKey(Position.KEY_FUEL_USED)) {
- assertTrue(attributes.get(Position.KEY_FUEL_USED) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_FUEL_USED));
}
if (attributes.containsKey(Position.KEY_POWER)) {
- assertTrue(attributes.get(Position.KEY_POWER) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_POWER));
}
if (attributes.containsKey(Position.KEY_BATTERY)) {
- assertTrue(attributes.get(Position.KEY_BATTERY) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_BATTERY));
}
if (attributes.containsKey(Position.KEY_BATTERY_LEVEL)) {
@@ -282,39 +283,39 @@ public class ProtocolTest extends BaseTest {
}
if (attributes.containsKey(Position.KEY_CHARGE)) {
- assertTrue(attributes.get(Position.KEY_CHARGE) instanceof Boolean);
+ assertInstanceOf(Boolean.class, attributes.get(Position.KEY_CHARGE));
}
if (attributes.containsKey(Position.KEY_IGNITION)) {
- assertTrue(attributes.get(Position.KEY_IGNITION) instanceof Boolean);
+ assertInstanceOf(Boolean.class, attributes.get(Position.KEY_IGNITION));
}
if (attributes.containsKey(Position.KEY_MOTION)) {
- assertTrue(attributes.get(Position.KEY_MOTION) instanceof Boolean);
+ assertInstanceOf(Boolean.class, attributes.get(Position.KEY_MOTION));
}
if (attributes.containsKey(Position.KEY_ARCHIVE)) {
- assertTrue(attributes.get(Position.KEY_ARCHIVE) instanceof Boolean);
+ assertInstanceOf(Boolean.class, attributes.get(Position.KEY_ARCHIVE));
}
if (attributes.containsKey(Position.KEY_DRIVER_UNIQUE_ID)) {
- assertTrue(attributes.get(Position.KEY_DRIVER_UNIQUE_ID) instanceof String);
+ assertInstanceOf(String.class, attributes.get(Position.KEY_DRIVER_UNIQUE_ID));
}
if (attributes.containsKey(Position.KEY_STEPS)) {
- assertTrue(attributes.get(Position.KEY_STEPS) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_STEPS));
}
if (attributes.containsKey(Position.KEY_ROAMING)) {
- assertTrue(attributes.get(Position.KEY_ROAMING) instanceof Boolean);
+ assertInstanceOf(Boolean.class, attributes.get(Position.KEY_ROAMING));
}
if (attributes.containsKey(Position.KEY_HOURS)) {
- assertTrue(attributes.get(Position.KEY_HOURS) instanceof Number);
+ assertInstanceOf(Number.class, attributes.get(Position.KEY_HOURS));
}
if (attributes.containsKey(Position.KEY_RESULT)) {
- assertTrue(attributes.get(Position.KEY_RESULT) instanceof String);
+ assertInstanceOf(String.class, attributes.get(Position.KEY_RESULT));
}
if (position.getNetwork() != null) {
@@ -351,7 +352,7 @@ public class ProtocolTest extends BaseTest {
protected void verifyFrame(ByteBuf expected, Object object) {
assertNotNull(object, "buffer is null");
- assertTrue(object instanceof ByteBuf, "not a buffer");
+ assertInstanceOf(ByteBuf.class, object, "not a buffer");
assertEquals(ByteBufUtil.hexDump(expected), ByteBufUtil.hexDump((ByteBuf) object));
}