diff --git a/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceDummy.kt b/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceDummy.kt index 0d367d59a..0ba318a15 100644 --- a/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceDummy.kt +++ b/bpdm-cleaning-service-dummy/src/main/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceDummy.kt @@ -41,26 +41,27 @@ class CleaningServiceDummy( fun pollForCleaningTasks() { try { logger.info { "Starting polling for cleaning tasks from Orchestrator..." } + val step = TaskStep.CleanAndSync // Step 1: Fetch and reserve the next cleaning request val cleaningRequest = orchestrationApiClient.goldenRecordTasks - .reserveTasksForStep(TaskStepReservationRequest(amount = 10, TaskStep.CleanAndSync)) + .reserveTasksForStep(TaskStepReservationRequest(amount = 10, step)) val cleaningTasks = cleaningRequest.reservedTasks logger.info { "${cleaningTasks.size} tasks found for cleaning. Proceeding with cleaning..." } if (cleaningTasks.isNotEmpty()) { - val cleaningResults = cleaningTasks.map { reservedTask -> // Step 2: Generate dummy cleaning results processCleaningTask(reservedTask) } // Step 3: Send the cleaning result back to the Orchestrator - orchestrationApiClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(cleaningResults)) + orchestrationApiClient.goldenRecordTasks.resolveStepResults(TaskStepResultRequest(step, cleaningResults)) logger.info { "Cleaning tasks processing completed for this iteration." } } + } catch (e: Exception) { logger.error(e) { "Error while processing cleaning task" } } diff --git a/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceApiCallsTest.kt b/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceApiCallsTest.kt index 3b72b28db..15ef3c6c2 100644 --- a/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceApiCallsTest.kt +++ b/bpdm-cleaning-service-dummy/src/test/kotlin/org/eclipse/tractusx/bpdm/cleaning/service/CleaningServiceApiCallsTest.kt @@ -78,7 +78,6 @@ class CleaningServiceApiCallsTest @Autowired constructor( @Test fun `pollForCleaningTasks should reserve and resolve tasks from orchestrator`() { - // Call the method under test cleaningServiceDummy.pollForCleaningTasks() @@ -91,11 +90,8 @@ class CleaningServiceApiCallsTest @Autowired constructor( @Test fun `reserveTasksForStep should return expected response`() { - - val expectedResponse = jacksonObjectMapper.writeValueAsString(createSampleTaskStepReservationResponse(businessPartnerWithBpnA)) - val result = orchestrationApiClient.goldenRecordTasks.reserveTasksForStep( TaskStepReservationRequest(amount = 10, TaskStep.Clean) ) @@ -105,14 +101,12 @@ class CleaningServiceApiCallsTest @Autowired constructor( assertEquals(expectedResult, result) orchestrationApiClient.goldenRecordTasks.resolveStepResults( - TaskStepResultRequest(emptyList()) + TaskStepResultRequest(TaskStep.Clean, emptyList()) ) - } fun mockOrchestratorReserveApi() { - // Orchestrator reserve orchestratorMockApi.stubFor( post(urlPathEqualTo(ORCHESTRATOR_RESERVE_TASKS_URL))