diff --git a/CHANGELOG.md b/CHANGELOG.md index b285f542c..feee886e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,7 +31,8 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C - BPDM Cleaning Service Dummy: Added a null check for name parts to ensure proper whitespace handling when constructing the legal name from them. - BPDM Gate: Enabled Tax Jurisdiction code to save it to the Output. - BPDM Cleaning Service Dummy: Removed assignment of uncategorized states while performing cleaning legal entity process. -- BPDM Gate: Fixed construction logic for states and identifiers by enabling business partner type +- BPDM Gate: Fixed construction logic for states and identifiers by enabling business partner type +- BPDM Gate: Fixed logic for identifiers to retrieve only generic type on output business partner ## [6.1.0] - [2024-07-15] diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt index 81cf621e3..4964aa45f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.service +import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNullMappingException @@ -55,7 +56,15 @@ class BusinessPartnerMappings { return BusinessPartnerOutputDto( externalId = entity.sharingState.externalId, nameParts = entity.nameParts, - identifiers = entity.identifiers.map(::toIdentifierDto), + identifiers = entity.postalAddress.addressType?.let { addressType -> + entity.identifiers + .filter { it.businessPartnerType == when (addressType) { + AddressType.LegalAndSiteMainAddress, AddressType.LegalAddress -> BusinessPartnerType.LEGAL_ENTITY + AddressType.AdditionalAddress -> BusinessPartnerType.ADDRESS + AddressType.SiteMainAddress -> return@let emptyList() // No identifiers for SiteMainAddress + } } + .map(::toIdentifierDto) + }?: emptyList(), states = entity.states.map(::toStateDto), roles = entity.roles, isOwnCompanyData = entity.isOwnCompanyData, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt index 1e3cc84c7..a752f63c1 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt @@ -143,8 +143,9 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor( fun `insert one business partners and finalize cleaning task without error`() { this.mockAndAssertUtils.mockOrchestratorApiCleaned(gateWireMockServer) + // Expect outputBusinessPartner without identifiers as there are not Address identifier provided. val outputBusinessPartners = listOf( - BusinessPartnerVerboseValues.bpOutputDtoCleaned + BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList()) ) val upsertRequests = listOf( diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt index 4f800bae1..c0e40a6a7 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt @@ -280,8 +280,9 @@ class BusinessPartnerControllerIT @Autowired constructor( fun `insert one business partners and finalize cleaning task without error`() { this.mockAndAssertUtils.mockOrchestratorApiCleaned(gateWireMockServer) + // Expect outputBusinessPartner without identifiers as there are not Address identifier provided. val outputBusinessPartners = listOf( - BusinessPartnerVerboseValues.bpOutputDtoCleaned + BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList()) ) val upsertRequests = listOf(