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/MotionEventHandlerTest.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/MotionEventHandlerTest.java')
-rw-r--r-- | test/org/traccar/events/MotionEventHandlerTest.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/test/org/traccar/events/MotionEventHandlerTest.java b/test/org/traccar/events/MotionEventHandlerTest.java index 902be8b87..b88328e58 100644 --- a/test/org/traccar/events/MotionEventHandlerTest.java +++ b/test/org/traccar/events/MotionEventHandlerTest.java @@ -10,6 +10,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; @@ -45,12 +46,13 @@ public class MotionEventHandlerTest extends BaseTest { nextPosition.set(Position.KEY_MOTION, true); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - Event event = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNull(event); + Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition); + assertNull(events); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 600); - event = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNotNull(event); + events = motionEventHandler.updateMotionState(deviceState, nextPosition); + assertNotNull(events); + Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); assertTrue(deviceState.getMotionState()); assertNull(deviceState.getMotionPosition()); @@ -59,8 +61,9 @@ public class MotionEventHandlerTest extends BaseTest { deviceState.setMotionPosition(position); nextPosition.setTime(date("2017-01-01 00:06:00")); nextPosition.set(Position.KEY_TOTAL_DISTANCE, 200); - event = motionEventHandler.updateMotionState(deviceState, nextPosition); + events = motionEventHandler.updateMotionState(deviceState, nextPosition); assertNotNull(event); + event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); assertTrue(deviceState.getMotionState()); assertNull(deviceState.getMotionPosition()); @@ -78,9 +81,10 @@ public class MotionEventHandlerTest extends BaseTest { deviceState.setMotionState(false); deviceState.setMotionPosition(position); - Event event = motionEventHandler.updateMotionState(deviceState); + Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState); - assertNotNull(event); + assertNotNull(events); + Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_MOVING, event.getType()); assertTrue(deviceState.getMotionState()); assertNull(deviceState.getMotionPosition()); @@ -104,8 +108,9 @@ public class MotionEventHandlerTest extends BaseTest { nextPosition.set(Position.KEY_MOTION, false); nextPosition.set(Position.KEY_IGNITION, false); - Event event = motionEventHandler.updateMotionState(deviceState, nextPosition); - assertNotNull(event); + Map<Event, Position> events = motionEventHandler.updateMotionState(deviceState, nextPosition); + assertNotNull(events); + Event event = events.keySet().iterator().next(); assertEquals(Event.TYPE_DEVICE_STOPPED, event.getType()); assertFalse(deviceState.getMotionState()); assertNull(deviceState.getMotionPosition()); |