Skip to content

Commit

Permalink
Merge pull request #1067 from eclipse-tractusx/fix/identifiers-output
Browse files Browse the repository at this point in the history
fix(bpdm-gate): refactored logic for identifiers on output business partners
  • Loading branch information
SujitMBRDI authored Oct 14, 2024
2 parents 7d8b122 + a2499e4 commit f5b6122
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f5b6122

Please sign in to comment.