From 513895d856e5dc7575a7e5c59fc0310ac0d7ab9c Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 13:21:23 +0200 Subject: [PATCH 1/3] feat(api): #172 Rename BPN fields --- .../bridge/dummy/service/GateUpdateService.kt | 12 ++--- .../dto/response/LegalEntityResponse.kt | 2 +- .../dto/response/LogisticAddressResponse.kt | 2 +- .../bpdm/common/dto/response/SiteResponse.kt | 2 +- .../bpdm/gate/service/AddressService.kt | 2 +- .../bpdm/gate/service/LegalEntityService.kt | 2 +- .../tractusx/bpdm/gate/service/SiteService.kt | 2 +- .../tractusx/bpdm/gate/util/ResponseValues.kt | 12 ++--- .../service/BusinessPartnerBuildService.kt | 2 +- .../bpdm/pool/service/ResponseMappings.kt | 4 +- .../pool/controller/AddressControllerIT.kt | 42 +++++++-------- .../BusinessPartnerLegacyControllerIT.kt | 2 +- .../controller/LegalEntityControllerIT.kt | 40 +++++++------- .../bpdm/pool/controller/SiteControllerIT.kt | 52 ++++++++++--------- .../bpdm/pool/service/PartnerChangelogIT.kt | 12 +++-- .../tractusx/bpdm/pool/util/ResponseValues.kt | 36 ++++++------- .../tractusx/bpdm/pool/util/TestHelpers.kt | 22 ++++---- 17 files changed, 126 insertions(+), 122 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt index e79b7e356..d79a8e11a 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateUpdateService.kt @@ -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) { @@ -57,7 +57,7 @@ class GateUpdateService( externalIdByBpn: Map ) { 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) } @@ -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) { @@ -92,7 +92,7 @@ class GateUpdateService( externalIdByBpn: Map ) { 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) } @@ -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) { @@ -127,7 +127,7 @@ class GateUpdateService( externalIdByBpn: Map ) { 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) } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt index 6d8218bf6..ea204b03d 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LegalEntityResponse.kt @@ -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 = emptyList(), diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt index 51c6d402e..7e55ba6c8 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/LogisticAddressResponse.kt @@ -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" + diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/SiteResponse.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/SiteResponse.kt index c43d6284f..b24a0f984 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/SiteResponse.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/response/SiteResponse.kt @@ -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, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt index c45ba5503..d5033a2ee 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/AddressService.kt @@ -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." } diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt index 5e734e187..4892b9cd3 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/LegalEntityService.kt @@ -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) { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt index 5e6d394e8..dd6d0509f 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SiteService.kt @@ -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) { diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt index f4c93ec96..9fae7afe4 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/ResponseValues.kt @@ -203,7 +203,7 @@ object ResponseValues { ) val logisticAddress1 = LogisticAddressResponse( - bpn = CommonValues.bpnAddress1, + bpna = CommonValues.bpnAddress1, physicalPostalAddress = address1, bpnLegalEntity = CommonValues.bpn1, bpnSite = "BPNS0000000001XY", @@ -212,7 +212,7 @@ object ResponseValues { ) val logisticAddress2 = LogisticAddressResponse( - bpn = CommonValues.bpnAddress2, + bpna = CommonValues.bpnAddress2, physicalPostalAddress = address2, bpnLegalEntity = CommonValues.bpn2, bpnSite = "BPNS0000000002XY", @@ -222,7 +222,7 @@ object ResponseValues { val legalEntityResponse1 = LegalEntityResponse( - bpn = CommonValues.bpn1, + bpnl = CommonValues.bpn1, identifiers = listOf(identifier1, identifier2), legalName = name1, legalForm = legalForm1, @@ -234,7 +234,7 @@ object ResponseValues { ) val legalEntityResponse2 = LegalEntityResponse( - bpn = CommonValues.bpn2, + bpnl = CommonValues.bpn2, identifiers = listOf(identifier3, identifier4), legalName = name3, legalForm = legalForm2, @@ -293,7 +293,7 @@ object ResponseValues { ) val siteResponse1 = SiteResponse( - bpn = CommonValues.bpnSite1, + bpns = CommonValues.bpnSite1, name = CommonValues.nameSite1, states = listOf(), bpnLegalEntity = CommonValues.bpn1, @@ -301,7 +301,7 @@ object ResponseValues { updatedAt = CommonValues.now ) val siteResponse2 = SiteResponse( - bpn = CommonValues.bpnSite2, + bpns = CommonValues.bpnSite2, name = CommonValues.nameSite2, states = listOf(), bpnLegalEntity = CommonValues.bpn2, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index ffbb1ff69..be4210b61 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -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) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt index 9872ca574..672373a14 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/ResponseMappings.kt @@ -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(), @@ -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, diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt index 402f1bb39..5de6f41d6 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt @@ -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) @@ -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) } } @@ -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 = @@ -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()) @@ -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)) @@ -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, @@ -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, @@ -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( @@ -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" @@ -432,7 +432,7 @@ class AddressControllerIT @Autowired constructor( } private fun assertCreatedAddressesAreEqual(actuals: Collection, expected: Collection) { - 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") @@ -440,7 +440,7 @@ class AddressControllerIT @Autowired constructor( } private fun assertAddressesAreEqual(actuals: Collection, expected: Collection) { - actuals.forEach { assertThat(it.bpn).matches(testHelpers.bpnAPattern) } + actuals.forEach { assertThat(it.bpna).matches(testHelpers.bpnAPattern) } testHelpers.assertRecursively(actuals) .ignoringFields("bpn", "bpnLegalEntity", "bpnSite") diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt index 748e2dcf8..49cc46060 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/BusinessPartnerLegacyControllerIT.kt @@ -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("${EndpointValues.CATENA_BUSINESS_PARTNER_LEGACY_PATH}/${bpn}") testHelpers.assertRecursively(respone).ignoringFieldsMatchingRegexes(".*uuid").isEqualTo(expected) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index b2447b1ac..56956d1ae 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -85,7 +85,7 @@ class LegalEntityControllerIT @Autowired constructor( val expected = with(ResponseValues.legalEntityUpsert1) { copy( legalEntity = legalEntity.copy( - bpn = expectedBpn + bpnl = expectedBpn ) ) } @@ -131,7 +131,7 @@ class LegalEntityControllerIT @Autowired constructor( val expected = listOf(ResponseValues.legalEntityUpsert2, ResponseValues.legalEntityUpsert3) val toCreate = listOf(given, RequestValues.legalEntityCreate2, RequestValues.legalEntityCreate3) - val response =poolClient.legalEntities().createBusinessPartners(toCreate) + val response = poolClient.legalEntities().createBusinessPartners(toCreate) // 2 entities created assertThatCreatedLegalEntitiesEqual(response.entities, expected) @@ -151,16 +151,16 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) .entities.single() - val givenBpnL = createResponse.legalEntity.bpn - val givenBpnA = createResponse.legalAddress.bpn + val givenBpnL = createResponse.legalEntity.bpnl + val givenBpnA = createResponse.legalAddress.bpna val expected = with(ResponseValues.legalEntityUpsert3) { copy( legalEntity = legalEntity.copy( - bpn = givenBpnL + bpnl = givenBpnL ), legalAddress = legalAddress.copy( - bpn = givenBpnA, + bpna = givenBpnA, bpnLegalEntity = givenBpnL ) ) @@ -186,8 +186,8 @@ class LegalEntityControllerIT @Autowired constructor( val createResponse = poolClient.legalEntities().createBusinessPartners(given) val createdEntity = createResponse.entities.toList()[1] - val bpnL = createdEntity.legalEntity.bpn - val bpnA = createdEntity.legalAddress.bpn + val bpnL = createdEntity.legalEntity.bpnl + val bpnA = createdEntity.legalAddress.bpna val toUpdate = listOf( RequestValues.legalEntityUpdate3.copy(bpn = "NONEXISTENT"), @@ -197,10 +197,10 @@ class LegalEntityControllerIT @Autowired constructor( val expected = with(ResponseValues.legalEntityUpsert3) { copy( legalEntity = legalEntity.copy( - bpn = bpnL + bpnl = bpnL ), legalAddress = legalAddress.copy( - bpn = bpnA, + bpna = bpnA, bpnLegalEntity = bpnL ) ) @@ -233,7 +233,7 @@ class LegalEntityControllerIT @Autowired constructor( val expected = givenLegalEntities .map { toLegalAddressResponse(it.legalAddress) } - val bpnsToSearch = givenLegalEntities.map { it.legalEntity.bpn } + val bpnsToSearch = givenLegalEntities.map { it.legalEntity.bpnl } val response = poolClient.legalEntities().searchLegalAddresses(bpnsToSearch) assertThat(response) @@ -291,9 +291,9 @@ class LegalEntityControllerIT @Autowired constructor( .map { it.legalEntity } .take(2) // only search for a subset of the existing legal entities - val bpnsToSearch = expected.map { it.bpn } + val bpnsToSearch = expected.map { it.bpnl } val response = poolClient.legalEntities().searchSites(bpnsToSearch).body - + assertThat(response) .usingRecursiveComparison() .ignoringCollectionOrder() @@ -350,7 +350,7 @@ class LegalEntityControllerIT @Autowired constructor( var identifierToFind = expected.identifiers.first() identifierToFind = identifierToFind.copy(value = changeCase(identifierToFind.value)) - val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value,identifierToFind.type.technicalKey) + val response = poolClient.legalEntities().getLegalEntity(identifierToFind.value, identifierToFind.type.technicalKey) assertThat(response) .usingRecursiveComparison() @@ -377,7 +377,7 @@ class LegalEntityControllerIT @Autowired constructor( .map { it.legalEntity } .first() // search for first - val bpnToFind = expected.bpn + val bpnToFind = expected.bpnl val response = poolClient.legalEntities().getLegalEntity(bpnToFind) @@ -406,7 +406,7 @@ class LegalEntityControllerIT @Autowired constructor( .map { it.legalEntity } .first() // search for first - val bpnToFind = changeCase(expected.bpn) + val bpnToFind = changeCase(expected.bpnl) val response = poolClient.legalEntities().getLegalEntity(bpnToFind) assertThat(response) @@ -435,7 +435,7 @@ class LegalEntityControllerIT @Autowired constructor( .map { it.legalEntity } .take(2) // only search for a subset of the existing legal entities - val bpnsToSearch = expected.map { it.bpn }.plus("NONEXISTENT") // also search for nonexistent BPN + val bpnsToSearch = expected.map { it.bpnl }.plus("NONEXISTENT") // also search for nonexistent BPN val response = poolClient.legalEntities().searchSites(bpnsToSearch).body assertThat(response) @@ -455,7 +455,7 @@ class LegalEntityControllerIT @Autowired constructor( fun `set business partner currentness`() { val given = listOf(RequestValues.legalEntityCreate1) val bpnL = poolClient.legalEntities().createBusinessPartners(given) - .entities.single().legalEntity.bpn + .entities.single().legalEntity.bpnl val initialCurrentness = retrieveCurrentness(bpnL) val instantBeforeCurrentnessUpdate = Instant.now() @@ -484,11 +484,11 @@ class LegalEntityControllerIT @Autowired constructor( val now = Instant.now() val justBeforeCreate = now.minusSeconds(2) actuals.forEach { assertThat(it.legalEntity.currentness).isBetween(justBeforeCreate, now) } - actuals.forEach { assertThat(it.legalEntity.bpn).matches(testHelpers.bpnLPattern) } + actuals.forEach { assertThat(it.legalEntity.bpnl).matches(testHelpers.bpnLPattern) } testHelpers.assertRecursively(actuals) .ignoringFieldsOfTypes(Instant::class.java) - .ignoringFieldsMatchingRegexes(".*${LegalEntityResponse::bpn.name}") + .ignoringFieldsMatchingRegexes(".*${LegalEntityResponse::bpnl.name}") .isEqualTo(expected) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index fa9a8186d..dbb926e4d 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -60,11 +60,11 @@ class SiteControllerIT @Autowired constructor( val createdStructures = testHelpers.createBusinessPartnerStructure(listOf(RequestValues.partnerStructure1)) val importedPartner = createdStructures.single().legalEntity - importedPartner.legalEntity.bpn - .let { bpn -> requestSitesOfLegalEntity(bpn).content.single().bpn } + importedPartner.legalEntity.bpnl + .let { bpn -> requestSitesOfLegalEntity(bpn).content.single().bpns } .let { bpnSite -> requestSite(bpnSite) } .let { siteResponse -> - assertThat(siteResponse.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpn) + assertThat(siteResponse.bpnLegalEntity).isEqualTo(importedPartner.legalEntity.bpnl) } } @@ -99,9 +99,9 @@ class SiteControllerIT @Autowired constructor( ) ) - val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpn - val bpnS2 = createdStructures[0].siteStructures[1].site.site.bpn - val bpnL = createdStructures[0].legalEntity.legalEntity.bpn + val bpnS1 = createdStructures[0].siteStructures[0].site.site.bpns + val bpnS2 = createdStructures[0].siteStructures[1].site.site.bpns + val bpnL = createdStructures[0].legalEntity.legalEntity.bpnl val siteSearchRequest = SiteBpnSearchRequest(emptyList(), listOf(bpnS1, bpnS2)) val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) @@ -137,8 +137,8 @@ class SiteControllerIT @Autowired constructor( ) ) - val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpn - val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpn + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl val siteSearchRequest = SiteBpnSearchRequest(listOf(bpnL1, bpnL2)) val searchResult = poolClient.sites().searchSites(siteSearchRequest, PaginationRequest()) @@ -161,10 +161,11 @@ class SiteControllerIT @Autowired constructor( @Test fun `create new sites`() { - val givenLegalEntities = poolClient.legalEntities().createBusinessPartners(listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2)).entities + val givenLegalEntities = + poolClient.legalEntities().createBusinessPartners(listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2)).entities - val bpnL1 = givenLegalEntities.first().legalEntity.bpn - val bpnL2 = givenLegalEntities.last().legalEntity.bpn + val bpnL1 = givenLegalEntities.first().legalEntity.bpnl + val bpnL2 = givenLegalEntities.last().legalEntity.bpnl val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2, ResponseValues.siteUpsert3) @@ -189,10 +190,11 @@ class SiteControllerIT @Autowired constructor( fun `don't create sites with non-existing parent`() { - val givenLegalEntities = poolClient.legalEntities().createBusinessPartners(listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2)).entities + val givenLegalEntities = + poolClient.legalEntities().createBusinessPartners(listOf(RequestValues.legalEntityCreate1, RequestValues.legalEntityCreate2)).entities - val bpnL1 = givenLegalEntities.first().legalEntity.bpn - val bpnL2 = givenLegalEntities.last().legalEntity.bpn + val bpnL1 = givenLegalEntities.first().legalEntity.bpnl + val bpnL2 = givenLegalEntities.last().legalEntity.bpnl val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2) @@ -231,14 +233,14 @@ class SiteControllerIT @Autowired constructor( ) ) - val bpnS1 = givenStructure[0].siteStructures[0].site.site.bpn - val bpnS2 = givenStructure[1].siteStructures[0].site.site.bpn - val bpnS3 = givenStructure[1].siteStructures[1].site.site.bpn + val bpnS1 = givenStructure[0].siteStructures[0].site.site.bpns + val bpnS2 = givenStructure[1].siteStructures[0].site.site.bpns + val bpnS3 = givenStructure[1].siteStructures[1].site.site.bpns val expected = listOf( - ResponseValues.siteUpsert1.run { copy(site = site.copy(bpn = bpnS3), index = null) }, - ResponseValues.siteUpsert2.run { copy(site = site.copy(bpn = bpnS1), index = null) }, - ResponseValues.siteUpsert3.run { copy(site = site.copy(bpn = bpnS2), index = null) }, + ResponseValues.siteUpsert1.run { copy(site = site.copy(bpns = bpnS3), index = null) }, + ResponseValues.siteUpsert2.run { copy(site = site.copy(bpns = bpnS1), index = null) }, + ResponseValues.siteUpsert3.run { copy(site = site.copy(bpns = bpnS2), index = null) }, ) val toUpdate = listOf( @@ -269,12 +271,12 @@ class SiteControllerIT @Autowired constructor( ) ) - val bpnS1 = givenStructure[0].siteStructures[0].site.site.bpn - val bpnS2 = givenStructure[0].siteStructures[1].site.site.bpn + val bpnS1 = givenStructure[0].siteStructures[0].site.site.bpns + val bpnS2 = givenStructure[0].siteStructures[1].site.site.bpns val expected = listOf( - ResponseValues.siteUpsert1.run { copy(site = site.copy(bpn=bpnS2), index = null) }, - ResponseValues.siteUpsert2.run { copy(site = site.copy(bpn=bpnS1), index = null) }, + ResponseValues.siteUpsert1.run { copy(site = site.copy(bpns = bpnS2), index = null) }, + ResponseValues.siteUpsert2.run { copy(site = site.copy(bpns = bpnS1), index = null) }, ) val toUpdate = listOf( @@ -348,7 +350,7 @@ class SiteControllerIT @Autowired constructor( } private fun assertThatCreatedSitesEqual(actuals: Collection, expected: Collection) { - actuals.forEach { assertThat(it.site.bpn).matches(testHelpers.bpnSPattern) } + actuals.forEach { assertThat(it.site.bpns).matches(testHelpers.bpnSPattern) } testHelpers.assertRecursively(actuals) .ignoringFields("site.bpn", "site.bpnLegalEntity", "mainAddress.bpn", "mainAddress.bpnSite") diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt index ef46e1d8c..e19e65fbd 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt @@ -44,8 +44,10 @@ import org.springframework.test.web.reactive.server.returnResult import java.time.Instant import java.util.* -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class], - properties = ["bpdm.controller.search-request-limit=2"]) +@SpringBootTest( + webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = [Application::class, TestHelpers::class], + properties = ["bpdm.controller.search-request-limit=2"] +) @ActiveProfiles("test") @ContextConfiguration(initializers = [PostgreSQLContextInitializer::class]) class PartnerChangelogIT @Autowired constructor( @@ -88,8 +90,8 @@ class PartnerChangelogIT @Autowired constructor( LegalEntityStructureRequest(legalEntity = RequestValues.legalEntityCreate3) ) ) - val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpn - val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpn + val bpnL1 = createdStructures[0].legalEntity.legalEntity.bpnl + val bpnL2 = createdStructures[1].legalEntity.legalEntity.bpnl // prepare modified partner to import val modifiedPartnersToImport = listOf( @@ -191,7 +193,7 @@ class PartnerChangelogIT @Autowired constructor( ) val limit = controllerConfigProperties.searchRequestLimit - val bpnsOk = (0..limit-1).map { it -> "bpn${it}" } // limit entries + val bpnsOk = (0..limit - 1).map { it -> "bpn${it}" } // limit entries getChangelogResponse(null, bpnsOk) .expectStatus().isOk diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt index ba9fb23ce..9c4d22918 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/ResponseValues.kt @@ -152,7 +152,7 @@ object ResponseValues { ) val addressPartner1 = LogisticAddressResponse( - bpn = CommonValues.bpnA1, + bpna = CommonValues.bpnA1, physicalPostalAddress = address1, bpnLegalEntity = null, bpnSite = null, @@ -161,7 +161,7 @@ object ResponseValues { ) val addressPartner2 = LogisticAddressResponse( - bpn = CommonValues.bpnA2, + bpna = CommonValues.bpnA2, physicalPostalAddress = address2, bpnLegalEntity = null, bpnSite = null, @@ -170,7 +170,7 @@ object ResponseValues { ) val addressPartner3 = LogisticAddressResponse( - bpn = CommonValues.bpnA3, + bpna = CommonValues.bpnA3, physicalPostalAddress = address3, bpnLegalEntity = null, bpnSite = null, @@ -194,7 +194,7 @@ object ResponseValues { ) val site1 = SiteResponse( - bpn = CommonValues.bpnS1, + bpns = CommonValues.bpnS1, name = CommonValues.siteName1, states = listOf(siteStatus1), bpnLegalEntity = CommonValues.bpnL1, @@ -203,7 +203,7 @@ object ResponseValues { ) val site2 = SiteResponse( - bpn = CommonValues.bpnS2, + bpns = CommonValues.bpnS2, name = CommonValues.siteName2, states = listOf(siteStatus2), bpnLegalEntity = CommonValues.bpnL2, @@ -212,7 +212,7 @@ object ResponseValues { ) val site3 = SiteResponse( - bpn = CommonValues.bpnS3, + bpns = CommonValues.bpnS3, name = CommonValues.siteName3, states = listOf(siteStatus3), bpnLegalEntity = CommonValues.bpnL3, @@ -223,7 +223,7 @@ object ResponseValues { val siteUpsert1 = SitePartnerCreateResponse( site = site1, mainAddress = addressPartner1.copy( - bpnSite = site1.bpn, + bpnSite = site1.bpns, isMainAddress = true ), index = CommonValues.index1 @@ -232,7 +232,7 @@ object ResponseValues { val siteUpsert2 = SitePartnerCreateResponse( site = site2, mainAddress = addressPartner2.copy( - bpnSite = site2.bpn, + bpnSite = site2.bpns, isMainAddress = true ), index = CommonValues.index2 @@ -241,7 +241,7 @@ object ResponseValues { val siteUpsert3 = SitePartnerCreateResponse( site = site3, mainAddress = addressPartner3.copy( - bpnSite = site3.bpn, + bpnSite = site3.bpns, isMainAddress = true ), index = CommonValues.index3 @@ -249,7 +249,7 @@ object ResponseValues { val legalEntity1 = LegalEntityResponse( - bpn = CommonValues.bpnL1, + bpnl = CommonValues.bpnL1, legalName = name1, identifiers = listOf(identifier1), legalForm = legalForm1, @@ -261,7 +261,7 @@ object ResponseValues { ) val legalEntity2 = LegalEntityResponse( - bpn = CommonValues.bpnL2, + bpnl = CommonValues.bpnL2, legalName = name3, identifiers = listOf(identifier2), legalForm = legalForm2, @@ -273,7 +273,7 @@ object ResponseValues { ) val legalEntity3 = LegalEntityResponse( - bpn = CommonValues.bpnL3, + bpnl = CommonValues.bpnL3, legalName = name5, identifiers = listOf(identifier3), legalForm = legalForm3, @@ -286,7 +286,7 @@ object ResponseValues { val legalEntityUpsert1 = LegalEntityPartnerCreateResponse( legalEntity = LegalEntityResponse( - bpn = CommonValues.bpnL1, + bpnl = CommonValues.bpnL1, legalName = name1, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue1, RequestValues.identifierType1, CommonValues.issuingBody1)), legalForm = legalForm1, @@ -297,7 +297,7 @@ object ResponseValues { updatedAt = CommonValues.now ), legalAddress = addressPartner1.copy( - bpnLegalEntity = legalEntity1.bpn, + bpnLegalEntity = legalEntity1.bpnl, isLegalAddress = true ), index = CommonValues.index1 @@ -305,7 +305,7 @@ object ResponseValues { val legalEntityUpsert2 = LegalEntityPartnerCreateResponse( legalEntity = LegalEntityResponse( - bpn = CommonValues.bpnL2, + bpnl = CommonValues.bpnL2, legalName = name3, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue2, RequestValues.identifierType2, CommonValues.issuingBody2)), legalForm = legalForm2, @@ -316,7 +316,7 @@ object ResponseValues { updatedAt = CommonValues.now ), legalAddress = addressPartner2.copy( - bpnLegalEntity = legalEntity2.bpn, + bpnLegalEntity = legalEntity2.bpnl, isLegalAddress = true ), index = CommonValues.index2 @@ -324,7 +324,7 @@ object ResponseValues { val legalEntityUpsert3 = LegalEntityPartnerCreateResponse( legalEntity = LegalEntityResponse( - bpn = CommonValues.bpnL3, + bpnl = CommonValues.bpnL3, legalName = name5, identifiers = listOf(LegalEntityIdentifierResponse(CommonValues.identifierValue3, RequestValues.identifierType3, CommonValues.issuingBody3)), legalForm = legalForm3, @@ -335,7 +335,7 @@ object ResponseValues { updatedAt = CommonValues.now ), legalAddress = addressPartner3.copy( - bpnLegalEntity = legalEntity3.bpn, + bpnLegalEntity = legalEntity3.bpnl, isLegalAddress = true ), index = CommonValues.index3 diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt index 0c57f0340..c3eb432dc 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt @@ -58,7 +58,6 @@ class TestHelpers( val em: EntityManager = entityManagerFactory.createEntityManager() - fun truncateDbTables() { em.transaction.begin() @@ -96,7 +95,7 @@ class TestHelpers( val assignedSiteRequests = partnerStructures.flatMap { it.siteStructures.map { site -> - site.site.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpn) + site.site.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) } } val sitesWithErrorsResponse = poolClient.sites().createSite(assignedSiteRequests) @@ -105,14 +104,14 @@ class TestHelpers( val assignedSitelessAddresses = partnerStructures.flatMap { it.addresses.map { address -> - address.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpn) + address.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) } } val assignedSiteAddresses = partnerStructures .flatMap { it.siteStructures } .flatMap { - it.addresses.map { address -> address.copy(bpnParent = indexedSites[it.site.index]!!.site.bpn) } + it.addresses.map { address -> address.copy(bpnParent = indexedSites[it.site.index]!!.site.bpns) } } val addresses = poolClient.addresses().createAddresses(assignedSitelessAddresses + assignedSiteAddresses).entities @@ -132,7 +131,8 @@ class TestHelpers( ) } } - fun `get address by bpn-a, not found`(bpn:String ){ + + fun `get address by bpn-a, not found`(bpn: String) { try { val result = poolClient.addresses().getAddress(bpn) assertThrows { result } @@ -141,7 +141,7 @@ class TestHelpers( } } - fun `find bpns by identifiers, bpn request limit exceeded`( identifiersSearchRequest: IdentifiersSearchRequest){ + fun `find bpns by identifiers, bpn request limit exceeded`(identifiersSearchRequest: IdentifiersSearchRequest) { try { val result = poolClient.bpns().findBpnsByIdentifiers(identifiersSearchRequest) @@ -151,7 +151,7 @@ class TestHelpers( } } - fun `find bpns by nonexistent identifier type`( identifiersSearchRequest: IdentifiersSearchRequest){ + fun `find bpns by nonexistent identifier type`(identifiersSearchRequest: IdentifiersSearchRequest) { try { val result = poolClient.bpns().findBpnsByIdentifiers(identifiersSearchRequest) assertThrows { result } @@ -160,18 +160,18 @@ class TestHelpers( } } - fun `set business partner currentness using nonexistent bpn`(bpn:String ){ + fun `set business partner currentness using nonexistent bpn`(bpn: String) { try { - val result = poolClient.legalEntities().setLegalEntityCurrentness(bpn) + val result = poolClient.legalEntities().setLegalEntityCurrentness(bpn) assertThrows { result } } catch (e: WebClientResponseException) { Assert.assertEquals(HttpStatus.NOT_FOUND, e.statusCode) } } - fun `get site by bpn-s, not found`(bpn:String ){ + fun `get site by bpn-s, not found`(bpn: String) { try { - val result = poolClient.sites().getSite(bpn) + val result = poolClient.sites().getSite(bpn) assertThrows { result } } catch (e: WebClientResponseException) { Assert.assertEquals(HttpStatus.NOT_FOUND, e.statusCode) From 656f79b78919e98ca5ee12830d8683d0ed1f06f1 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 14:44:41 +0200 Subject: [PATCH 2/3] feat(api): #172 Rename BPN fields - fix tests --- .../bridge/dummy/service/PoolUpdateService.kt | 6 ++-- .../request/AddressPartnerUpdateRequest.kt | 2 +- .../LegalEntityPartnerUpdateRequest.kt | 2 +- .../model/request/SitePartnerUpdateRequest.kt | 2 +- .../service/BusinessPartnerBuildService.kt | 16 +++++----- .../pool/controller/AddressControllerIT.kt | 24 ++++++++++----- .../controller/LegalEntityControllerIT.kt | 6 ++-- .../bpdm/pool/controller/SiteControllerIT.kt | 19 +++++++----- .../bpdm/pool/service/PartnerChangelogIT.kt | 2 +- .../tractusx/bpdm/pool/util/RequestValues.kt | 30 +++++++++---------- 10 files changed, 61 insertions(+), 48 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 096b9864b..2daab39d4 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -53,7 +53,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { LegalEntityPartnerUpdateRequest( legalEntity = it.legalEntity, - bpn = it.bpn!! + bpnl = it.bpn!! ) } @@ -90,7 +90,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { SitePartnerUpdateRequest( site = it.site, - bpn = it.bpn!! + bpns = it.bpn!! ) } @@ -142,7 +142,7 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { AddressPartnerUpdateRequest( address = it.address, - bpn = it.bpn!! + bpna = it.bpn!! ) } diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerUpdateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerUpdateRequest.kt index ea44fd0c9..f82b0609e 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerUpdateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/AddressPartnerUpdateRequest.kt @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "AddressPartnerUpdateRequest", description = "Request for updating a business partner record of type address") data class AddressPartnerUpdateRequest( @Schema(description = "Business Partner Number of this address") - val bpn: String, + val bpna: String, @field:JsonUnwrapped val address: LogisticAddressDto diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt index 16b5f24c1..12595b58b 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/LegalEntityPartnerUpdateRequest.kt @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "LegalEntityUpdateRequest", description = "Request for updating a business partner record of type legal entity") data class LegalEntityPartnerUpdateRequest( @Schema(description = "Business Partner Number") - val bpn: String, + val bpnl: String, @field:JsonUnwrapped val legalEntity: LegalEntityDto diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerUpdateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerUpdateRequest.kt index 8d82e544a..b3c5589b0 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerUpdateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerUpdateRequest.kt @@ -29,7 +29,7 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ @Schema(name = "SitePartnerUpdateRequest", description = "Request for updating a business partner record of type site") data class SitePartnerUpdateRequest( @Schema(description = "Business Partner Number of this site") - val bpn: String, + val bpns: String, @field:JsonUnwrapped val site: SiteDto diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index be4210b61..e79abebab 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -163,7 +163,7 @@ class BusinessPartnerBuildService( val legalEntityMetadataMap = metadataMappingService.mapRequests(requests.map { it.legalEntity }) val addressMetadataMap = metadataMappingService.mapRequests(requests.map { it.legalEntity.legalAddress }) - val bpnsToFetch = requests.map { it.bpn } + val bpnsToFetch = requests.map { it.bpnl } val legalEntities = legalEntityRepository.findDistinctByBpnIn(bpnsToFetch) businessPartnerFetchService.fetchDependenciesWithLegalAddress(legalEntities) @@ -172,7 +172,7 @@ class BusinessPartnerBuildService( ErrorInfo(LegalEntityUpdateError.LegalEntityNotFound, "Legal entity $it not updated: BPNL not found", it) } - val requestByBpnMap = requests.associateBy { it.bpn } + val requestByBpnMap = requests.associateBy { it.bpnl } legalEntities.forEach { val request = requestByBpnMap.get(it.bpn)!! updateLegalEntity(it, request.legalEntity, legalEntityMetadataMap) @@ -193,7 +193,7 @@ class BusinessPartnerBuildService( val addressMetadataMap = metadataMappingService.mapRequests(requests.map { it.site.mainAddress }) - val bpnsToFetch = requests.map { it.bpn } + val bpnsToFetch = requests.map { it.bpns } val sites = siteRepository.findDistinctByBpnIn(bpnsToFetch) val bpnsNotFetched = bpnsToFetch.minus(sites.map { it.bpn }.toSet()) @@ -204,7 +204,7 @@ class BusinessPartnerBuildService( changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.bpn, ChangelogType.UPDATE, ChangelogSubject.SITE) }) changelogService.createChangelogEntries(sites.map { ChangelogEntryDto(it.mainAddress.bpn, ChangelogType.UPDATE, ChangelogSubject.ADDRESS) }) - val requestByBpnMap = requests.associateBy { it.bpn } + val requestByBpnMap = requests.associateBy { it.bpns } sites.forEach { val request = requestByBpnMap[it.bpn]!! updateSite(it, request.site) @@ -218,14 +218,14 @@ class BusinessPartnerBuildService( fun updateAddresses(requests: Collection): AddressPartnerUpdateResponseWrapper { logger.info { "Update ${requests.size} business partner addresses" } - val validAddresses = logisticAddressRepository.findDistinctByBpnIn(requests.map { it.bpn }) + val validAddresses = logisticAddressRepository.findDistinctByBpnIn(requests.map { it.bpna }) val validBpns = validAddresses.map { it.bpn }.toHashSet() - val (validRequests, invalidRequests) = requests.partition { validBpns.contains(it.bpn) } + val (validRequests, invalidRequests) = requests.partition { validBpns.contains(it.bpna) } val errors = invalidRequests.map { - ErrorInfo(AddressUpdateError.AddressNotFound, "Address ${it.bpn} not updated: BPNA not found", it.bpn) + ErrorInfo(AddressUpdateError.AddressNotFound, "Address ${it.bpna} not updated: BPNA not found", it.bpna) } - val requestByBpnMap = requests.associateBy { it.bpn } + val requestByBpnMap = requests.associateBy { it.bpna } val metadataMap = metadataMappingService.mapRequests(validRequests.map { it.address }) validAddresses.forEach { updateLogisticAddress(it, requestByBpnMap[it.bpn]!!.address, metadataMap) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt index 5de6f41d6..8bc95690e 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressControllerIT.kt @@ -376,9 +376,9 @@ class AddressControllerIT @Autowired constructor( ) val toUpdate = listOf( - RequestValues.addressPartnerUpdate1.copy(bpn = bpnA2), - RequestValues.addressPartnerUpdate2.copy(bpn = bpnA3), - RequestValues.addressPartnerUpdate3.copy(bpn = bpnA1) + RequestValues.addressPartnerUpdate1.copy(bpna = bpnA2), + RequestValues.addressPartnerUpdate2.copy(bpna = bpnA3), + RequestValues.addressPartnerUpdate3.copy(bpna = bpnA1) ) val response = poolClient.addresses().updateAddresses(toUpdate) @@ -417,9 +417,9 @@ class AddressControllerIT @Autowired constructor( val firstInvalidBpn = "BPNLXXXXXXXX" val secondInvalidBpn = "BPNAXXXXXXXX" val toUpdate = listOf( - RequestValues.addressPartnerUpdate2.copy(bpn = bpnA1), - RequestValues.addressPartnerUpdate2.copy(bpn = firstInvalidBpn), - RequestValues.addressPartnerUpdate3.copy(bpn = secondInvalidBpn) + RequestValues.addressPartnerUpdate2.copy(bpna = bpnA1), + RequestValues.addressPartnerUpdate2.copy(bpna = firstInvalidBpn), + RequestValues.addressPartnerUpdate3.copy(bpna = secondInvalidBpn) ) val response = poolClient.addresses().updateAddresses(toUpdate) @@ -435,7 +435,11 @@ class AddressControllerIT @Autowired constructor( actuals.forEach { assertThat(it.address.bpna).matches(testHelpers.bpnAPattern) } testHelpers.assertRecursively(actuals) - .ignoringFields("address.bpn", "address.bpnLegalEntity", "address.bpnSite") + .ignoringFields( + AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpna.name, + AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpnLegalEntity.name, + AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpnSite.name + ) .isEqualTo(expected) } @@ -443,7 +447,11 @@ class AddressControllerIT @Autowired constructor( actuals.forEach { assertThat(it.bpna).matches(testHelpers.bpnAPattern) } testHelpers.assertRecursively(actuals) - .ignoringFields("bpn", "bpnLegalEntity", "bpnSite") + .ignoringFields( + LogisticAddressResponse::bpna.name, + LogisticAddressResponse::bpnLegalEntity.name, + LogisticAddressResponse::bpnSite.name + ) .isEqualTo(expected) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt index 56956d1ae..e5b9ac768 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityControllerIT.kt @@ -167,7 +167,7 @@ class LegalEntityControllerIT @Autowired constructor( } val toUpdate = RequestValues.legalEntityUpdate3.copy( - bpn = givenBpnL + bpnl = givenBpnL ) val response = poolClient.legalEntities().updateBusinessPartners(listOf(toUpdate)) @@ -190,8 +190,8 @@ class LegalEntityControllerIT @Autowired constructor( val bpnA = createdEntity.legalAddress.bpna val toUpdate = listOf( - RequestValues.legalEntityUpdate3.copy(bpn = "NONEXISTENT"), - RequestValues.legalEntityUpdate3.copy(bpn = bpnL) + RequestValues.legalEntityUpdate3.copy(bpnl = "NONEXISTENT"), + RequestValues.legalEntityUpdate3.copy(bpnl = bpnL) ) val expected = with(ResponseValues.legalEntityUpsert3) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index dbb926e4d..1942544b2 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -244,9 +244,9 @@ class SiteControllerIT @Autowired constructor( ) val toUpdate = listOf( - RequestValues.siteUpdate1.copy(bpn = bpnS3), - RequestValues.siteUpdate2.copy(bpn = bpnS1), - RequestValues.siteUpdate3.copy(bpn = bpnS2) + RequestValues.siteUpdate1.copy(bpns = bpnS3), + RequestValues.siteUpdate2.copy(bpns = bpnS1), + RequestValues.siteUpdate3.copy(bpns = bpnS2) ) val response = poolClient.sites().updateSite(toUpdate) @@ -280,9 +280,9 @@ class SiteControllerIT @Autowired constructor( ) val toUpdate = listOf( - RequestValues.siteUpdate1.copy(bpn = bpnS2), - RequestValues.siteUpdate2.copy(bpn = bpnS1), - RequestValues.siteUpdate3.copy(bpn = "NONEXISTENT"), + RequestValues.siteUpdate1.copy(bpns = bpnS2), + RequestValues.siteUpdate2.copy(bpns = bpnS1), + RequestValues.siteUpdate3.copy(bpns = "NONEXISTENT"), ) val response = poolClient.sites().updateSite(toUpdate) @@ -353,7 +353,12 @@ class SiteControllerIT @Autowired constructor( actuals.forEach { assertThat(it.site.bpns).matches(testHelpers.bpnSPattern) } testHelpers.assertRecursively(actuals) - .ignoringFields("site.bpn", "site.bpnLegalEntity", "mainAddress.bpn", "mainAddress.bpnSite") + .ignoringFields( + SitePartnerCreateResponse::site.name + "." + SiteResponse::bpns.name, + SitePartnerCreateResponse::site.name + "." + SiteResponse::bpnLegalEntity.name, + SitePartnerCreateResponse::mainAddress.name + "." + LogisticAddressResponse::bpna.name, + SitePartnerCreateResponse::mainAddress.name + "." + LogisticAddressResponse::bpnSite.name + ) .isEqualTo(expected) } diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt index e19e65fbd..b913dfd33 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/PartnerChangelogIT.kt @@ -95,7 +95,7 @@ class PartnerChangelogIT @Autowired constructor( // prepare modified partner to import val modifiedPartnersToImport = listOf( - RequestValues.legalEntityUpdate3.copy(bpn = bpnL1) + RequestValues.legalEntityUpdate3.copy(bpnl = bpnL1) ) val timestampBetweenCreateAndUpdate = Instant.now() diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index f104335c4..a0d2e8f0b 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -198,17 +198,17 @@ object RequestValues { ) val legalEntityUpdate1 = LegalEntityPartnerUpdateRequest( - bpn = CommonValues.bpnL1, + bpnl = CommonValues.bpnL1, legalEntity = legalEntityCreate1.legalEntity ) val legalEntityUpdate2 = LegalEntityPartnerUpdateRequest( - bpn = CommonValues.bpnL2, + bpnl = CommonValues.bpnL2, legalEntity = legalEntityCreate2.legalEntity ) val legalEntityUpdate3 = LegalEntityPartnerUpdateRequest( - bpn = CommonValues.bpnL3, + bpnl = CommonValues.bpnL3, legalEntity = legalEntityCreate3.legalEntity ) @@ -219,7 +219,7 @@ object RequestValues { mainAddress = logisticAddress1 ), index = CommonValues.index1, - bpnParent = legalEntityUpdate1.bpn + bpnParent = legalEntityUpdate1.bpnl ) val siteCreate2 = SitePartnerCreateRequest( @@ -229,7 +229,7 @@ object RequestValues { mainAddress = logisticAddress2 ), index = CommonValues.index2, - bpnParent = legalEntityUpdate2.bpn + bpnParent = legalEntityUpdate2.bpnl ) val siteCreate3 = SitePartnerCreateRequest( @@ -239,54 +239,54 @@ object RequestValues { mainAddress = logisticAddress3 ), index = CommonValues.index3, - bpnParent = legalEntityUpdate3.bpn + bpnParent = legalEntityUpdate3.bpnl ) val siteUpdate1 = SitePartnerUpdateRequest( - bpn = CommonValues.bpnS1, + bpns = CommonValues.bpnS1, site = siteCreate1.site ) val siteUpdate2 = SitePartnerUpdateRequest( - bpn = CommonValues.bpnS2, + bpns = CommonValues.bpnS2, site = siteCreate2.site ) val siteUpdate3 = SitePartnerUpdateRequest( - bpn = CommonValues.bpnS3, + bpns = CommonValues.bpnS3, site = siteCreate3.site ) val addressPartnerCreate1 = AddressPartnerCreateRequest( address = logisticAddress1, - bpnParent = legalEntityUpdate1.bpn, + bpnParent = legalEntityUpdate1.bpnl, index = CommonValues.index1 ) val addressPartnerCreate2 = AddressPartnerCreateRequest( address = logisticAddress2, - bpnParent = legalEntityUpdate2.bpn, + bpnParent = legalEntityUpdate2.bpnl, index = CommonValues.index2 ) val addressPartnerCreate3 = AddressPartnerCreateRequest( address = logisticAddress3, - bpnParent = legalEntityUpdate3.bpn, + bpnParent = legalEntityUpdate3.bpnl, index = CommonValues.index3 ) val addressPartnerUpdate1 = AddressPartnerUpdateRequest( - bpn = CommonValues.bpnA1, + bpna = CommonValues.bpnA1, address = logisticAddress1 ) val addressPartnerUpdate2 = AddressPartnerUpdateRequest( - bpn = CommonValues.bpnA2, + bpna = CommonValues.bpnA2, address = logisticAddress2 ) val addressPartnerUpdate3 = AddressPartnerUpdateRequest( - bpn = CommonValues.bpnA3, + bpna = CommonValues.bpnA3, address = logisticAddress3 ) From 77e852223c651b51b167158d0fdadcb6a7f65a8a Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 25 May 2023 15:33:19 +0200 Subject: [PATCH 3/3] feat(api): #172 Rename BPN fields - rename controlles paths --- .../bridge/dummy/service/PoolUpdateService.kt | 2 +- .../tractusx/bpdm/pool/api/PoolAddressApi.kt | 12 ++++---- .../bpdm/pool/api/PoolLegalEntityApi.kt | 28 +++++++++---------- .../model/request/SitePartnerCreateRequest.kt | 2 +- .../bpdm/pool/controller/AddressController.kt | 6 ++-- .../pool/controller/LegalEntityController.kt | 15 +++++----- .../service/BusinessPartnerBuildService.kt | 8 +++--- .../bpdm/pool/controller/SiteControllerIT.kt | 12 ++++---- .../tractusx/bpdm/pool/util/RequestValues.kt | 6 ++-- .../tractusx/bpdm/pool/util/TestHelpers.kt | 2 +- 10 files changed, 47 insertions(+), 46 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt index 2daab39d4..c9241e1a9 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/PoolUpdateService.kt @@ -71,7 +71,7 @@ class PoolUpdateService( SitePartnerCreateRequest( site = entry.site, index = entry.externalId, - bpnParent = leParentBpn + bpnlParent = leParentBpn ) } } diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt index 34eca8eba..94cf60416 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolAddressApi.kt @@ -66,20 +66,20 @@ interface PoolAddressApi { ): PageResponse @Operation( - summary = "Get address partners by bpn", + summary = "Get address partners by bpna", description = "Get business partners of type address by bpn-a ignoring case." ) @ApiResponses( value = [ - ApiResponse(responseCode = "200", description = "Found address with specified bpn"), + ApiResponse(responseCode = "200", description = "Found address with specified bpna"), ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), - ApiResponse(responseCode = "404", description = "No address found under specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No address found under specified bpna", content = [Content()]) ] ) - @GetMapping("/{bpn}") - @GetExchange("/{bpn}") + @GetMapping("/{bpna}") + @GetExchange("/{bpna}") fun getAddress( - @Parameter(description = "Bpn value") @PathVariable bpn: String + @Parameter(description = "Bpn value") @PathVariable bpna: String ): LogisticAddressResponse @Operation( diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt index 7a42eb5a1..826b8bb17 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/PoolLegalEntityApi.kt @@ -95,19 +95,19 @@ interface PoolLegalEntityApi { @Operation( summary = "Confirms that the data of a legal entity business partner is still up to date.", description = "Confirms that the data of a business partner is still up to date " + - "by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpn." + "by saving the current timestamp at the time this POST-request is made as this business partner's \"currentness\". Ignores case of bpnl." ) @ApiResponses( value = [ ApiResponse(responseCode = "200", description = "Business partner's \"currentness\" successfully updated"), ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()]) ] ) - @PostMapping("/{bpn}/confirm-up-to-date") - @PostExchange("/{bpn}/confirm-up-to-date") + @PostMapping("/{bpnl}/confirm-up-to-date") + @PostExchange("/{bpnl}/confirm-up-to-date") fun setLegalEntityCurrentness( - @Parameter(description = "Bpn value") @PathVariable bpn: String + @Parameter(description = "Bpnl value") @PathVariable bpnl: String ) @Operation( @@ -134,19 +134,19 @@ interface PoolLegalEntityApi { @Operation( summary = "Get site partners of a legal entity", - description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpn ignoring case." + description = "Get business partners of type site belonging to a business partner of type legal entity, identified by the business partner's bpnl ignoring case." ) @ApiResponses( value = [ - ApiResponse(responseCode = "200", description = "The sites for the specified bpn"), + ApiResponse(responseCode = "200", description = "The sites for the specified bpnl"), ApiResponse(responseCode = "400", description = "On malformed pagination request", content = [Content()]), - ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) + ApiResponse(responseCode = "404", description = "No business partner found for specified bpnl", content = [Content()]) ] ) - @GetMapping("/{bpn}/sites") - @GetExchange("/{bpn}/sites") + @GetMapping("/{bpnl}/sites") + @GetExchange("/{bpnl}/sites") fun getSites( - @Parameter(description = "Bpn value") @PathVariable bpn: String, + @Parameter(description = "Bpnl value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest ): PageResponse @@ -161,10 +161,10 @@ interface PoolLegalEntityApi { ApiResponse(responseCode = "404", description = "No business partner found for specified bpn", content = [Content()]) ] ) - @GetMapping("/{bpn}/addresses") - @GetExchange("/{bpn}/addresses") + @GetMapping("/{bpnl}/addresses") + @GetExchange("/{bpnl}/addresses") fun getAddresses( - @Parameter(description = "Bpn value") @PathVariable bpn: String, + @Parameter(description = "Bpn value") @PathVariable bpnl: String, @ParameterObject paginationRequest: PaginationRequest ): PageResponse diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt index bd7026f8f..015bcaacc 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/request/SitePartnerCreateRequest.kt @@ -32,7 +32,7 @@ data class SitePartnerCreateRequest( val site: SiteDto, @Schema(description = "Business Partner Number of the legal entity this site belongs to") - val bpnParent: String, + val bpnlParent: String, @Schema(description = "User defined index to conveniently match this entry to the corresponding entry in the response") val index: String? diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt index 3b0304eec..759cef975 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/AddressController.kt @@ -52,9 +52,9 @@ class AddressController( } override fun getAddress( - bpn: String + bpna: String ): LogisticAddressResponse { - return addressService.findByBpn(bpn.uppercase()) + return addressService.findByBpn(bpna.uppercase()) } override fun searchAddresses( @@ -68,7 +68,7 @@ class AddressController( override fun createAddresses( requests: Collection - ): AddressPartnerCreateResponseWrapper { + ): AddressPartnerCreateResponseWrapper { return businessPartnerBuildService.createAddresses(requests) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt index a719f2572..d45367950 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/controller/LegalEntityController.kt @@ -72,8 +72,8 @@ class LegalEntityController( } - override fun setLegalEntityCurrentness(bpn: String) { - businessPartnerBuildService.setBusinessPartnerCurrentness(bpn.uppercase()) + override fun setLegalEntityCurrentness(bpnl: String) { + businessPartnerBuildService.setBusinessPartnerCurrentness(bpnl.uppercase()) } override fun searchSites( @@ -86,18 +86,18 @@ class LegalEntityController( } override fun getSites( - bpn: String, + bpnl: String, paginationRequest: PaginationRequest ): PageResponse { - return siteService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size) + return siteService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } override fun getAddresses( - bpn: String, + bpnl: String, paginationRequest: PaginationRequest ): PageResponse { - return addressService.findByPartnerBpn(bpn.uppercase(), paginationRequest.page, paginationRequest.size) + return addressService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size) } @@ -114,7 +114,8 @@ class LegalEntityController( return businessPartnerBuildService.createLegalEntities(businessPartners) } - override fun updateBusinessPartners(businessPartners: Collection + override fun updateBusinessPartners( + businessPartners: Collection ): LegalEntityPartnerUpdateResponseWrapper { return businessPartnerBuildService.updateLegalEntities(businessPartners) } diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt index e79abebab..9e9745ee8 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/BusinessPartnerBuildService.kt @@ -95,12 +95,12 @@ class BusinessPartnerBuildService( fun createSites(requests: Collection): SitePartnerCreateResponseWrapper { logger.info { "Create ${requests.size} new sites" } - val legalEntities = legalEntityRepository.findDistinctByBpnIn(requests.map { it.bpnParent }) + val legalEntities = legalEntityRepository.findDistinctByBpnIn(requests.map { it.bpnlParent }) val legalEntityMap = legalEntities.associateBy { it.bpn } - val (validRequests, invalidRequests) = requests.partition { legalEntityMap[it.bpnParent] != null } + val (validRequests, invalidRequests) = requests.partition { legalEntityMap[it.bpnlParent] != null } val errors = invalidRequests.map { - ErrorInfo(SiteCreateError.LegalEntityNotFound, "Site not created: parent legal entity ${it.bpnParent} not found", it.index) + ErrorInfo(SiteCreateError.LegalEntityNotFound, "Site not created: parent legal entity ${it.bpnlParent} not found", it.index) } val addressMetadataMap = metadataMappingService.mapRequests(validRequests.map { it.site.mainAddress }) @@ -110,7 +110,7 @@ class BusinessPartnerBuildService( val siteWithIndexByBpnMap = validRequests .mapIndexed { i, request -> - val legalEntity = legalEntityMap[request.bpnParent]!! + val legalEntity = legalEntityMap[request.bpnlParent]!! val site = createSite(request.site, bpnSs[i], legalEntity) site.mainAddress = createLogisticAddress(request.site.mainAddress, bpnAs[i], site, addressMetadataMap) Pair(site, request.index) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt index 1942544b2..3a5fffdf3 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/controller/SiteControllerIT.kt @@ -170,9 +170,9 @@ class SiteControllerIT @Autowired constructor( val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2, ResponseValues.siteUpsert3) val toCreate = listOf( - RequestValues.siteCreate1.copy(bpnParent = bpnL1), - RequestValues.siteCreate2.copy(bpnParent = bpnL2), - RequestValues.siteCreate3.copy(bpnParent = bpnL2) + RequestValues.siteCreate1.copy(bpnlParent = bpnL1), + RequestValues.siteCreate2.copy(bpnlParent = bpnL2), + RequestValues.siteCreate3.copy(bpnlParent = bpnL2) ) val response = poolClient.sites().createSite(toCreate) @@ -200,9 +200,9 @@ class SiteControllerIT @Autowired constructor( val expected = listOf(ResponseValues.siteUpsert1, ResponseValues.siteUpsert2) val toCreate = listOf( - RequestValues.siteCreate1.copy(bpnParent = bpnL1), - RequestValues.siteCreate2.copy(bpnParent = bpnL2), - RequestValues.siteCreate3.copy(bpnParent = "NONEXISTENT") + RequestValues.siteCreate1.copy(bpnlParent = bpnL1), + RequestValues.siteCreate2.copy(bpnlParent = bpnL2), + RequestValues.siteCreate3.copy(bpnlParent = "NONEXISTENT") ) val response = poolClient.sites().createSite(toCreate) diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt index a0d2e8f0b..605574f83 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/RequestValues.kt @@ -219,7 +219,7 @@ object RequestValues { mainAddress = logisticAddress1 ), index = CommonValues.index1, - bpnParent = legalEntityUpdate1.bpnl + bpnlParent = legalEntityUpdate1.bpnl ) val siteCreate2 = SitePartnerCreateRequest( @@ -229,7 +229,7 @@ object RequestValues { mainAddress = logisticAddress2 ), index = CommonValues.index2, - bpnParent = legalEntityUpdate2.bpnl + bpnlParent = legalEntityUpdate2.bpnl ) val siteCreate3 = SitePartnerCreateRequest( @@ -239,7 +239,7 @@ object RequestValues { mainAddress = logisticAddress3 ), index = CommonValues.index3, - bpnParent = legalEntityUpdate3.bpnl + bpnlParent = legalEntityUpdate3.bpnl ) val siteUpdate1 = SitePartnerUpdateRequest( diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt index c3eb432dc..5334c5839 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/TestHelpers.kt @@ -95,7 +95,7 @@ class TestHelpers( val assignedSiteRequests = partnerStructures.flatMap { it.siteStructures.map { site -> - site.site.copy(bpnParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) + site.site.copy(bpnlParent = indexedLegalEntities[it.legalEntity.index]!!.legalEntity.bpnl) } } val sitesWithErrorsResponse = poolClient.sites().createSite(assignedSiteRequests)