Merge branch 'route_alternatives'
LocationBasedServices/sumoc-backend/pipeline/head There was a failure building this commit
LocationBasedServices/sumoc-backend/pipeline/head There was a failure building this commit
This commit is contained in:
+36
-16
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user