From 6e594f07b8f1236e000952601ce2d6ff7aa0575a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 28 Oct 2015 13:51:58 +1300 Subject: Refactor TLT-2H protocol decoder --- test/org/traccar/ProtocolDecoderTest.java | 9 +++++++++ test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'test/org/traccar') diff --git a/test/org/traccar/ProtocolDecoderTest.java b/test/org/traccar/ProtocolDecoderTest.java index 564ecb751..61c333d67 100644 --- a/test/org/traccar/ProtocolDecoderTest.java +++ b/test/org/traccar/ProtocolDecoderTest.java @@ -74,6 +74,15 @@ public class ProtocolDecoderTest { } } + protected void verifyPositions(BaseProtocolDecoder decoder, Object object, Position position) throws Exception { + Object decodedObject = decoder.decode(null, null, object); + Assert.assertNotNull(decodedObject); + Assert.assertTrue(decodedObject instanceof List); + for (Object item : (List) decodedObject) { + verifyDecodedPosition(item, position); + } + } + protected Position position(String time, boolean valid, double lat, double lon) throws ParseException { Position position = new Position(); diff --git a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java index b0f90a82d..70515cf00 100644 --- a/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java +++ b/test/org/traccar/protocol/Tlt2hProtocolDecoderTest.java @@ -12,7 +12,8 @@ public class Tlt2hProtocolDecoderTest extends ProtocolDecoderTest { verifyPositions(decoder, text( "#357671030946351#V500#0000#AUTO#1\r\n", - "#$GPRMC,223835.000,A,0615.3545,S,10708.5779,E,14.62,97.41,070313,,,D*70\r\n")); + "#$GPRMC,223835.000,A,0615.3545,S,10708.5779,E,14.62,97.41,070313,,,D*70\r\n"), + position("2013-03-07 22:38:35.000", true, -6.25591, 107.14297)); verifyPositions(decoder, text( "\r\n#357671030946351#V500#0000#AUTO#1\r\n", -- cgit v1.2.3