aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2016-08-19 10:45:33 +0500
committerAbyss777 <abyss@fox5.ru>2016-08-19 10:45:33 +0500
commit1c7437d6de01fffbe3f69853717808b1790413fd (patch)
treeae6fa7144b30321e754773af4a2d464c9e52c624 /test/org/traccar
parent3826a93f1009942e22ec80c1e13be71e8e917b01 (diff)
downloadtrackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.gz
trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.tar.bz2
trackermap-server-1c7437d6de01fffbe3f69853717808b1790413fd.zip
- Added trips report
- Refactored reports models - Added tests for ReportUtils - Added speed to test-generator.py - Other changes
Diffstat (limited to 'test/org/traccar')
-rw-r--r--test/org/traccar/reports/ReportUtilsTest.java34
1 files changed, 34 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..e7f762b28
--- /dev/null
+++ b/test/org/traccar/reports/ReportUtilsTest.java
@@ -0,0 +1,34 @@
+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);
+ Position endPosition = new Position();
+ endPosition.set(Position.KEY_TOTAL_DISTANCE, 700);
+ 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.calculateSpentFuel(startPosition, endPosition), "-");
+ startPosition.setProtocol("meitrack");
+ startPosition.set(Position.KEY_FUEL, 0.07);
+ endPosition.set(Position.KEY_FUEL, 0.05);
+ Assert.assertEquals(ReportUtils.calculateSpentFuel(startPosition, endPosition), "0.02 %");
+ startPosition.setProtocol("galileo");
+ Assert.assertEquals(ReportUtils.calculateSpentFuel(startPosition, endPosition), "0.02 %");
+ }
+
+}