Skip to content

Commit

Permalink
feat(api): eclipse-tractusx#172 Rename BPN fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rainer-exxcellent committed May 30, 2023
1 parent bc791a8 commit 1460653
Show file tree
Hide file tree
Showing 17 changed files with 126 additions and 122 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpn, true)
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, entity.legalEntity.bpnl, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -57,7 +57,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.legalEntity.bpn
val bpn = entity.legalEntity.bpnl
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.LegalEntity, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand All @@ -76,7 +76,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.Site, externalId, entity.site.bpn, true)
buildSuccessSharingStateDto(LsaType.Site, externalId, entity.site.bpns, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -92,7 +92,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.site.bpn
val bpn = entity.site.bpns
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.Site, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand All @@ -111,7 +111,7 @@ class GateUpdateService(
) {
for (entity in responseWrapper.entities) {
val externalId = entity.index
buildSuccessSharingStateDto(LsaType.Address, externalId, entity.address.bpn, true)
buildSuccessSharingStateDto(LsaType.Address, externalId, entity.address.bpna, true)
?.let { gateClient.sharingState().upsertSharingState(it) }
}
for (errorInfo in responseWrapper.errors) {
Expand All @@ -127,7 +127,7 @@ class GateUpdateService(
externalIdByBpn: Map<String, String>
) {
for (entity in responseWrapper.entities) {
val bpn = entity.bpn
val bpn = entity.bpna
val externalId = externalIdByBpn[bpn]
buildSuccessSharingStateDto(LsaType.Address, externalId, bpn, false)
?.let { gateClient.sharingState().upsertSharingState(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.time.Instant
@Schema(name = "LegalEntityResponse", description = "Legal entity record")
data class LegalEntityResponse(
@get:Schema(description = "Business Partner Number of this legal entity")
val bpn: String,
val bpnl: String,

@ArraySchema(arraySchema = Schema(description = "All identifiers of the business partner, including BPN information"))
val identifiers: Collection<LegalEntityIdentifierResponse> = emptyList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import java.time.Instant
data class LogisticAddressResponse(

@get:Schema(description = "Business Partner Number of this address")
val bpn: String,
val bpna: String,

@get:Schema(
description = "Name of the logistic address of the business partner. This is not according to official\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import java.time.Instant
@Schema(name = "SiteResponse", description = "Site of a legal entity")
data class SiteResponse(
@get:Schema(description = "Business Partner Number, main identifier value for sites")
val bpn: String,
val bpns: String,

@get:Schema(description = "Site name")
val name: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class AddressService(

//Search entries in the pool with BPNs found in the local mirror
val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val addressesByBpnMap = poolClient.searchAddresses(bpnSet).associateBy { it.bpn }
val addressesByBpnMap = poolClient.searchAddresses(bpnSet).associateBy { it.bpna }

if (bpnSet.size > addressesByBpnMap.size) {
logger.warn { "Requested ${bpnSet.size} addresses from pool, but only ${addressesByBpnMap.size} were found." }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class LegalEntityService(

//Search entries in the pool with BPNs found in the local mirror
val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.bpn }
val legalEntitiesByBpnMap = poolClient.searchLegalEntities(bpnSet).associateBy { it.bpnl }
val legalAddressesByBpnMap = poolClient.searchLegalAddresses(bpnSet).associateBy { it.bpnLegalEntity }

if (bpnSet.size > legalEntitiesByBpnMap.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class SiteService(
val partnersWithLocalBpn = outputSaasMappingService.mapWithLocalBpn(partnersWithExternalId, augmentedPartnerResponse.values)

val bpnSet = partnersWithLocalBpn.map { it.bpn }.toSet()
val sitesByBpnMap = poolClient.searchSites(bpnSet).associateBy { it.bpn }
val sitesByBpnMap = poolClient.searchSites(bpnSet).associateBy { it.bpns }
val mainAddressesByBpnMap = poolClient.searchMainAddresses(bpnSet).associateBy { it.bpnSite }

if (bpnSet.size > sitesByBpnMap.size) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ object ResponseValues {
)

val logisticAddress1 = LogisticAddressResponse(
bpn = CommonValues.bpnAddress1,
bpna = CommonValues.bpnAddress1,
physicalPostalAddress = address1,
bpnLegalEntity = CommonValues.bpn1,
bpnSite = "BPNS0000000001XY",
Expand All @@ -212,7 +212,7 @@ object ResponseValues {
)

val logisticAddress2 = LogisticAddressResponse(
bpn = CommonValues.bpnAddress2,
bpna = CommonValues.bpnAddress2,
physicalPostalAddress = address2,
bpnLegalEntity = CommonValues.bpn2,
bpnSite = "BPNS0000000002XY",
Expand All @@ -222,7 +222,7 @@ object ResponseValues {


val legalEntityResponse1 = LegalEntityResponse(
bpn = CommonValues.bpn1,
bpnl = CommonValues.bpn1,
identifiers = listOf(identifier1, identifier2),
legalName = name1,
legalForm = legalForm1,
Expand All @@ -234,7 +234,7 @@ object ResponseValues {
)

val legalEntityResponse2 = LegalEntityResponse(
bpn = CommonValues.bpn2,
bpnl = CommonValues.bpn2,
identifiers = listOf(identifier3, identifier4),
legalName = name3,
legalForm = legalForm2,
Expand Down Expand Up @@ -293,15 +293,15 @@ object ResponseValues {
)

val siteResponse1 = SiteResponse(
bpn = CommonValues.bpnSite1,
bpns = CommonValues.bpnSite1,
name = CommonValues.nameSite1,
states = listOf(),
bpnLegalEntity = CommonValues.bpn1,
createdAt = CommonValues.now,
updatedAt = CommonValues.now
)
val siteResponse2 = SiteResponse(
bpn = CommonValues.bpnSite2,
bpns = CommonValues.bpnSite2,
name = CommonValues.nameSite2,
states = listOf(),
bpnLegalEntity = CommonValues.bpn2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class BusinessPartnerBuildService(
val addressResponses = createAddressesForSite(siteRequests, errors, metadataMap)
.plus(createAddressesForLegalEntity(legalEntityRequests, errors, metadataMap))

changelogService.createChangelogEntries(addressResponses.map { ChangelogEntryDto(it.address.bpn, ChangelogType.CREATE, ChangelogSubject.ADDRESS) })
changelogService.createChangelogEntries(addressResponses.map { ChangelogEntryDto(it.address.bpna, ChangelogType.CREATE, ChangelogSubject.ADDRESS) })

return EntitiesWithErrors(addressResponses, errors)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fun LegalEntity.toUpsertDto(entryId: String?): LegalEntityPartnerCreateResponse

fun LegalEntity.toDto(): LegalEntityResponse {
return LegalEntityResponse(
bpn = bpn,
bpnl = bpn,
identifiers = identifiers.map { it.toDto() },
legalName = legalName.toDto(),
legalForm = legalForm?.toDto(),
Expand Down Expand Up @@ -111,7 +111,7 @@ fun AddressState.toDto(): AddressStateResponse {

fun LogisticAddress.toDto(): LogisticAddressResponse {
return LogisticAddressResponse(
bpn = bpn,
bpna = bpn,
bpnLegalEntity = legalEntity?.bpn,
isLegalAddress = legalEntity?.legalAddress == this,
bpnSite = site?.bpn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class AddressControllerIT @Autowired constructor(
)

val importedPartner = createdStructures.single().legalEntity
val addressesByBpnL = importedPartner.legalEntity.bpn
val addressesByBpnL = importedPartner.legalEntity.bpnl
.let { bpnL -> requestAddressesOfLegalEntity(bpnL).content }
// 1 legal address, 1 regular address
assertThat(addressesByBpnL.size).isEqualTo(2)
Expand All @@ -96,8 +96,8 @@ class AddressControllerIT @Autowired constructor(
// Same address if we use the address-by-BPNA method
addressesByBpnL
.forEach { address ->
val addressByBpnA = requestAddress(address.bpn)
assertThat(addressByBpnA.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpn)
val addressByBpnA = requestAddress(address.bpna)
assertThat(addressByBpnA.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpnl)
assertThat(addressByBpnA).isEqualTo(address)
}
}
Expand Down Expand Up @@ -139,8 +139,8 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnA1 = createdStructures[0].addresses[0].address.bpn
val bpnA2 = createdStructures[0].addresses[1].address.bpn
val bpnA1 = createdStructures[0].addresses[0].address.bpna
val bpnA2 = createdStructures[0].addresses[1].address.bpna

val searchRequest = AddressPartnerBpnSearchRequest(addresses = listOf(bpnA1, bpnA2))
val searchResult =
Expand Down Expand Up @@ -174,7 +174,7 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpn
val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl

val searchRequest = AddressPartnerBpnSearchRequest(legalEntities = listOf(bpnL2))
val searchResult = poolClient.addresses().searchAddresses(searchRequest, PaginationRequest())
Expand Down Expand Up @@ -217,8 +217,8 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpn
val bpnS2 = createdStructures[1].siteStructures[0].site.site.bpn
val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpns
val bpnS2 = createdStructures[1].siteStructures[0].site.site.bpns

// search for site1 -> main address and 2 regular addresses
AddressPartnerBpnSearchRequest(sites = listOf(bpnS1))
Expand Down Expand Up @@ -280,8 +280,8 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnL = givenStructure[0].legalEntity.legalEntity.bpn
val bpnS = givenStructure[0].siteStructures[0].site.site.bpn
val bpnL = givenStructure[0].legalEntity.legalEntity.bpnl
val bpnS = givenStructure[0].siteStructures[0].site.site.bpns

val expected = listOf(
ResponseValues.addressPartnerCreate1,
Expand Down Expand Up @@ -313,7 +313,7 @@ class AddressControllerIT @Autowired constructor(
@Test
fun `don't create addresses with non-existent parent`() {
val bpnL = poolClient.legalEntities().createBusinessPartners(listOf(RequestValues.legalEntityCreate1))
.entities.single().legalEntity.bpn
.entities.single().legalEntity.bpnl

val expected = listOf(
ResponseValues.addressPartnerCreate1,
Expand Down Expand Up @@ -365,14 +365,14 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnA1 = givenStructure[0].siteStructures[0].addresses[0].address.bpn
val bpnA2 = givenStructure[0].siteStructures[0].addresses[1].address.bpn
val bpnA3 = givenStructure[1].addresses[0].address.bpn
val bpnA1 = givenStructure[0].siteStructures[0].addresses[0].address.bpna
val bpnA2 = givenStructure[0].siteStructures[0].addresses[1].address.bpna
val bpnA3 = givenStructure[1].addresses[0].address.bpna

val expected = listOf(
ResponseValues.addressPartner1.copy(bpn = bpnA2),
ResponseValues.addressPartner2.copy(bpn = bpnA3),
ResponseValues.addressPartner3.copy(bpn = bpnA1)
ResponseValues.addressPartner1.copy(bpna = bpnA2),
ResponseValues.addressPartner2.copy(bpna = bpnA3),
ResponseValues.addressPartner3.copy(bpna = bpnA1)
)

val toUpdate = listOf(
Expand Down Expand Up @@ -408,10 +408,10 @@ class AddressControllerIT @Autowired constructor(
)
)

val bpnA1 = givenStructure[0].siteStructures[0].addresses[0].address.bpn
val bpnA1 = givenStructure[0].siteStructures[0].addresses[0].address.bpna

val expected = listOf(
ResponseValues.addressPartner2.copy(bpn = bpnA1)
ResponseValues.addressPartner2.copy(bpna = bpnA1)
)

val firstInvalidBpn = "BPNLXXXXXXXX"
Expand All @@ -432,15 +432,15 @@ class AddressControllerIT @Autowired constructor(
}

private fun assertCreatedAddressesAreEqual(actuals: Collection<AddressPartnerCreateResponse>, expected: Collection<AddressPartnerCreateResponse>) {
actuals.forEach { assertThat(it.address.bpn).matches(testHelpers.bpnAPattern) }
actuals.forEach { assertThat(it.address.bpna).matches(testHelpers.bpnAPattern) }

testHelpers.assertRecursively(actuals)
.ignoringFields("address.bpn", "address.bpnLegalEntity", "address.bpnSite")
.isEqualTo(expected)
}

private fun assertAddressesAreEqual(actuals: Collection<LogisticAddressResponse>, expected: Collection<LogisticAddressResponse>) {
actuals.forEach { assertThat(it.bpn).matches(testHelpers.bpnAPattern) }
actuals.forEach { assertThat(it.bpna).matches(testHelpers.bpnAPattern) }

testHelpers.assertRecursively(actuals)
.ignoringFields("bpn", "bpnLegalEntity", "bpnSite")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class BusinessPartnerLegacyControllerIT @Autowired constructor(
fun `find by BPN`() {
val expected = convertCreateResponse(givenPartner1)

val bpn = givenPartner1.legalEntity.bpn
val bpn = givenPartner1.legalEntity.bpnl
val respone = webTestClient.invokeGetEndpoint<BusinessPartnerResponse>("${EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH}/${bpn}")

testHelpers.assertRecursively(respone).ignoringFieldsMatchingRegexes(".*uuid").isEqualTo(expected)
Expand Down
Loading

0 comments on commit 1460653

Please sign in to comment.