diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-08-17 17:12:44 +1200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-17 17:12:44 +1200 |
commit | 9e9f97ac34d882594e3d23e959775ce765447787 (patch) | |
tree | 775ad2a42ebba160d1e36be38c59384cd1da5a1e /test/org/traccar/events/OverspeedEventHandlerTest.java | |
parent | e8739edc4e2b3a945c2b0eeec6286f7ef59037cf (diff) | |
parent | 1324c00d0ece6e20545fb75f7775a2c6cee2a391 (diff) | |
download | trackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.tar.gz trackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.tar.bz2 trackermap-server-9e9f97ac34d882594e3d23e959775ce765447787.zip |
Merge pull request #3449 from Abyss777/load_position
Map correct position to delayed event notification
Diffstat (limited to 'test/org/traccar/events/OverspeedEventHandlerTest.java')
-rw-r--r-- | test/org/traccar/events/OverspeedEventHandlerTest.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/test/org/traccar/events/OverspeedEventHandlerTest.java b/test/org/traccar/events/OverspeedEventHandlerTest.java index 48d7445ff..d38367cd9 100644 --- a/test/org/traccar/events/OverspeedEventHandlerTest.java +++ b/test/org/traccar/events/OverspeedEventHandlerTest.java @@ -9,6 +9,7 @@ import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; +import java.util.Map; import java.util.TimeZone; import org.junit.Test; @@ -34,8 +35,8 @@ public class OverspeedEventHandlerTest extends BaseTest { DeviceState deviceState = new DeviceState(); deviceState.setOverspeedState(false); - Event event = overspeedEventHandler.updateOverspeedState(deviceState, position, 40); - assertNull(event); + Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, position, 40); + assertNull(events); assertFalse(deviceState.getOverspeedState()); assertEquals(position, deviceState.getOverspeedPosition()); @@ -43,13 +44,14 @@ public class OverspeedEventHandlerTest extends BaseTest { nextPosition.setTime(date("2017-01-01 00:00:10")); nextPosition.setSpeed(55); - event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); - assertNull(event); + events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); + assertNull(events); nextPosition.setTime(date("2017-01-01 00:00:20")); - event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); - assertNotNull(event); + events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); + assertNotNull(events); + Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); assertEquals(50, event.getDouble("speed"), 0.1); assertEquals(40, event.getDouble(OverspeedEventHandler.ATTRIBUTE_SPEED_LIMIT), 0.1); @@ -58,8 +60,8 @@ public class OverspeedEventHandlerTest extends BaseTest { assertNull(deviceState.getOverspeedPosition()); nextPosition.setTime(date("2017-01-01 00:00:30")); - event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); - assertNull(event); + events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); + assertNull(events); assertEquals(notRepeat, deviceState.getOverspeedState()); if (notRepeat) { @@ -71,8 +73,8 @@ public class OverspeedEventHandlerTest extends BaseTest { nextPosition.setTime(date("2017-01-01 00:00:40")); nextPosition.setSpeed(30); - event = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); - assertNull(event); + events = overspeedEventHandler.updateOverspeedState(deviceState, nextPosition, 40); + assertNull(events); assertFalse(deviceState.getOverspeedState()); assertNull(deviceState.getOverspeedPosition()); } @@ -87,9 +89,10 @@ public class OverspeedEventHandlerTest extends BaseTest { deviceState.setOverspeedState(false); deviceState.setOverspeedPosition(position); - Event event = overspeedEventHandler.updateOverspeedState(deviceState, 40); + Map<Event, Position> events = overspeedEventHandler.updateOverspeedState(deviceState, 40); - assertNotNull(event); + assertNotNull(events); + Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_OVERSPEED, event.getType()); assertEquals(notRepeat, deviceState.getOverspeedState()); } |