aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/org/traccar
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2023-12-17 11:43:51 -0800
committerAnton Tananaev <anton@traccar.org>2023-12-17 11:43:51 -0800
commitc165968c2eb24b1c4a35dab39174b4df3576551c (patch)
tree6dae35ddec3feb14151e5c711f4d0f5865cbc64e /src/test/java/org/traccar
parent4dc2e86ae5e403143b3c4e2c1a3bd671dfeaf5f8 (diff)
downloadtrackermap-server-c165968c2eb24b1c4a35dab39174b4df3576551c.tar.gz
trackermap-server-c165968c2eb24b1c4a35dab39174b4df3576551c.tar.bz2
trackermap-server-c165968c2eb24b1c4a35dab39174b4df3576551c.zip
Improve cache update performance
Diffstat (limited to 'src/test/java/org/traccar')
-rw-r--r--src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java b/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java
index 5320be926..661336d76 100644
--- a/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java
+++ b/src/test/java/org/traccar/handler/events/MaintenanceEventHandlerTest.java
@@ -6,14 +6,15 @@ import org.traccar.model.Maintenance;
import org.traccar.model.Position;
import org.traccar.session.cache.CacheManager;
-import java.util.Arrays;
import java.util.Date;
+import java.util.Set;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.ArgumentMatchers.anyLong;
public class MaintenanceEventHandlerTest extends BaseTest {
@@ -29,7 +30,7 @@ public class MaintenanceEventHandlerTest extends BaseTest {
var maintenance = mock(Maintenance.class);
when(maintenance.getType()).thenReturn(Position.KEY_TOTAL_DISTANCE);
- var maintenances = Arrays.asList(maintenance);
+ var maintenances = Set.of(maintenance);
var cacheManager = mock(CacheManager.class);
when(cacheManager.getDeviceObjects(anyLong(), eq(Maintenance.class))).thenReturn(maintenances);
@@ -48,12 +49,12 @@ public class MaintenanceEventHandlerTest extends BaseTest {
assertTrue(eventHandler.analyzePosition(position).isEmpty());
lastPosition.set(Position.KEY_TOTAL_DISTANCE, 9999);
- position.set(Position.KEY_TOTAL_DISTANCE, 10001);
- assertTrue(eventHandler.analyzePosition(position).size() == 1);
+ position.set(Position.KEY_TOTAL_DISTANCE, 10001);
+ assertEquals(1, eventHandler.analyzePosition(position).size());
lastPosition.set(Position.KEY_TOTAL_DISTANCE, 11999);
- position.set(Position.KEY_TOTAL_DISTANCE, 12001);
- assertTrue(eventHandler.analyzePosition(position).size() == 1);
+ position.set(Position.KEY_TOTAL_DISTANCE, 12001);
+ assertEquals(1, eventHandler.analyzePosition(position).size());
}