eventhub/.analysis/TmpPrint.java

46 lines
2.8 KiB
Java

package at.procon.eventhub.processing.api;
import at.procon.eventhub.dto.*;
import at.procon.eventhub.processing.model.*;
import at.procon.eventhub.processing.service.*;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.time.OffsetDateTime;
import java.util.*;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.when;
public class TmpPrint {
public static void main(String[] args) throws Exception {
UnifiedRuntimeEventAssemblyService eventAssemblyService = org.mockito.Mockito.mock(UnifiedRuntimeEventAssemblyService.class);
UnifiedRuntimeDriverTimelineService timelineService = org.mockito.Mockito.mock(UnifiedRuntimeDriverTimelineService.class);
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(new UnifiedRuntimeProcessingController(eventAssemblyService, timelineService))
.setControllerAdvice(new UnifiedRuntimeProcessingExceptionHandler())
.build();
ObjectMapper om = new ObjectMapper().findAndRegisterModules();
UUID sessionId = UUID.randomUUID();
UnifiedRuntimeProcessingRequest request = UnifiedRuntimeProcessingRequest.forTachographFileSession(
sessionId, "12:123", OffsetDateTime.parse("2026-05-01T08:00:00Z"), OffsetDateTime.parse("2026-05-01T10:00:00Z"), true, 0);
EventHubEventDto event = new EventHubEventDto(
UUID.randomUUID(), "EV-1", new DriverRefDto("12:123", null),
new VehicleRefDto("VEH-1", "VIN-1", "VR-1", new VehicleRegistrationRefDto("12", 12, "REG-1")),
OffsetDateTime.parse("2026-05-01T08:00:00Z"), null, OffsetDateTime.parse("2026-05-01T08:00:00Z"),
EventDomain.DRIVER_ACTIVITY, EventType.DRIVE, EventLifecycle.START, null, null,
new EventDetailsDto("DRIVER_ACTIVITY", om.valueToTree(Map.of("cardSlot", "DRIVER"))),
null,
om.valueToTree(Map.of("raw", Map.of("driverKey", "12:123", "intervalId", "ACT-1"))),
false,
null
);
when(eventAssemblyService.assembleDriverScopedEvents(any()))
.thenReturn(new UnifiedRuntimeEventBundle(request, List.of(event), List.of(), List.of(), List.of(event), List.of()));
String body = mockMvc.perform(post("/api/eventhub/runtime-processing/driver-events")
.contentType("application/json")
.content("{\"sessionId\":\"" + sessionId + "\",\"sourceFamilies\":[\"TACHOGRAPH_FILE_SESSION\"],\"driverKey\":\"12:123\",\"occurredFrom\":\"2026-05-01T08:00:00Z\",\"occurredTo\":\"2026-05-01T10:00:00Z\",\"expandVehicleEvents\":true,\"vehicleExpansionPaddingMinutes\":0}"))
.andReturn().getResponse().getContentAsString();
System.out.println(body);
}
}