From c165968c2eb24b1c4a35dab39174b4df3576551c Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 17 Dec 2023 11:43:51 -0800 Subject: Improve cache update performance --- .../handler/events/MaintenanceEventHandlerTest.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/test/java/org') 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()); } -- cgit v1.2.3