aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/reports/ReportUtilsTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2016-08-20 13:13:09 +0300
committerGitHub <noreply@github.com>2016-08-20 13:13:09 +0300
commit6c6b62351aadd68928b9bd3e39e2bf96d78695e8 (patch)
tree8d9f5617aada94e3c8784c0bee6a201fbced54b3 /test/org/traccar/reports/ReportUtilsTest.java
parent6b6d28695600fee509ee37a7225dd6518879ac9c (diff)
parent804c56a76dc8406e4ff072289a4a9f97322dfe83 (diff)
downloadtrackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.gz
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.tar.bz2
trackermap-server-6c6b62351aadd68928b9bd3e39e2bf96d78695e8.zip
Merge pull request #2228 from Abyss777/reports_trips
Implement trips reports
Diffstat (limited to 'test/org/traccar/reports/ReportUtilsTest.java')
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java36
1 files changed, 36 insertions, 0 deletions
diff --git a/test/org/traccar/reports/ReportUtilsTest.java b/test/org/traccar/reports/ReportUtilsTest.java
new file mode 100644
index 000000000..2e01505db
--- /dev/null
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -0,0 +1,36 @@
+package org.traccar.reports;
+
+import org.junit.Assert;
+import org.junit.Test;
+import org.traccar.model.Position;
+
+public class ReportUtilsTest {
+
+ @Test
+ public void testCalculateDistance() {
+ Position startPosition = new Position();
+ startPosition.set(Position.KEY_TOTAL_DISTANCE, 500.0);
+ Position endPosition = new Position();
+ endPosition.set(Position.KEY_TOTAL_DISTANCE, 700.0);
+ Assert.assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 200.0, 10);
+ startPosition.set(Position.KEY_ODOMETER, 50000);
+ endPosition.set(Position.KEY_ODOMETER, 50001);
+ Assert.assertEquals(ReportUtils.calculateDistance(startPosition, endPosition), 1000.0, 10);
+ }
+
+ @Test
+ public void testCalculateSpentFuel() {
+ Position startPosition = new Position();
+ Position endPosition = new Position();
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), "-");
+ startPosition.setProtocol("meitrack");
+ startPosition.set(Position.KEY_FUEL, 0.07);
+ endPosition.set(Position.KEY_FUEL, 0.05);
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), "0.02 %");
+ startPosition.setProtocol("galileo");
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), "0.02 %");
+ startPosition.setProtocol("noran");
+ Assert.assertEquals(ReportUtils.calculateFuel(startPosition, endPosition), "0.02 %");
+ }
+
+}