From f10b6239b14d7daff68f7185e7a31285c0a96149 Mon Sep 17 00:00:00 2001 From: rschneider <97682836+rainer-exxcellent@users.noreply.github.com> Date: Thu, 1 Jun 2023 08:13:09 +0200 Subject: [PATCH] feat(api): #181 Gate API: Nameparts fix after merge --- .../bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt | 1 + .../bpdm/bridge/dummy/service/PoolUpdateService.kt | 6 ++++-- .../tractusx/bpdm/common/dto/LegalEntityDto.kt | 2 +- .../tractusx/bpdm/common/service/SaasMappings.kt | 4 ++-- .../tractusx/bpdm/gate/service/ResponseMappings.kt | 1 - .../controller/LegalEntityControllerInputIT.kt | 14 ++++++-------- .../tractusx/bpdm/gate/util/RequestValues.kt | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt index 13c52d44c..84f3cc1d4 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/GateLegalEntityInfo.kt @@ -22,6 +22,7 @@ package com.catenax.bpdm.bridge.dummy.dto import org.eclipse.tractusx.bpdm.common.dto.LegalEntityDto data class GateLegalEntityInfo( + val legalNameParts: Array = emptyArray(), val legalEntity: LegalEntityDto, val externalId: String, val bpn: String? 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 c9241e1a9..7d442ac85 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 @@ -41,7 +41,8 @@ class PoolUpdateService( val createRequests = entriesToCreate.map { LegalEntityPartnerCreateRequest( legalEntity = it.legalEntity, - index = it.externalId + index = it.externalId, + legalName = it.legalNameParts[0] ) } @@ -53,7 +54,8 @@ class PoolUpdateService( val updateRequests = entriesToUpdate.map { LegalEntityPartnerUpdateRequest( legalEntity = it.legalEntity, - bpnl = it.bpn!! + bpnl = it.bpn!!, + legalName = it.legalNameParts[0] ) } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt index 352d1cfb5..794bd3c8b 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/LegalEntityDto.kt @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.media.Schema data class LegalEntityDto( @ArraySchema(arraySchema = Schema(description = "Additional identifiers (except BPN)", required = false)) val identifiers: Collection = emptyList(), - + @get:Schema(description = "Abbreviated name or shorthand") val legalShortName: String?, diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index a16b97675..8c8ce8b80 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -100,7 +100,7 @@ object SaasMappings { ) } - fun BusinessPartnerSaas.toNameDto(): SassNameDto? { + private fun BusinessPartnerSaas.toNameDto(): SassNameDto? { if (names.size > 1) { logger.warn { "Business Partner with ID $externalId has more than one name" } } @@ -292,7 +292,7 @@ object SaasMappings { ) } - data class SassNameDto( + private data class SassNameDto( val value: String, val shortName: String? ) { diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt index 087423449..b8ef2eba9 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/ResponseMappings.kt @@ -293,7 +293,6 @@ private fun Street.toStreetDto(): StreetDto { fun LegalEntity.toLegalEntityDto(): LegalEntityDto { return LegalEntityDto( - legalName = legalName.value, legalForm = legalForm, legalShortName = legalName.shortName, legalAddress = legalAddress.toLogisticAddressDto(), diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt index da0f52c00..262c01a21 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/LegalEntityControllerInputIT.kt @@ -61,8 +61,7 @@ internal class LegalEntityControllerInputIT @Autowired constructor( private val webTestClient: WebTestClient, private val objectMapper: ObjectMapper, val gateClient: GateClient, - private val legalEntityRepository: LegalEntityRepository, - private val testHelpers: DbTestHelpers + private val legalEntityRepository: LegalEntityRepository ) { companion object { @RegisterExtension @@ -241,12 +240,11 @@ internal class LegalEntityControllerInputIT @Autowired constructor( content = expectedLegalEntities ) + // TODO check administrativeAreaLevel1 assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( - expectedPage - ) - - testHelpers.assertRecursively(pageResponse).isEqualTo(expectedResponse) + expectedPage + ) } @@ -289,8 +287,8 @@ internal class LegalEntityControllerInputIT @Autowired constructor( assertThat(pageResponse).usingRecursiveComparison().ignoringCollectionOrder().ignoringAllOverriddenEquals() .ignoringFieldsMatchingRegexes(".*processStartedAt*", ".*administrativeAreaLevel1*").isEqualTo( - expectedPage - ) + expectedPage + ) } /** diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index 1b18a771c..1a3348d4f 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -250,7 +250,6 @@ object RequestValues { val legalEntity3 = LegalEntityDto( identifiers = listOf(identifier1, identifier2), - legalName = CommonValues.name1, legalShortName = CommonValues.shortName1, legalForm = CommonValues.legalFormTechnicalKey1, states = listOf(leBusinessStatus1), @@ -274,6 +273,7 @@ object RequestValues { val legalEntityGateInputRequest3 = LegalEntityGateInputRequest( legalEntity = legalEntity3, + legalNameParts = arrayOf(CommonValues.name1), externalId = CommonValues.externalId3, bpn = CommonValues.bpn3 )