diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-10-30 21:39:32 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-30 21:39:32 +1300 |
commit | 6475bc9db3b1446bb90d2102003201db5611ddf0 (patch) | |
tree | c43d07825f153abd980bb3239227161952b3c500 /test/org/traccar | |
parent | 273a4b7ab23a66ddfdeb05f69edc21a970b6844c (diff) | |
parent | aa606dfd6159dc7e0d1ab35f656654db03c1cdec (diff) | |
download | trackermap-server-6475bc9db3b1446bb90d2102003201db5611ddf0.tar.gz trackermap-server-6475bc9db3b1446bb90d2102003201db5611ddf0.tar.bz2 trackermap-server-6475bc9db3b1446bb90d2102003201db5611ddf0.zip |
Merge pull request #3617 from Abyss777/math_jexl
Map "Math" to Computed Attributes context
Diffstat (limited to 'test/org/traccar')
-rw-r--r-- | test/org/traccar/processing/ComputedAttributesTest.java | 17 |
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()); - + } } |