From 836dc4138fdcf560a31c6a90769b19f6a0d0e438 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Wed, 14 Dec 2022 15:37:54 -0800 Subject: Add motion fluctuation test --- .../handler/events/MotionEventHandlerTest.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src') diff --git a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java index 22afbfa52..25c766b51 100644 --- a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java +++ b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java @@ -1,5 +1,6 @@ package org.traccar.handler.events; +import org.junit.Ignore; import org.junit.Test; import org.traccar.BaseTest; import org.traccar.model.Event; @@ -61,6 +62,38 @@ public class MotionEventHandlerTest extends BaseTest { verifyState(state, false, 0); } + @Ignore + @Test + public void testMotionFluctuation() throws ParseException { + TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false, 0.01); + + MotionState state = new MotionState(); + + MotionProcessor.updateState(state, position("2017-01-01 00:00:00", false, 0, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 100, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 100); + + MotionProcessor.updateState(state, position("2017-01-01 00:02:00", true, 700, null), true, tripsConfig); + assertEquals(Event.TYPE_DEVICE_MOVING, state.getEvent().getType()); + verifyState(state, true, 0); + + MotionProcessor.updateState(state, position("2017-01-01 00:03:00", false, 700, null), false, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, false, 700); + + MotionProcessor.updateState(state, position("2017-01-01 00:04:00", true, 1000, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 1000); + + MotionProcessor.updateState(state, position("2017-01-01 00:06:00", true, 2000, null), true, tripsConfig); + assertNull(state.getEvent()); + verifyState(state, true, 2000); + } + @Test public void testStopWithPositionIgnition() throws ParseException { TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, true, false, 0.01); -- cgit v1.2.3