From bf51c1994531da91f364b81d6d8c0778ed9c3570 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Thu, 7 Mar 2019 21:21:22 -0800 Subject: Refactor overspeed handler --- .../handler/events/OverspeedEventHandlerTest.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'test/org/traccar/handler/events') 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)); -- cgit v1.2.3