diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2013-11-09 19:01:19 +1300 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2013-11-09 19:01:19 +1300 |
commit | cf0565caceee6856328e481dd23600ed2590c88a (patch) | |
tree | 9d2cc8cf8d3eb27b36412eb492ad702581891f1c /test/org/traccar/helper/DecoderVerifier.java | |
parent | f9ecee5b732b0c82c8a95bebdb5e275ea479cccc (diff) | |
download | trackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.tar.gz trackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.tar.bz2 trackermap-server-cf0565caceee6856328e481dd23600ed2590c88a.zip |
Improve unit test verification
Diffstat (limited to 'test/org/traccar/helper/DecoderVerifier.java')
-rw-r--r-- | test/org/traccar/helper/DecoderVerifier.java | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/test/org/traccar/helper/DecoderVerifier.java b/test/org/traccar/helper/DecoderVerifier.java new file mode 100644 index 000000000..d73d9d58f --- /dev/null +++ b/test/org/traccar/helper/DecoderVerifier.java @@ -0,0 +1,62 @@ +package org.traccar.helper; + +import java.util.Date; +import java.util.List; +import static org.junit.Assert.*; +import org.traccar.model.Position; + +public class DecoderVerifier { + + private static void verifyPosition(Position position) { + + assertNotNull(position.getDeviceId()); + + assertNotNull(position.getTime()); + assertTrue(position.getTime().after(new Date(946684800000L))); // 2000 year + assertTrue(position.getTime().getTime() < new Date().getTime() + 3600000); // 1 hour from now + + assertNotNull(position.getValid()); + + assertNotNull(position.getLatitude()); + assertTrue(position.getLatitude() >= -90); + assertTrue(position.getLatitude() <= 90); + + assertNotNull(position.getLongitude()); + assertTrue(position.getLongitude() >= -180); + assertTrue(position.getLongitude() <= 180); + + assertNotNull(position.getAltitude()); + assertTrue(position.getAltitude() >= -12262); + assertTrue(position.getAltitude() <= 18000); + + assertNotNull(position.getSpeed()); + assertTrue(position.getSpeed() >= 0); + assertTrue(position.getSpeed() <= 869); + + assertNotNull(position.getCourse()); + assertTrue(position.getCourse() >= 0); + assertTrue(position.getCourse() <= 360); + + assertNotNull(position.getExtendedInfo()); + + } + + public static void verify(Object object) { + + assertNotNull(object); + + if (object instanceof Position) { + verifyPosition((Position) object); + } else if (object instanceof List) { + List<Position> positions = (List<Position>) object; + + assertFalse(positions.isEmpty()); + + for (Position position : positions) { + verifyPosition(position); + } + } + + } + +} |