diff --git a/CHANGELOG.md b/CHANGELOG.md index 54ea82eea..3b8ec0fe8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C - BPDM Gate: GET endpoint to download the csv file template for business partner upload. (#700) - Apps: Tax Jurisdiction Code to the physical address of a business partner (#955) - BPDM Orchestrator: Tasks will now be persisted +- BPDM Orchestrator: Tasks now come with a gate record identifier. This makes it possible for cleaning services to match tasks for the same Gate record ### Changed: 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 0a9c904cc..a0547564b 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 @@ -42,6 +42,7 @@ import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.DynamicPropertyRegistry import org.springframework.test.context.DynamicPropertySource import java.time.Instant +import java.util.* @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -373,7 +374,7 @@ class CleaningServiceApiCallsTest @Autowired constructor( // Helper method to create a sample TaskStepReservationResponse private fun createSampleTaskStepReservationResponse(businessPartner: BusinessPartner): TaskStepReservationResponse { - return TaskStepReservationResponse(listOf(TaskStepReservationEntryDto(fixedTaskId, businessPartner)), Instant.MIN) + return TaskStepReservationResponse(listOf(TaskStepReservationEntryDto(fixedTaskId, UUID.randomUUID().toString(), businessPartner)), Instant.MIN) } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingStateDb.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingStateDb.kt index a8d7a96a3..568166ce2 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingStateDb.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/entity/SharingStateDb.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.model.BaseEntity import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import java.time.LocalDateTime +import java.util.* @Entity @@ -36,6 +37,9 @@ class SharingStateDb( @Column(name = "tenant_bpnl", nullable = true) var tenantBpnl: String? = null, + @Column(name = "orchestrator_record_id", nullable = true, unique = true) + var orchestratorRecordId: UUID?, + @Enumerated(EnumType.STRING) @Column(name = "sharing_state_type", nullable = false) var sharingStateType: SharingStateType, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt index 377472d7f..d30da1851 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/OrchestratorMappings.kt @@ -43,6 +43,13 @@ class OrchestratorMappings( ) { private val logger = KotlinLogging.logger { } + fun toCreateRequest(entity: BusinessPartnerDb): TaskCreateRequestEntry{ + return TaskCreateRequestEntry( + recordId = entity.sharingState.orchestratorRecordId?.toString(), + businessPartner = toOrchestratorDto(entity) + ) + } + fun toOrchestratorDto(entity: BusinessPartnerDb): BusinessPartner { val postalAddress = toPostalAddress(entity) diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt index 1b34b7cf4..468b0f176 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SharingStateService.kt @@ -167,6 +167,7 @@ class SharingStateService( SharingStateDb( externalId, sharingStateType = SharingStateType.Ready, + orchestratorRecordId = null, sharingErrorCode = null, sharingErrorMessage = null, sharingProcessStarted = null, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TaskCreationService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TaskCreationService.kt index 4efa1cbc0..e2fdd25a1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TaskCreationService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/TaskCreationService.kt @@ -26,13 +26,14 @@ import org.eclipse.tractusx.bpdm.gate.config.GoldenRecordTaskConfigProperties import org.eclipse.tractusx.bpdm.gate.repository.SharingStateRepository import org.eclipse.tractusx.bpdm.gate.repository.generic.BusinessPartnerRepository import org.eclipse.tractusx.orchestrator.api.client.OrchestrationApiClient -import org.eclipse.tractusx.orchestrator.api.model.BusinessPartner import org.eclipse.tractusx.orchestrator.api.model.TaskClientStateDto import org.eclipse.tractusx.orchestrator.api.model.TaskCreateRequest +import org.eclipse.tractusx.orchestrator.api.model.TaskCreateRequestEntry import org.eclipse.tractusx.orchestrator.api.model.TaskMode import org.springframework.data.domain.Pageable import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional +import java.util.* @Service class TaskCreationService( @@ -55,17 +56,18 @@ class TaskCreationService( logger.debug { "Found ${foundStates.size} business partners in ready state" } val foundPartners = businessPartnerRepository.findBySharingStateInAndStage(foundStates, StageType.Input) - val orchestratorBusinessPartnersDto = foundPartners.map { orchestratorMappings.toOrchestratorDto(it) } + val orchestratorBusinessPartnersDto = foundPartners.map { orchestratorMappings.toCreateRequest(it) } val createdTasks = createGoldenRecordTasks(TaskMode.UpdateFromSharingMember, orchestratorBusinessPartnersDto) foundPartners.zip(createdTasks).forEach { (partner, task) -> + if(partner.sharingState.orchestratorRecordId == null) partner.sharingState.orchestratorRecordId = UUID.fromString(task.recordId) sharingStateService.setPending(partner.sharingState, task.taskId) } logger.info { "Created ${createdTasks.size} new golden record tasks from ready business partners" } } - private fun createGoldenRecordTasks(mode: TaskMode, orchestratorBusinessPartnersDto: List): List { + private fun createGoldenRecordTasks(mode: TaskMode, orchestratorBusinessPartnersDto: List): List { if (orchestratorBusinessPartnersDto.isEmpty()) return emptyList() diff --git a/bpdm-gate/src/main/resources/db/migration/V6_1_0_4__add_orchestrator_record_id.sql b/bpdm-gate/src/main/resources/db/migration/V6_1_0_4__add_orchestrator_record_id.sql new file mode 100644 index 000000000..7d59cc8fc --- /dev/null +++ b/bpdm-gate/src/main/resources/db/migration/V6_1_0_4__add_orchestrator_record_id.sql @@ -0,0 +1,2 @@ +ALTER TABLE sharing_states +ADD COLUMN orchestrator_record_id UUID unique; \ No newline at end of file diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt index 4c04d322a..787a45083 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/entity/generic/BusinessPartnerIT.kt @@ -161,6 +161,7 @@ internal class BusinessPartnerIT @Autowired constructor( return SharingStateDb( externalId = "testExternalId", sharingErrorCode = null, + orchestratorRecordId = null, sharingStateType = SharingStateType.Initial ) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt index 09b391789..95e377454 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt @@ -64,6 +64,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "0", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "e3a05ebc-ff59-4d09-bd58-da31d6245701", processingState = TaskProcessingStateDto( resultState = ResultState.Pending, step = TaskStep.CleanAndSync, @@ -77,6 +78,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "1", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "f05574ff-4ddd-4360-821a-923203711f85", processingState = TaskProcessingStateDto( resultState = ResultState.Pending, step = TaskStep.CleanAndSync, @@ -90,6 +92,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "2", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "8c03850d-d772-4a2e-9845-65211231b38c", processingState = TaskProcessingStateDto( resultState = ResultState.Pending, step = TaskStep.CleanAndSync, @@ -103,6 +106,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "3", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "6bebb1aa-935d-467a-afd4-7e8623420a18", processingState = TaskProcessingStateDto( resultState = ResultState.Pending, step = TaskStep.CleanAndSync, @@ -132,6 +136,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "0", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "e3a05ebc-ff59-4d09-bd58-da31d6245701", processingState = TaskProcessingStateDto( resultState = ResultState.Success, step = TaskStep.CleanAndSync, @@ -145,6 +150,7 @@ class MockAndAssertUtils @Autowired constructor( TaskClientStateDto( taskId = "1", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "f05574ff-4ddd-4360-821a-923203711f85", processingState = TaskProcessingStateDto( resultState = ResultState.Error, step = TaskStep.CleanAndSync, @@ -172,7 +178,10 @@ class MockAndAssertUtils @Autowired constructor( val taskStateResponse = TaskStateResponse( listOf( TaskClientStateDto( - taskId = "0", businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, processingState = TaskProcessingStateDto( + taskId = "0", + businessPartnerResult = BusinessPartnerGenericCommonValues.businessPartner1, + recordId = "e3a05ebc-ff59-4d09-bd58-da31d6245701", + processingState = TaskProcessingStateDto( resultState = ResultState.Success, step = TaskStep.CleanAndSync, stepState = StepState.Queued, diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskClientStateDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskClientStateDto.kt index 99365a0b6..a33ba5230 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskClientStateDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskClientStateDto.kt @@ -28,6 +28,9 @@ data class TaskClientStateDto( @get:Schema(required = true) val taskId: String, + @get:Schema(required = true, description = "The identifier of the gate record for which this task has been created") + val recordId: String, + val businessPartnerResult: BusinessPartner, @get:Schema(required = true) diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequest.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequest.kt index f4e7280e2..18570cc3c 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequest.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequest.kt @@ -28,6 +28,6 @@ data class TaskCreateRequest( @get:Schema(required = true, description = "The mode affecting which processing steps the business partner goes through") val mode: TaskMode, - @get:ArraySchema(arraySchema = Schema(description = "The list of business partner data to be processed")) - val businessPartners: List + @get:ArraySchema(arraySchema = Schema(description = "The list of tasks to create")) + val requests: List ) diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequestEntry.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequestEntry.kt new file mode 100644 index 000000000..79c08f33b --- /dev/null +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskCreateRequestEntry.kt @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.orchestrator.api.model + +import io.swagger.v3.oas.annotations.media.Schema + +data class TaskCreateRequestEntry( + @get:Schema(description = "The unique identifier for this record which was previously issued by the Orchestrator") + val recordId: String?, + @get:Schema(description = "The business partner data to be processed") + val businessPartner: BusinessPartner +) diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskStepReservationEntryDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskStepReservationEntryDto.kt index a67baf2e8..491d4ad5e 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskStepReservationEntryDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/TaskStepReservationEntryDto.kt @@ -28,6 +28,9 @@ data class TaskStepReservationEntryDto( @get:Schema(description = "The identifier of the reserved task") val taskId: String, + @get:Schema(description = "The identifier of the gate record for which this task has been created") + val recordId: String, + @get:Schema(description = "The business partner data to process") val businessPartner: BusinessPartner ) : RequestWithKey { diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskController.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskController.kt index 2d5ccef0d..c884b1b68 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskController.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskController.kt @@ -38,8 +38,8 @@ class GoldenRecordTaskController( @PreAuthorize("hasAuthority(${PermissionConfigProperties.CREATE_TASK})") override fun createTasks(createRequest: TaskCreateRequest): TaskCreateResponse { - if (createRequest.businessPartners.size > apiConfigProperties.upsertLimit) - throw BpdmUpsertLimitException(createRequest.businessPartners.size, apiConfigProperties.upsertLimit) + if (createRequest.requests.size > apiConfigProperties.upsertLimit) + throw BpdmUpsertLimitException(createRequest.requests.size, apiConfigProperties.upsertLimit) return goldenRecordTaskService.createTasks(createRequest) } diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/DbTimestampConverter.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/DbTimestampConverter.kt index 2aa695d1f..1abcd90e1 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/DbTimestampConverter.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/DbTimestampConverter.kt @@ -30,7 +30,6 @@ class DbTimestampConverter: AttributeConverter { } override fun convertToEntityAttribute(p0: Timestamp?): DbTimestamp? { - return p0?.let { DbTimestamp(p0.toInstant()) } + return p0?.let { DbTimestamp(p0.toInstant()) } } - } \ No newline at end of file diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GateRecordDb.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GateRecordDb.kt new file mode 100644 index 000000000..ad44ee667 --- /dev/null +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GateRecordDb.kt @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.orchestrator.entity + +import jakarta.persistence.* +import org.hibernate.annotations.CreationTimestamp +import org.hibernate.annotations.UpdateTimestamp +import java.time.Instant +import java.util.* + +@Entity +@Table( + name = "gate_records", + indexes = [ + Index(name = "index_gate_records_private_uuid", columnList = "private_uuid") + ] +) +class GateRecordDb ( + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bpdm_sequence") + @SequenceGenerator(name = "bpdm_sequence", sequenceName = "bpdm_sequence", allocationSize = 1) + @Column(name = "id", nullable = false, updatable = false, insertable = false) + val id: Long = 0, + + @Column(updatable = false, nullable = false, name = "CREATED_AT") + @CreationTimestamp + var createdAt: Instant = Instant.now(), + + @Column(nullable = false, name = "UPDATED_AT") + @UpdateTimestamp + var updatedAt: Instant = Instant.now(), + + @Column(name = "public_id", columnDefinition = "UUID", nullable = false, unique = true) + var publicId: UUID, + + @Column(name = "private_id", columnDefinition = "UUID", nullable = false, unique = true) + var privateId: UUID +) \ No newline at end of file diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GoldenRecordTaskDb.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GoldenRecordTaskDb.kt index 48ddc2bc5..a22b25be7 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GoldenRecordTaskDb.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/entity/GoldenRecordTaskDb.kt @@ -52,6 +52,10 @@ class GoldenRecordTaskDb( @Column(nullable = false, name = "UPDATED_AT") @Convert(converter = DbTimestampConverter::class) var updatedAt: DbTimestamp = createdAt, + @ManyToOne + @JoinColumn(name = "gate_record_id", nullable = false, foreignKey = ForeignKey(name = "fk_tasks_gate_records")) + var gateRecord: GateRecordDb, + @Embedded val processingState: ProcessingState, @Embedded diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/exception/BpdmRecordNotFoundException.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/exception/BpdmRecordNotFoundException.kt new file mode 100644 index 000000000..bd08f1344 --- /dev/null +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/exception/BpdmRecordNotFoundException.kt @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + +package org.eclipse.tractusx.bpdm.orchestrator.exception + +import org.springframework.http.HttpStatus +import org.springframework.web.bind.annotation.ResponseStatus +import java.util.* + +@ResponseStatus(HttpStatus.BAD_REQUEST) +class BpdmRecordNotFoundException ( + recordIds: List +): RuntimeException("The following gate records are not registered: ${recordIds.joinToString()}") \ No newline at end of file diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/repository/GateRecordRepository.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/repository/GateRecordRepository.kt new file mode 100644 index 000000000..e88544f5b --- /dev/null +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/repository/GateRecordRepository.kt @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2021,2024 Contributors to the Eclipse Foundation + * + * See the NOTICE file(s) distributed with this work for additional + * information regarding copyright ownership. + * + * This program and the accompanying materials are made available under the + * terms of the Apache License, Version 2.0 which is available at + * https://www.apache.org/licenses/LICENSE-2.0. + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + * SPDX-License-Identifier: Apache-2.0 + ******************************************************************************/ + + +package org.eclipse.tractusx.bpdm.orchestrator.repository + +import org.eclipse.tractusx.bpdm.orchestrator.entity.GateRecordDb +import org.springframework.data.repository.CrudRepository +import java.util.* + +interface GateRecordRepository: CrudRepository { + + fun findByPrivateIdIn(privateUuids: Set): Set +} \ No newline at end of file diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskService.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskService.kt index d5f0e67a2..f55ee8782 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskService.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskService.kt @@ -21,9 +21,12 @@ package org.eclipse.tractusx.bpdm.orchestrator.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.orchestrator.config.TaskConfigProperties +import org.eclipse.tractusx.bpdm.orchestrator.entity.GateRecordDb import org.eclipse.tractusx.bpdm.orchestrator.entity.DbTimestamp import org.eclipse.tractusx.bpdm.orchestrator.entity.GoldenRecordTaskDb +import org.eclipse.tractusx.bpdm.orchestrator.exception.BpdmRecordNotFoundException import org.eclipse.tractusx.bpdm.orchestrator.exception.BpdmTaskNotFoundException +import org.eclipse.tractusx.bpdm.orchestrator.repository.GateRecordRepository import org.eclipse.tractusx.bpdm.orchestrator.repository.GoldenRecordTaskRepository import org.eclipse.tractusx.orchestrator.api.model.* import org.springframework.data.domain.Pageable @@ -38,7 +41,8 @@ class GoldenRecordTaskService( private val goldenRecordTaskStateMachine: GoldenRecordTaskStateMachine, private val taskConfigProperties: TaskConfigProperties, private val responseMapper: ResponseMapper, - private val taskRepository: GoldenRecordTaskRepository + private val taskRepository: GoldenRecordTaskRepository, + private val gateRecordRepository: GateRecordRepository ) { private val logger = KotlinLogging.logger { } @@ -47,8 +51,10 @@ class GoldenRecordTaskService( fun createTasks(createRequest: TaskCreateRequest): TaskCreateResponse { logger.debug { "Creation of new golden record tasks: executing createTasks() with parameters $createRequest" } - return createRequest.businessPartners - .map { businessPartnerData -> goldenRecordTaskStateMachine.initTask(createRequest.mode, businessPartnerData) } + val gateRecords = getOrCreateGateRecords(createRequest.requests) + + return createRequest.requests.zip(gateRecords) + .map { (request, record) -> goldenRecordTaskStateMachine.initTask(createRequest.mode, request.businessPartner, record) } .map { task -> responseMapper.toClientState(task, calculateTaskRetentionTimeout(task)) } .let { TaskCreateResponse(createdTasks = it) } } @@ -72,7 +78,7 @@ class GoldenRecordTaskService( val pendingTimeout = reservedTasks.minOfOrNull { calculateTaskPendingTimeout(it) } ?: now return reservedTasks - .map { task -> TaskStepReservationEntryDto(task.uuid.toString(), responseMapper.toBusinessPartnerResult(task.businessPartner)) } + .map { task -> TaskStepReservationEntryDto(task.uuid.toString(), task.gateRecord.publicId.toString(), responseMapper.toBusinessPartnerResult(task.businessPartner)) } .let { reservations -> TaskStepReservationResponse(reservations, pendingTimeout) } } @@ -147,4 +153,21 @@ class GoldenRecordTaskService( } catch (e: IllegalArgumentException) { throw BpdmTaskNotFoundException(uuidString) } + + private fun getOrCreateGateRecords(requests: List): List{ + val privateIds = requests.map { request -> request.recordId?.let { toUUID(it) }} + val notNullPrivateIds = privateIds.filterNotNull() + + val foundRecords = gateRecordRepository.findByPrivateIdIn(notNullPrivateIds.toSet()) + val foundRecordsByPrivateId = foundRecords.associateBy { it.privateId } + val requestedNotFoundRecords = notNullPrivateIds.minus(foundRecordsByPrivateId.keys) + + if(requestedNotFoundRecords.isNotEmpty()) + throw BpdmRecordNotFoundException(requestedNotFoundRecords) + + return privateIds.map { privateId -> + val gateRecord = privateId?.let { foundRecordsByPrivateId[it] } ?: GateRecordDb(publicId = UUID.randomUUID(), privateId = UUID.randomUUID()) + gateRecordRepository.save(gateRecord) + } + } } diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachine.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachine.kt index d9a3d28dc..327a6fe09 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachine.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachine.kt @@ -22,10 +22,7 @@ package org.eclipse.tractusx.bpdm.orchestrator.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.util.replace import org.eclipse.tractusx.bpdm.orchestrator.config.TaskConfigProperties -import org.eclipse.tractusx.bpdm.orchestrator.entity.DbTimestamp -import org.eclipse.tractusx.bpdm.orchestrator.entity.GoldenRecordTaskDb -import org.eclipse.tractusx.bpdm.orchestrator.entity.TaskErrorDb -import org.eclipse.tractusx.bpdm.orchestrator.entity.toTimestamp +import org.eclipse.tractusx.bpdm.orchestrator.entity.* import org.eclipse.tractusx.bpdm.orchestrator.exception.BpdmIllegalStateException import org.eclipse.tractusx.bpdm.orchestrator.repository.GoldenRecordTaskRepository import org.eclipse.tractusx.orchestrator.api.model.* @@ -41,7 +38,7 @@ class GoldenRecordTaskStateMachine( private val logger = KotlinLogging.logger { } - fun initTask(mode: TaskMode, initBusinessPartner: BusinessPartner): GoldenRecordTaskDb { + fun initTask(mode: TaskMode, initBusinessPartner: BusinessPartner, record: GateRecordDb): GoldenRecordTaskDb { logger.debug { "Executing initProcessingState() with parameters mode: $mode and business partner data: $initBusinessPartner" } val initialStep = getInitialStep(mode) @@ -56,6 +53,7 @@ class GoldenRecordTaskStateMachine( ) val initialTask = GoldenRecordTaskDb( + gateRecord = record, processingState = initProcessingState, businessPartner = requestMapper.toBusinessPartner(initBusinessPartner) ) diff --git a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/ResponseMapper.kt b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/ResponseMapper.kt index cd5f5c513..192751046 100644 --- a/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/ResponseMapper.kt +++ b/bpdm-orchestrator/src/main/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/ResponseMapper.kt @@ -32,6 +32,7 @@ class ResponseMapper { with(task) { TaskClientStateDto( taskId = task.uuid.toString(), + recordId = task.gateRecord.privateId.toString(), businessPartnerResult = toBusinessPartnerResult(businessPartner), processingState = toProcessingState(task, timeout) ) diff --git a/bpdm-orchestrator/src/main/resources/db/migration/V6_1_0_0__create_tables.sql b/bpdm-orchestrator/src/main/resources/db/migration/V6_1_0_0__create_tables.sql index b107b17d5..0538b9b96 100644 --- a/bpdm-orchestrator/src/main/resources/db/migration/V6_1_0_0__create_tables.sql +++ b/bpdm-orchestrator/src/main/resources/db/migration/V6_1_0_0__create_tables.sql @@ -146,6 +146,7 @@ create table business_partner_states ( ); create table golden_record_tasks ( + gate_record_id bigint not null, is_cx_member boolean, legal_entity_has_changed boolean, site_exists boolean not null, @@ -180,6 +181,16 @@ create table task_errors ( type varchar(255) not null check (type in ('Timeout', 'Unspecified')) ); +create table gate_records ( + id bigint not null, + created_at TIMESTAMP not null, + updated_at TIMESTAMP not null, + private_id uuid not null unique, + public_id uuid not null unique, + primary key(id) +); + + create index index_tasks_uuid on golden_record_tasks (uuid); create index index_tasks_step_step_state on golden_record_tasks (task_step, task_step_state); @@ -188,6 +199,11 @@ create index index_tasks_pending_timeout on golden_record_tasks (task_pending_ti create index index_tasks_retention_timeout on golden_record_tasks (task_retention_timeout); +alter table + if exists golden_record_tasks +add + constraint fk_tasks_gate_records foreign key (gate_record_id) references gate_records; + alter table if exists business_partner_addresses add diff --git a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskControllerIT.kt b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskControllerIT.kt index 4882a6343..fbbcba011 100644 --- a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskControllerIT.kt +++ b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/controller/GoldenRecordTaskControllerIT.kt @@ -37,6 +37,7 @@ import org.springframework.test.context.ContextConfiguration import org.springframework.web.reactive.function.client.WebClientResponseException import java.time.Instant import java.time.temporal.ChronoUnit +import java.util.* val WITHIN_ALLOWED_TIME_OFFSET: TemporalUnitOffset = within(1, ChronoUnit.SECONDS) @@ -76,7 +77,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `request cleaning task`() { // create tasks and check response - val createdTasks = createTasks().createdTasks + val createdTasks = createTasksWithoutRecordId().createdTasks assertThat(createdTasks.size).isEqualTo(2) @@ -101,7 +102,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `request cleaning task in alternative mode`() { // create tasks and check response - val createdTasks = createTasks(TaskMode.UpdateFromPool).createdTasks + val createdTasks = createTasksWithoutRecordId(TaskMode.UpdateFromPool).createdTasks assertThat(createdTasks.size).isEqualTo(2) val processingState = createdTasks[0].processingState @@ -122,7 +123,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `request reservation`() { // create tasks - val createdTasks = createTasks(TaskMode.UpdateFromSharingMember).createdTasks + val createdTasks = createTasksWithoutRecordId(TaskMode.UpdateFromSharingMember).createdTasks assertThat(createdTasks.size).isEqualTo(2) // reserve tasks @@ -162,7 +163,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `request reservation for wrong step`() { // create tasks - createTasks(TaskMode.UpdateFromPool) + createTasksWithoutRecordId(TaskMode.UpdateFromPool) // try reservation for wrong step val reservedTasks = reserveTasks(TaskStep.CleanAndSync).reservedTasks @@ -183,7 +184,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `post cleaning results for all steps`() { // create tasks - createTasks() + createTasksWithoutRecordId() // reserve task for step==CleanAndSync val reservedTasks1 = reserveTasks(TaskStep.CleanAndSync, 1).reservedTasks @@ -252,7 +253,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `post cleaning result with error`() { // create tasks - createTasks() + createTasksWithoutRecordId() // reserve task for step==CleanAndSync val taskId = reserveTasks(TaskStep.CleanAndSync, 1).reservedTasks.single().taskId @@ -292,7 +293,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( ) assertBadRequestException { - createTasks(businessPartners = businessPartners) + createTasksWithoutRecordId(businessPartners = businessPartners) } } @@ -345,7 +346,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `expect exceptions on posting inconsistent task results`() { // create tasks - createTasks() + createTasksWithoutRecordId() // reserve tasks val tasksIds = reserveTasks(TaskStep.CleanAndSync).reservedTasks.map { it.taskId } @@ -419,7 +420,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `wait for task pending and retention timeout`() { // create tasks - val createdTasks = createTasks().createdTasks + val createdTasks = createTasksWithoutRecordId().createdTasks val taskIds = createdTasks.map { it.taskId } // check for state Pending @@ -455,7 +456,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `wait for task retention timeout after success`() { // create single task in UpdateFromPool mode (only one step) - createTasks(TaskMode.UpdateFromPool, listOf(defaultBusinessPartner1)) + createTasksWithoutRecordId(TaskMode.UpdateFromPool, listOf(defaultBusinessPartner1)) // reserve task val reservedTask = reserveTasks(TaskStep.Clean).reservedTasks.single() @@ -488,7 +489,7 @@ class GoldenRecordTaskControllerIT @Autowired constructor( @Test fun `wait for task retention timeout after error`() { // create single task in UpdateFromPool mode (only one step) - createTasks(TaskMode.UpdateFromPool, listOf(defaultBusinessPartner1)) + createTasksWithoutRecordId(TaskMode.UpdateFromPool, listOf(defaultBusinessPartner1)) // reserve task val reservedTask = reserveTasks(TaskStep.Clean).reservedTasks.single() @@ -519,13 +520,42 @@ class GoldenRecordTaskControllerIT @Autowired constructor( assertThat(foundTasks.size).isZero() } - private fun createTasks(mode: TaskMode = TaskMode.UpdateFromSharingMember, businessPartners: List? = null): TaskCreateResponse = - orchestratorClient.goldenRecordTasks.createTasks( - TaskCreateRequest( - mode = mode, - businessPartners = businessPartners ?: listOf(defaultBusinessPartner1, defaultBusinessPartner2) - ) - ) + @Test + fun `create task for existing gate record`(){ + //Create records by creating tasks first + val existingRecordIds = createTasksWithoutRecordId().createdTasks.map { it.recordId } + + val requestsWithRecords = listOf(defaultBusinessPartner1, defaultBusinessPartner2) + .zip(existingRecordIds) + .map { (bp, recordId) -> TaskCreateRequestEntry(recordId, bp) } + + requestsWithRecords.forEach { assertThat(it.recordId).isNotNull() } + + val tasksWithRecords = orchestratorClient.goldenRecordTasks.createTasks(TaskCreateRequest(TaskMode.UpdateFromSharingMember, requestsWithRecords)).createdTasks + + tasksWithRecords.zip(existingRecordIds).forEach { (actualTask, expectedRecordId) -> assertThat(actualTask.recordId).isEqualTo(expectedRecordId) } + } + + @Test + fun `expect exception on creating task for non-existing gate record`(){ + val unknownRecordId = UUID.randomUUID() + + val requestWithUnknownRecord = TaskCreateRequestEntry(unknownRecordId.toString(), defaultBusinessPartner1) + + assertBadRequestException{ + createTasks(entries = listOf(requestWithUnknownRecord)) + } + } + + private fun createTasks(mode: TaskMode = TaskMode.UpdateFromSharingMember, + entries: List? = null + ): TaskCreateResponse{ + val resolvedEntries = entries ?: listOf(defaultBusinessPartner1, defaultBusinessPartner2).map { bp -> TaskCreateRequestEntry(null, bp) } + return orchestratorClient.goldenRecordTasks.createTasks(TaskCreateRequest(mode = mode, requests = resolvedEntries)) + } + + private fun createTasksWithoutRecordId(mode: TaskMode = TaskMode.UpdateFromSharingMember, businessPartners: List? = null): TaskCreateResponse = + createTasks(mode, (businessPartners ?: listOf(defaultBusinessPartner1, defaultBusinessPartner2)).map{ bp -> TaskCreateRequestEntry(null, bp) }) private fun reserveTasks(step: TaskStep, amount: Int = 3) = orchestratorClient.goldenRecordTasks.reserveTasksForStep( diff --git a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachineIT.kt b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachineIT.kt index 0824f0854..cf1c685c3 100644 --- a/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachineIT.kt +++ b/bpdm-orchestrator/src/test/kotlin/org/eclipse/tractusx/bpdm/orchestrator/service/GoldenRecordTaskStateMachineIT.kt @@ -24,8 +24,10 @@ import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThatThrownBy import org.assertj.core.data.TemporalUnitOffset import org.eclipse.tractusx.bpdm.orchestrator.config.TaskConfigProperties +import org.eclipse.tractusx.bpdm.orchestrator.entity.GateRecordDb import org.eclipse.tractusx.bpdm.orchestrator.entity.GoldenRecordTaskDb import org.eclipse.tractusx.bpdm.orchestrator.exception.BpdmIllegalStateException +import org.eclipse.tractusx.bpdm.orchestrator.repository.GateRecordRepository import org.eclipse.tractusx.bpdm.test.containers.PostgreSQLContextInitializer import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.BusinessPartnerTestDataFactory import org.eclipse.tractusx.bpdm.test.util.DbTestHelpers @@ -38,9 +40,9 @@ import org.springframework.test.context.ContextConfiguration import org.springframework.transaction.annotation.Transactional import java.time.Instant import java.time.temporal.ChronoUnit +import java.util.* val WITHIN_ALLOWED_TIME_OFFSET: TemporalUnitOffset = Assertions.within(10, ChronoUnit.SECONDS) -val TASK_ID = "TASK-ID" @SpringBootTest( webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, @@ -54,6 +56,7 @@ val TASK_ID = "TASK-ID" class GoldenRecordTaskStateMachineIT @Autowired constructor( private val goldenRecordTaskStateMachine: GoldenRecordTaskStateMachine, private val taskConfigProperties: TaskConfigProperties, + private val gateRecordRepository: GateRecordRepository, private val dbTestHelpers: DbTestHelpers ) { @@ -61,9 +64,12 @@ class GoldenRecordTaskStateMachineIT @Autowired constructor( private val businessPartnerFull = testDataFactory.createFullBusinessPartner("full") + private lateinit var gateRecord: GateRecordDb + @BeforeEach fun cleanUp() { dbTestHelpers.truncateDbTables() + gateRecord = gateRecordRepository.save(GateRecordDb(publicId = UUID.randomUUID(), privateId = UUID.randomUUID())) } @@ -75,7 +81,7 @@ class GoldenRecordTaskStateMachineIT @Autowired constructor( @Transactional fun `initial state`() { val now = Instant.now() - val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromSharingMember, businessPartnerFull) + val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromSharingMember, businessPartnerFull, gateRecord) val state = task.processingState assertProcessingState(state, ResultState.Pending, TaskStep.CleanAndSync, StepState.Queued) @@ -98,7 +104,7 @@ class GoldenRecordTaskStateMachineIT @Autowired constructor( @Transactional fun `walk through all UpdateFromSharingMember steps`() { // new task - val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromSharingMember, businessPartnerFull) + val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromSharingMember, businessPartnerFull, gateRecord) assertProcessingState(task.processingState, ResultState.Pending, TaskStep.CleanAndSync, StepState.Queued) // taskPendingTimeout has been set val taskPendingTimeout = task.processingState.pendingTimeout @@ -165,7 +171,7 @@ class GoldenRecordTaskStateMachineIT @Autowired constructor( @Transactional fun `walk through all UpdateFromPool steps`() { // new task - val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromPool, businessPartnerFull) + val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromPool, businessPartnerFull, gateRecord) assertProcessingState(task.processingState, ResultState.Pending, TaskStep.Clean, StepState.Queued) val modified0 = task.updatedAt.instant // taskPendingTimeout has been set @@ -205,7 +211,7 @@ class GoldenRecordTaskStateMachineIT @Autowired constructor( @Transactional fun `walk through steps and resolve with error`() { // new task - val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromPool, businessPartnerFull) + val task = goldenRecordTaskStateMachine.initTask(TaskMode.UpdateFromPool, businessPartnerFull, gateRecord) assertProcessingState(task.processingState, ResultState.Pending, TaskStep.Clean, StepState.Queued) // taskPendingTimeout has been set assertThat(task.processingState.pendingTimeout?.instant).isCloseTo(Instant.now().plus(taskConfigProperties.taskPendingTimeout), WITHIN_ALLOWED_TIME_OFFSET) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt index 8c3e17078..74ed35924 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt @@ -21,13 +21,16 @@ package org.eclipse.tractusx.bpdm.pool.service import com.neovisionaries.i18n.CountryCode import org.assertj.core.api.Assertions.assertThat -import org.eclipse.tractusx.bpdm.common.dto.* +import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.pool.Application import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient import org.eclipse.tractusx.bpdm.pool.repository.BpnRequestIdentifierRepository import org.eclipse.tractusx.bpdm.pool.service.TaskStepBuildService.CleaningError import org.eclipse.tractusx.bpdm.test.containers.PostgreSQLContextInitializer -import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.* +import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.BusinessPartnerTestDataFactory +import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.copyWithBpnRequests +import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.copyWithLegalEntityIdentifiers +import org.eclipse.tractusx.bpdm.test.testdata.orchestrator.copyWithSiteMainAddress import org.eclipse.tractusx.bpdm.test.testdata.pool.PoolDataHelper import org.eclipse.tractusx.bpdm.test.testdata.pool.TestDataEnvironment import org.eclipse.tractusx.bpdm.test.util.DbTestHelpers @@ -42,6 +45,7 @@ import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration import java.time.Instant import java.time.temporal.ChronoUnit +import java.util.* @SpringBootTest( @@ -744,6 +748,7 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( return listOf( TaskStepReservationEntryDto( taskId = taskId, + recordId = UUID.randomUUID().toString(), businessPartner = businessPartner ) ) @@ -754,6 +759,7 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( return businessPartners.map { TaskStepReservationEntryDto( taskId = it.legalEntity.bpnReference.referenceValue!!, + recordId = UUID.randomUUID().toString(), businessPartner = it ) }