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 02b3e1f26..b88bc53ca 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 @@ -130,7 +130,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 66a762998..39d4fa7e0 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 @@ -97,7 +97,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 d9969a7e9..67a07cda4 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 @@ -86,7 +86,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 dbe45c5bc..cea8fa823 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, @@ -272,7 +272,7 @@ object ResponseValues { ) val siteResponse1 = SiteResponse( - bpn = CommonValues.bpnSite1, + bpns = CommonValues.bpnSite1, name = CommonValues.nameSite1, states = listOf(), bpnLegalEntity = CommonValues.bpn1, @@ -280,7 +280,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/component/saas/service/PartnerImportPageService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportPageService.kt index ef6491da3..192410b1b 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportPageService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/service/PartnerImportPageService.kt @@ -23,7 +23,6 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.IdentifierLsaType import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse import org.eclipse.tractusx.bpdm.common.dto.saas.BusinessPartnerSaas -import org.eclipse.tractusx.bpdm.common.dto.saas.ThoroughfareSaas import org.eclipse.tractusx.bpdm.common.exception.BpdmMappingException import org.eclipse.tractusx.bpdm.common.service.SaasMappings import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressPartnerCreateResponse @@ -88,7 +87,7 @@ class PartnerImportPageService( ) } - private fun addNewMetadata(partners: Collection){ + private fun addNewMetadata(partners: Collection) { val (legalEntitiesSaas, _, addressesSaas) = partitionIntoLSA(partners) { it.extractLsaType() } addNewMetadataIdentifierTypes(legalEntitiesSaas, IdentifierLsaType.LEGAL_ENTITY) @@ -134,9 +133,9 @@ class PartnerImportPageService( val createdSites = if (sites.isNotEmpty()) businessPartnerBuildService.createSites(sites).entities else emptyList() val createdAddresses = if (addresses.isNotEmpty()) businessPartnerBuildService.createAddresses(addresses).entities else emptyList() - val legalEntityImportEntries = createdLegalEntities.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.legalEntity.bpn) else null } - val siteImportEntries = createdSites.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.site.bpn) else null } - val addressImportEntries = createdAddresses.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.address.bpn) else null } + val legalEntityImportEntries = createdLegalEntities.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.legalEntity.bpnl) else null } + val siteImportEntries = createdSites.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.site.bpns) else null } + val addressImportEntries = createdAddresses.mapNotNull { if (it.index != null) ImportEntry(it.index!!, it.address.bpna) else null } importEntryRepository.saveAll(legalEntityImportEntries + siteImportEntries + addressImportEntries) @@ -179,7 +178,7 @@ class PartnerImportPageService( } } - private fun determineParentBPNs(parents: Collection): Collection{ + private fun determineParentBPNs(parents: Collection): Collection { val parentByImportId = parents.associateBy { it.externalId!! } val (parentsWithoutBpn, parentsWithBpn) = partitionHasNoBpnAndValidBpn(parents) @@ -187,8 +186,8 @@ class PartnerImportPageService( //create missing parents in the Pool val (newLegalEntities, newSites, _) = createPartners(parentsWithoutBpn) - val createdParents = newLegalEntities.map { Pair(parentByImportId[it.index], it.legalEntity.bpn) } - .plus(newSites.map { Pair(parentByImportId[it.index], it.site.bpn) }) + val createdParents = newLegalEntities.map { Pair(parentByImportId[it.index], it.legalEntity.bpnl) } + .plus(newSites.map { Pair(parentByImportId[it.index], it.site.bpns) }) .filter { (parent, _) -> parent != null } .map { BusinessPartnerWithBpn(it.first!!, it.second) } @@ -211,7 +210,7 @@ class PartnerImportPageService( try { SaasMappings.convertSaasAdressesToLogisticAddressDto(partner.addresses, partner.externalId) - } catch(e: BpdmMappingException) { + } catch (e: BpdmMappingException) { logger.warn { "SaaS Partner with id ${partner.id} is invalid. Message: ${e.localizedMessage}" } return false } @@ -268,7 +267,7 @@ class PartnerImportPageService( * If we encounter valid BPNs with no import entry we create an import entry for it (as self correction logic) * Optionally, depending on the configuration we either ignore records with invalid BPNs or we treat them as having no BPN */ - private fun partitionHasNoBpnAndValidBpn(partners: Collection): Pair, Collection>{ + private fun partitionHasNoBpnAndValidBpn(partners: Collection): Pair, Collection> { //search BPN in import entry based on CX-Pool identifier val (withEntry, withoutEntry) = partitionHasImportEntry(partners) //if no entry has been found look for BPN in identifiers of records @@ -276,13 +275,13 @@ class PartnerImportPageService( //if BPN is identifiers but no import record exists, check whether the BPN is known to the BPDM Pool val (bpnFound, bpnMissing) = partitionBpnFound(hasBpnIdentifier) - val consequence = if(adapterProperties.treatInvalidBpnAsNew) "Record will be treated as having no BPN." else "Record will be ignored." + val consequence = if (adapterProperties.treatInvalidBpnAsNew) "Record will be treated as having no BPN." else "Record will be ignored." bpnMissing.forEach { logger.warn { "Business partner with Id ${it.partner.externalId} contains BPN ${it.bpn} but such BPN can't be found in the Pool." + consequence } } val hasValidBpn = withEntry + bpnFound - val hasNoBpn = if(adapterProperties.treatInvalidBpnAsNew) hasNoBpnIdentifier + bpnMissing.map { it.partner } else hasNoBpnIdentifier + val hasNoBpn = if (adapterProperties.treatInvalidBpnAsNew) hasNoBpnIdentifier + bpnMissing.map { it.partner } else hasNoBpnIdentifier //Create missing import entries for records which have known BPNs importEntryRepository.saveAll(bpnFound.map { ImportEntry(it.partner.externalId!!, it.bpn) }) @@ -330,14 +329,13 @@ class PartnerImportPageService( return Pair(bpnExists.values, bpnMissing.values) } - private fun partitionLSA(bpns: Collection): Triple, Collection, Collection>{ + private fun partitionLSA(bpns: Collection): Triple, Collection, Collection> { val bpnLs = mutableListOf() val bpnSs = mutableListOf() val bpnAs = mutableListOf() - bpns.map { it.uppercase()}.forEach { - when(it.take(4)) - { + bpns.map { it.uppercase() }.forEach { + when (it.take(4)) { "BPNL" -> bpnLs.add(it) "BPNS" -> bpnSs.add(it) "BPNA" -> bpnAs.add(it) 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/component/saas/controller/SaasControllerImportIT.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt index 33ac33be9..225469f70 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/component/saas/controller/SaasControllerImportIT.kt @@ -470,9 +470,9 @@ class SaasControllerImportIT @Autowired constructor( //assert actual is expected val expectedPartners = listOf( - ResponseValues.legalEntity1.copy(bpn = bpnL2), - ResponseValues.legalEntity2.copy(bpn = bpnL3), - ResponseValues.legalEntity3.copy(bpn = bpnL1) + ResponseValues.legalEntity1.copy(bpnl = bpnL2), + ResponseValues.legalEntity2.copy(bpnl = bpnL3), + ResponseValues.legalEntity3.copy(bpnl = bpnL1) ) val actual = getLegalEntities(bpns) testHelpers.assertRecursively(actual).ignoringFieldsMatchingRegexes(".*currentness").isEqualTo(expectedPartners) @@ -515,9 +515,9 @@ class SaasControllerImportIT @Autowired constructor( //assert actual is expected val expectedPartners = listOf( - ResponseValues.site1.copy(bpn = bpnS2, bpnLegalEntity = bpnL2), - ResponseValues.site2.copy(bpn = bpnS3, bpnLegalEntity = bpnL3), - ResponseValues.site3.copy(bpn = bpnS1, bpnLegalEntity = bpnL1), + ResponseValues.site1.copy(bpns = bpnS2, bpnLegalEntity = bpnL2), + ResponseValues.site2.copy(bpns = bpnS3, bpnLegalEntity = bpnL3), + ResponseValues.site3.copy(bpns = bpnS1, bpnLegalEntity = bpnL1), ) val actual = getSites(bpns).content testHelpers.assertRecursively(actual).isEqualTo(expectedPartners) @@ -560,9 +560,9 @@ class SaasControllerImportIT @Autowired constructor( //assert actual is expected val expectedPartners = 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 actual = getAddresses(bpns).content testHelpers.assertRecursively(actual.toList().sortedBy { it.physicalPostalAddress.industrialZone }) @@ -595,7 +595,8 @@ class SaasControllerImportIT @Autowired constructor( private fun getSites(bpns: Collection): PageResponse = poolClient.sites().searchSites(SiteBpnSearchRequest(sites = bpns), PaginationRequest()) - private fun getAddresses(bpns: Collection): PageResponse = poolClient.addresses().searchAddresses(AddressPartnerBpnSearchRequest(addresses = bpns), PaginationRequest()) + private fun getAddresses(bpns: Collection): PageResponse = + poolClient.addresses().searchAddresses(AddressPartnerBpnSearchRequest(addresses = bpns), PaginationRequest()) private fun importPartners( partnersToImport: List, 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 f55a2d54c..a25065158 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 @@ -72,7 +72,6 @@ class TestHelpers( val em: EntityManager = entityManagerFactory.createEntityManager() - fun truncateDbTables() { em.transaction.begin() @@ -110,7 +109,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) @@ -119,14 +118,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 @@ -146,7 +145,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 } @@ -155,7 +155,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) @@ -165,7 +165,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 } @@ -174,18 +174,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)