aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/handler/DistanceHandlerTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 15:33:33 -0800
committerAnton Tananaev <anton.tananaev@gmail.com>2019-02-23 15:33:33 -0800
commitb7d48127e60bcaa5d01f45d8df5203f28f9a1667 (patch)
treea5c6c85460775db357b39e8ac401db3c8d218dc6 /test/org/traccar/handler/DistanceHandlerTest.java
parent563243a8da888244e910a4a7a10fb86ad525fdd4 (diff)
downloadtraccar-server-b7d48127e60bcaa5d01f45d8df5203f28f9a1667.tar.gz
traccar-server-b7d48127e60bcaa5d01f45d8df5203f28f9a1667.tar.bz2
traccar-server-b7d48127e60bcaa5d01f45d8df5203f28f9a1667.zip
Refactor distance handler
Diffstat (limited to 'test/org/traccar/handler/DistanceHandlerTest.java')
-rw-r--r--test/org/traccar/handler/DistanceHandlerTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/test/org/traccar/handler/DistanceHandlerTest.java b/test/org/traccar/handler/DistanceHandlerTest.java
new file mode 100644
index 000000000..f7c6e42cd
--- /dev/null
+++ b/test/org/traccar/handler/DistanceHandlerTest.java
@@ -0,0 +1,30 @@
+package org.traccar.handler;
+
+import org.junit.Test;
+import org.traccar.config.Config;
+import org.traccar.model.Position;
+
+import static org.junit.Assert.assertEquals;
+
+public class DistanceHandlerTest {
+
+ @Test
+ public void testCalculateDistance() {
+
+ DistanceHandler distanceHandler = new DistanceHandler(new Config(), null);
+
+ Position position = distanceHandler.handlePosition(new Position());
+
+ assertEquals(0.0, position.getAttributes().get(Position.KEY_DISTANCE));
+ assertEquals(0.0, position.getAttributes().get(Position.KEY_TOTAL_DISTANCE));
+
+ position.set(Position.KEY_DISTANCE, 100);
+
+ position = distanceHandler.handlePosition(position);
+
+ assertEquals(100.0, position.getAttributes().get(Position.KEY_DISTANCE));
+ assertEquals(100.0, position.getAttributes().get(Position.KEY_TOTAL_DISTANCE));
+
+ }
+
+}