diff --git a/CHANGELOG.md b/CHANGELOG.md index fb9ae3115..bf040a8e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ For changes to the BPDM Helm charts please consult the [changelog](charts/bpdm/C - BPDM Gate: Fixed logic for identifiers to retrieve only generic type on output business partner - BPDM Gate: Fixed construction logic for states and identifiers by enabling business partner type - BPDM Pool: When processing golden record tasks the Pool now ignores isCatenaXMemberData field if it is set to null. ([#1069](https://github.com/eclipse-tractusx/bpdm/issues/1069)) +- BPDM Gate: Fixed gate output logic to provide only generic states for uncategorized states. ## [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 4964aa45f..75c2b8ef5 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 @@ -65,7 +65,15 @@ class BusinessPartnerMappings { } } .map(::toIdentifierDto) }?: emptyList(), - states = entity.states.map(::toStateDto), + states = entity.postalAddress.addressType?.let { addressType -> + entity.states + .filter { it.businessPartnerTyp == when (addressType) { + AddressType.LegalAndSiteMainAddress, AddressType.LegalAddress -> BusinessPartnerType.LEGAL_ENTITY + AddressType.AdditionalAddress -> BusinessPartnerType.ADDRESS + AddressType.SiteMainAddress -> return@let emptyList() // No identifiers for SiteMainAddress + } } + .map(::toStateDto) + }?: emptyList(), roles = entity.roles, isOwnCompanyData = entity.isOwnCompanyData, legalEntity = toLegalEntityComponentOutputDto(entity), 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 a752f63c1..9b5d33551 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 @@ -145,7 +145,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor( // Expect outputBusinessPartner without identifiers as there are not Address identifier provided. val outputBusinessPartners = listOf( - BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList()) + BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList(), states = 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 c0e40a6a7..d4caf81a8 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,9 +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. + // Expect outputBusinessPartner without identifiers and states as there are no Address identifier and states provided. val outputBusinessPartners = listOf( - BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList()) + BusinessPartnerVerboseValues.bpOutputDtoCleaned.copy(identifiers = emptyList(), states = emptyList()) ) val upsertRequests = listOf(