From e2e1cc48a093578fbbd63eb1b6649cfde8991332 Mon Sep 17 00:00:00 2001 From: David Neuhauss Date: Mon, 26 Jan 2026 17:43:18 +0100 Subject: [PATCH 1/2] refactor to proper unit test --- .../IterativeClustererTest.java | 52 +++++++++++++------ 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/test/java/SuMoC/backend/regulartrip/detectionapproaches/IterativeClustererTest.java b/src/test/java/SuMoC/backend/regulartrip/detectionapproaches/IterativeClustererTest.java index 99042d9..06e2bb4 100644 --- a/src/test/java/SuMoC/backend/regulartrip/detectionapproaches/IterativeClustererTest.java +++ b/src/test/java/SuMoC/backend/regulartrip/detectionapproaches/IterativeClustererTest.java @@ -1,37 +1,57 @@ package SuMoC.backend.regulartrip.detectionapproaches; import SuMoC.backend.Factories.RegularTripDetectionDTOFactory; +import SuMoC.backend.h3.H3Service; import SuMoC.backend.regulartrip.config.RegularTripDetectionProperties; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.mockito.InjectMocks; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; +import org.mockito.junit.jupiter.MockitoExtension; +import java.util.Arrays; + +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; -@SpringBootTest(properties = { - "geocoding.provider=carta", - "geocoding.carta.base-url=https://mobydex.locoslab.com/carta" -}) +@ExtendWith(MockitoExtension.class) public class IterativeClustererTest { - @Mock(lenient = true) - private RegularTripDetectionProperties properties; + @Mock + private H3Service h3Service; - @InjectMocks private IterativeClusterer iterativeClusterer; - - @Autowired private RegularTripDetectionDTOFactory regularTripDetectionDTOFactory; @BeforeEach void setUp() { - when(properties.getDetectionTimeWindowDays()).thenReturn(30); - when(properties.getTimeWindowSeconds()).thenReturn(90 * 60); - when(properties.getMinTripsForRegularity()).thenReturn(2); - when(properties.getIterativeShuffleAmounts()).thenReturn(5); + // Set up properties + RegularTripDetectionProperties properties = new RegularTripDetectionProperties(); + properties.setDetectionTimeWindowDays(40); + properties.setTimeWindowSeconds(5400); + properties.setMinTripsForRegularity(2); + properties.setIterativeShuffleAmounts(5); + + // Create the clusterer with properties + iterativeClusterer = new IterativeClusterer(properties); + + // Mock H3Service to return consistent neighbor lists + // Each H3 cell has 6 neighbors in a hexagonal grid + when(h3Service.getRoutePatternNeighbors(anyString())).thenAnswer(invocation -> { + String cellId = invocation.getArgument(0); + // Generate 6 consistent neighbor IDs based on the cell ID + return Arrays.asList( + cellId + "n1", + cellId + "n2", + cellId + "n3", + cellId + "n4", + cellId + "n5", + cellId + "n6" + ); + }); + + // Create the factory with mocked H3Service + regularTripDetectionDTOFactory = new RegularTripDetectionDTOFactory(h3Service); } /** From 88fcbfb7286382288b0059a5ae5c28018c5da39d Mon Sep 17 00:00:00 2001 From: David Neuhauss Date: Wed, 28 Jan 2026 10:16:25 +0100 Subject: [PATCH 2/2] fix entrypoint --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 5a5f39b..d299dfa 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh # Decrypt secrets if key is provided if [ -z "$FCM_DECRYPTION_KEY" ]; then