aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar/handler/MotionHandlerTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java/org/traccar/handler/MotionHandlerTest.java')
-rw-r--r--src/test/java/org/traccar/handler/MotionHandlerTest.java22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/test/java/org/traccar/handler/MotionHandlerTest.java b/src/test/java/org/traccar/handler/MotionHandlerTest.java
index 9e0859664..10cdf6a90 100644
--- a/src/test/java/org/traccar/handler/MotionHandlerTest.java
+++ b/src/test/java/org/traccar/handler/MotionHandlerTest.java
@@ -1,16 +1,30 @@
package org.traccar.handler;
-import static org.junit.Assert.assertEquals;
-
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.traccar.config.Config;
+import org.traccar.config.Keys;
+import org.traccar.model.Device;
import org.traccar.model.Position;
+import org.traccar.session.cache.CacheManager;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
public class MotionHandlerTest {
@Test
public void testCalculateMotion() {
- MotionHandler motionHandler = new MotionHandler(0.01);
+ var cacheManager = mock(CacheManager.class);
+ when(cacheManager.getObject(eq(Device.class), anyLong())).thenReturn(mock(Device.class));
+ var config = mock(Config.class);
+ when(config.getString(Keys.EVENT_MOTION_SPEED_THRESHOLD.getKey())).thenReturn("0.01");
+ when(cacheManager.getConfig()).thenReturn(config);
+
+ MotionHandler motionHandler = new MotionHandler(cacheManager);
Position position = motionHandler.handlePosition(new Position());