aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/handler/ComputedAttributesTest.java
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2019-03-31 22:35:39 -0700
commit59416923dcb3a756eaf532cc4259f2f6625c0762 (patch)
tree9082dae6616deac8fda432b7bfd80e4a52b6d9dc /test/org/traccar/handler/ComputedAttributesTest.java
parent79a129dd6327d932133d6b9a50190d3f4927bff9 (diff)
downloadtrackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.gz
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.tar.bz2
trackermap-server-59416923dcb3a756eaf532cc4259f2f6625c0762.zip
Convert project to gradle
Diffstat (limited to 'test/org/traccar/handler/ComputedAttributesTest.java')
-rw-r--r--test/org/traccar/handler/ComputedAttributesTest.java71
1 files changed, 0 insertions, 71 deletions
diff --git a/test/org/traccar/handler/ComputedAttributesTest.java b/test/org/traccar/handler/ComputedAttributesTest.java
deleted file mode 100644
index a76d8169b..000000000
--- a/test/org/traccar/handler/ComputedAttributesTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package org.traccar.handler;
-
-import java.util.Date;
-
-import org.junit.Test;
-import org.traccar.config.Config;
-import org.traccar.model.Attribute;
-import org.traccar.model.Position;
-
-import static org.junit.Assert.assertEquals;
-
-public class ComputedAttributesTest {
-
- @Test
- public void testComputedAttributes() {
-
- ComputedAttributesHandler handler = new ComputedAttributesHandler(new Config(), null, null);
-
- Date date = new Date();
- Position position = new Position();
- position.setTime(date);
- position.setSpeed(42);
- position.setValid(false);
- position.set("adc1", 128);
- position.set("booleanFlag", true);
- position.set("adc2", 100);
- position.set("bitFlag", 7);
- position.set("event", 42);
- position.set("result", "success");
- Attribute attribute = new Attribute();
-
- attribute.setExpression("adc1");
- assertEquals(128, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("!booleanFlag");
- assertEquals(false, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("adc2 * 2 + 50");
- assertEquals(250, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("(bitFlag & 4) != 0");
- assertEquals(true, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("if (event == 42) \"lowBattery\"");
- assertEquals("lowBattery", handler.computeAttribute(attribute, position));
-
- attribute.setExpression("speed > 5 && valid");
- assertEquals(false, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("fixTime");
- assertEquals(date, handler.computeAttribute(attribute, position));
-
- attribute.setExpression("math:pow(adc1, 2)");
- assertEquals(16384.0, handler.computeAttribute(attribute, position));
-
- // modification tests
- attribute.setExpression("adc1 = 256");
- handler.computeAttribute(attribute, position);
- assertEquals(128, position.getInteger("adc1"));
-
- attribute.setExpression("result = \"fail\"");
- handler.computeAttribute(attribute, position);
- assertEquals("success", position.getString("result"));
-
- attribute.setExpression("fixTime = \"2017-10-18 10:00:01\"");
- handler.computeAttribute(attribute, position);
- assertEquals(date, position.getFixTime());
-
- }
-
-}