diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-07 21:21:22 -0800 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2019-03-07 21:21:22 -0800 |
commit | bf51c1994531da91f364b81d6d8c0778ed9c3570 (patch) | |
tree | d39930217931b52a763162dc946c72822a524d9b /test | |
parent | 4e68a40c77240800dce14094b4cc55907410c208 (diff) | |
download | traccar-server-bf51c1994531da91f364b81d6d8c0778ed9c3570.tar.gz traccar-server-bf51c1994531da91f364b81d6d8c0778ed9c3570.tar.bz2 traccar-server-bf51c1994531da91f364b81d6d8c0778ed9c3570.zip |
Refactor overspeed handler
Diffstat (limited to 'test')
-rw-r--r-- | test/org/traccar/handler/events/OverspeedEventHandlerTest.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/test/org/traccar/handler/events/OverspeedEventHandlerTest.java b/test/org/traccar/handler/events/OverspeedEventHandlerTest.java index 584ac271a..515f37b5d 100644 --- a/test/org/traccar/handler/events/OverspeedEventHandlerTest.java +++ b/test/org/traccar/handler/events/OverspeedEventHandlerTest.java @@ -14,6 +14,8 @@ import java.util.TimeZone; import org.junit.Test; import org.traccar.BaseTest; +import org.traccar.config.Config; +import org.traccar.config.Keys; import org.traccar.model.DeviceState; import org.traccar.model.Event; import org.traccar.model.Position; @@ -26,8 +28,12 @@ public class OverspeedEventHandlerTest extends BaseTest { return dateFormat.parse(time); } - private void testOverspeedWithPosition(boolean notRepeat, long geofenceId) throws Exception { - OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat, false); + private void testOverspeedWithPosition(boolean notRepeat, long geofenceId) throws ParseException { + Config config = new Config(); + config.setString(Keys.EVENT_OVERSPEED_NOT_REPEAT, String.valueOf(notRepeat)); + config.setString(Keys.EVENT_OVERSPEED_MINIMAL_DURATION, String.valueOf(15)); + config.setString(Keys.EVENT_OVERSPEED_PREFER_LOWEST, String.valueOf(false)); + OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(config, null, null); Position position = new Position(); position.setTime(date("2017-01-01 00:00:00")); @@ -85,8 +91,12 @@ public class OverspeedEventHandlerTest extends BaseTest { assertEquals(0, deviceState.getOverspeedGeofenceId()); } - private void testOverspeedWithStatus(boolean notRepeat) throws Exception { - OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(15000, notRepeat, false); + private void testOverspeedWithStatus(boolean notRepeat) { + Config config = new Config(); + config.setString(Keys.EVENT_OVERSPEED_NOT_REPEAT, String.valueOf(notRepeat)); + config.setString(Keys.EVENT_OVERSPEED_MINIMAL_DURATION, String.valueOf(15)); + config.setString(Keys.EVENT_OVERSPEED_PREFER_LOWEST, String.valueOf(false)); + OverspeedEventHandler overspeedEventHandler = new OverspeedEventHandler(config, null, null); Position position = new Position(); position.setTime(new Date(System.currentTimeMillis() - 30000)); |