aboutsummaryrefslogtreecommitdiff
path: root/test/org
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-08-17 10:10:05 +0500
committerAbyss777 <abyss@fox5.ru>2017-08-17 10:10:05 +0500
commit1324c00d0ece6e20545fb75f7775a2c6cee2a391 (patch)
tree775ad2a42ebba160d1e36be38c59384cd1da5a1e /test/org
parent9476e6be8fae228cda5867750bc4d102b1f9497d (diff)
downloadtrackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.gz
trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.tar.bz2
trackermap-server-1324c00d0ece6e20545fb75f7775a2c6cee2a391.zip
Pass Map<Event, Position> to notifications
Diffstat (limited to 'test/org')
-rw-r--r--test/org/traccar/events/AlertEventHandlerTest.java6
-rw-r--r--test/org/traccar/events/CommandResultEventHandlerTest.java6
-rw-r--r--test/org/traccar/events/IgnitionEventHandlerTest.java4
-rw-r--r--test/org/traccar/events/MotionEventHandlerTest.java23
-rw-r--r--test/org/traccar/events/OverspeedEventHandlerTest.java27
5 files changed, 37 insertions, 29 deletions
diff --git a/test/org/traccar/events/AlertEventHandlerTest.java b/test/org/traccar/events/AlertEventHandlerTest.java
index 77128f066..4e11398e1 100644
--- a/test/org/traccar/events/AlertEventHandlerTest.java
+++ b/test/org/traccar/events/AlertEventHandlerTest.java
@@ -3,7 +3,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,9 +19,9 @@ public class AlertEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_ALARM, Position.ALARM_GENERAL);
- Collection<Event> events = alertEventHandler.analyzePosition(position);
+ Map<Event, Position> events = alertEventHandler.analyzePosition(position);
assertNotNull(events);
- Event event = (Event) events.toArray()[0];
+ Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_ALARM, event.getType());
}
diff --git a/test/org/traccar/events/CommandResultEventHandlerTest.java b/test/org/traccar/events/CommandResultEventHandlerTest.java
index f028e86ee..602108d1a 100644
--- a/test/org/traccar/events/CommandResultEventHandlerTest.java
+++ b/test/org/traccar/events/CommandResultEventHandlerTest.java
@@ -3,7 +3,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,9 +19,9 @@ public class CommandResultEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_RESULT, "Test Result");
- Collection<Event> events = commandResultEventHandler.analyzePosition(position);
+ Map<Event, Position> events = commandResultEventHandler.analyzePosition(position);
assertNotNull(events);
- Event event = (Event) events.toArray()[0];
+ Event event = events.keySet().iterator().next();
assertEquals(Event.TYPE_COMMAND_RESULT, event.getType());
}
diff --git a/test/org/traccar/events/IgnitionEventHandlerTest.java b/test/org/traccar/events/IgnitionEventHandlerTest.java
index d6c348c77..7c4ac21b9 100644
--- a/test/org/traccar/events/IgnitionEventHandlerTest.java
+++ b/test/org/traccar/events/IgnitionEventHandlerTest.java
@@ -2,7 +2,7 @@ package org.traccar.events;
import static org.junit.Assert.assertEquals;
-import java.util.Collection;
+import java.util.Map;
import org.junit.Test;
import org.traccar.BaseTest;
@@ -19,7 +19,7 @@ public class IgnitionEventHandlerTest extends BaseTest {
Position position = new Position();
position.set(Position.KEY_IGNITION, true);
position.setValid(true);
- Collection<Event> events = ignitionEventHandler.analyzePosition(position);
+ Map<Event, Position> events = ignitionEventHandler.analyzePosition(position);
assertEquals(events, null);
}
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());
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());
}