aboutsummaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/traccar/handler/MotionHandlerTest.java16
-rw-r--r--src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java6
-rw-r--r--src/test/java/org/traccar/reports/ReportUtilsTest.java16
3 files changed, 23 insertions, 15 deletions
diff --git a/src/test/java/org/traccar/handler/MotionHandlerTest.java b/src/test/java/org/traccar/handler/MotionHandlerTest.java
index 2a7af23ba..10cdf6a90 100644
--- a/src/test/java/org/traccar/handler/MotionHandlerTest.java
+++ b/src/test/java/org/traccar/handler/MotionHandlerTest.java
@@ -1,10 +1,15 @@
package org.traccar.handler;
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.reports.common.TripsConfig;
+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;
@@ -13,10 +18,13 @@ public class MotionHandlerTest {
@Test
public void testCalculateMotion() {
- TripsConfig tripsConfig = mock(TripsConfig.class);
- when(tripsConfig.getSpeedThreshold()).thenReturn(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(tripsConfig);
+ MotionHandler motionHandler = new MotionHandler(cacheManager);
Position position = motionHandler.handlePosition(new Position());
diff --git a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java
index f2d858656..2be3f4647 100644
--- a/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java
+++ b/src/test/java/org/traccar/handler/events/MotionEventHandlerTest.java
@@ -36,7 +36,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionWithPosition() throws ParseException {
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false);
MotionState state = new MotionState();
@@ -63,7 +63,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testMotionFluctuation() throws ParseException {
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, false, false);
MotionState state = new MotionState();
@@ -94,7 +94,7 @@ public class MotionEventHandlerTest extends BaseTest {
@Test
public void testStopWithPositionIgnition() throws ParseException {
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, true, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 300000, 0, true, false);
MotionState state = new MotionState();
state.setMotionStreak(true);
diff --git a/src/test/java/org/traccar/reports/ReportUtilsTest.java b/src/test/java/org/traccar/reports/ReportUtilsTest.java
index 09e5b3e27..e116f24b4 100644
--- a/src/test/java/org/traccar/reports/ReportUtilsTest.java
+++ b/src/test/java/org/traccar/reports/ReportUtilsTest.java
@@ -101,7 +101,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:15:00.000", 0, 3000),
position("2016-01-01 00:25:00.000", 0, 3000));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -156,7 +156,7 @@ public class ReportUtilsTest extends BaseTest {
data.get(5).set(Position.KEY_IGNITION, false);
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, true, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -227,7 +227,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:19:00.000", 0, 7000),
position("2016-01-01 00:29:00.000", 0, 7000));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 180000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -278,7 +278,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 1, 0),
position("2016-01-01 00:05:00.000", 0, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -307,7 +307,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 1, 0),
position("2016-01-01 00:05:00.000", 2, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -336,7 +336,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:22:00.000", 0, 0),
position("2016-01-01 00:32:00.000", 0, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -365,7 +365,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:04:00.000", 5, 0),
position("2016-01-01 00:05:00.000", 5, 0));
- TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 300000, 200000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);
@@ -390,7 +390,7 @@ public class ReportUtilsTest extends BaseTest {
position("2016-01-01 00:24:00.000", 5, 800),
position("2016-01-01 00:25:00.000", 5, 900));
- TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false, 0.01);
+ TripsConfig tripsConfig = new TripsConfig(500, 200000, 200000, 900000, false, false);
ReportUtils reportUtils = new ReportUtils(
mock(Config.class), storage, mock(PermissionsService.class),
tripsConfig, mock(VelocityEngine.class), null);