aboutsummaryrefslogtreecommitdiff
path: root/test/org/traccar/processing/ComputedAttributesTest.java
diff options
context:
space:
mode:
authorIvan Muratov <binakot@gmail.com>2017-11-03 15:10:45 +0300
committerGitHub <noreply@github.com>2017-11-03 15:10:45 +0300
commit4e07d664cac49fcbb47376471ef9f4d770293ba9 (patch)
tree7eaa0886dcb6e44cf4d4aa549abbbaca6533f654 /test/org/traccar/processing/ComputedAttributesTest.java
parent74cea90707321c775c11e9cfb91269f63ab4476f (diff)
parentc62dd84c7ad4061c0c6d8a521c63857ccde461ba (diff)
downloadtrackermap-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.tar.gz
trackermap-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.tar.bz2
trackermap-server-4e07d664cac49fcbb47376471ef9f4d770293ba9.zip
Merge branch 'master' into master
Diffstat (limited to 'test/org/traccar/processing/ComputedAttributesTest.java')
-rw-r--r--test/org/traccar/processing/ComputedAttributesTest.java17
1 files changed, 10 insertions, 7 deletions
diff --git a/test/org/traccar/processing/ComputedAttributesTest.java b/test/org/traccar/processing/ComputedAttributesTest.java
index ac4331c6d..fe898ff54 100644
--- a/test/org/traccar/processing/ComputedAttributesTest.java
+++ b/test/org/traccar/processing/ComputedAttributesTest.java
@@ -8,7 +8,7 @@ import org.traccar.model.Attribute;
import org.traccar.model.Position;
public class ComputedAttributesTest {
-
+
@Test
public void testComputedAttributes() {
Position position = new Position();
@@ -39,26 +39,29 @@ public class ComputedAttributesTest {
attribute.setExpression("if (event == 42) \"lowBattery\"");
Assert.assertEquals("lowBattery", computedAttributesHandler.computeAttribute(attribute, position));
-
+
attribute.setExpression("speed > 5 && valid");
Assert.assertEquals(false, computedAttributesHandler.computeAttribute(attribute, position));
-
+
attribute.setExpression("fixTime");
Assert.assertEquals(date, computedAttributesHandler.computeAttribute(attribute, position));
-
+
+ attribute.setExpression("math:pow(adc1, 2)");
+ Assert.assertEquals(16384.0, computedAttributesHandler.computeAttribute(attribute, position));
+
// modification tests
attribute.setExpression("adc1 = 256");
computedAttributesHandler.computeAttribute(attribute, position);
Assert.assertEquals(128, position.getInteger("adc1"));
-
+
attribute.setExpression("result = \"fail\"");
computedAttributesHandler.computeAttribute(attribute, position);
Assert.assertEquals("success", position.getString("result"));
-
+
attribute.setExpression("fixTime = \"2017-10-18 10:00:01\"");
computedAttributesHandler.computeAttribute(attribute, position);
Assert.assertEquals(date, position.getFixTime());
-
+
}
}