From 5dc9687d669dc5a3ae04223e4d25f3a6c095f290 Mon Sep 17 00:00:00 2001 From: Martin Kaeser Date: Wed, 6 Dec 2023 18:30:11 +0100 Subject: [PATCH] refactor(DTO): Unify postal address for normal/verbose model --- .../bridge/dummy/dto/DtoConversionHelper.kt | 8 +++--- .../dto/IBaseAlternativePostalAddressDto.kt | 8 ++---- .../dto/IBasePhysicalPostalAddressDto.kt | 8 ++---- .../DataClassUnwrappedJsonDeserializer.kt | 7 +++-- .../api/model/AlternativePostalAddressDto.kt | 10 +------ .../api/model/PhysicalPostalAddressDto.kt | 10 +------ .../api/model/AlternativePostalAddressDto.kt | 10 ++----- .../api/model/PhysicalPostalAddressDto.kt | 11 ++------ .../api/model/AlternativePostalAddressDto.kt | 10 +------ .../AlternativePostalAddressVerboseDto.kt | 28 +++++++++++++------ .../api/model/PhysicalPostalAddressDto.kt | 10 +------ .../model/PhysicalPostalAddressVerboseDto.kt | 26 +++++++++++------ .../service/BusinessPartnerBuildService.kt | 8 +++--- .../bpdm/pool/service/MetadataService.kt | 8 +++--- .../bpdm/pool/service/ResponseMappings.kt | 8 +++--- .../TaskStepFetchAndReserveServiceTest.kt | 12 ++++---- .../util/BusinessPartnerNonVerboseValues.kt | 6 ++-- .../pool/util/BusinessPartnerVerboseValues.kt | 24 ++++++++-------- 18 files changed, 91 insertions(+), 121 deletions(-) diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt index c45946ac6..e0040ae47 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/dto/DtoConversionHelper.kt @@ -255,10 +255,10 @@ private fun poolToGatePhysicalAddress(address: PhysicalPostalAddressVerboseDto): } return Gate_PhysicalPostalAddressDto( geographicCoordinates = address.geographicCoordinates, - country = address.country.technicalKey, + country = address.country, postalCode = address.postalCode, city = address.city, - administrativeAreaLevel1 = address.administrativeAreaLevel1?.regionCode, + administrativeAreaLevel1 = address.administrativeAreaLevel1, administrativeAreaLevel2 = address.administrativeAreaLevel2, administrativeAreaLevel3 = address.administrativeAreaLevel3, district = address.district, @@ -274,10 +274,10 @@ private fun poolToGatePhysicalAddress(address: PhysicalPostalAddressVerboseDto): private fun poolToGateAlternativeAddress(address: AlternativePostalAddressVerboseDto): org.eclipse.tractusx.bpdm.gate.api.model.AlternativePostalAddressDto { return org.eclipse.tractusx.bpdm.gate.api.model.AlternativePostalAddressDto( geographicCoordinates = address.geographicCoordinates, - country = address.country.technicalKey, + country = address.country, postalCode = address.postalCode, city = address.city, - administrativeAreaLevel1 = address.administrativeAreaLevel1?.regionCode, + administrativeAreaLevel1 = address.administrativeAreaLevel1, deliveryServiceNumber = address.deliveryServiceNumber, deliveryServiceType = address.deliveryServiceType, deliveryServiceQualifier = address.deliveryServiceQualifier diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAlternativePostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAlternativePostalAddressDto.kt index 6cbe666ad..4f10a7895 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAlternativePostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBaseAlternativePostalAddressDto.kt @@ -33,10 +33,10 @@ interface IBaseAlternativePostalAddressDto { val geographicCoordinates: GeoCoordinateDto? @get:Schema(description = PostalAddressDescription.country) - val country: Any? + val country: CountryCode? @get:Schema(description = PostalAddressDescription.administrativeAreaLevel1) - val administrativeAreaLevel1: Any? + val administrativeAreaLevel1: String? @get:Schema(description = PostalAddressDescription.postalCode) val postalCode: String? @@ -52,8 +52,4 @@ interface IBaseAlternativePostalAddressDto { @get:Schema(description = PostalAddressDescription.deliveryServiceNumber) val deliveryServiceNumber: String? - - fun adminLevel1Key(): String? - - fun countryCode(): CountryCode? } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBasePhysicalPostalAddressDto.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBasePhysicalPostalAddressDto.kt index 4059e92a3..6b5655589 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBasePhysicalPostalAddressDto.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/dto/IBasePhysicalPostalAddressDto.kt @@ -32,10 +32,10 @@ interface IBasePhysicalPostalAddressDto { val geographicCoordinates: GeoCoordinateDto? @get:Schema(description = PostalAddressDescription.country) - val country: Any? + val country: CountryCode? @get:Schema(description = PostalAddressDescription.administrativeAreaLevel1) - val administrativeAreaLevel1: Any? + val administrativeAreaLevel1: String? @get:Schema(description = PostalAddressDescription.administrativeAreaLevel2) val administrativeAreaLevel2: String? @@ -69,8 +69,4 @@ interface IBasePhysicalPostalAddressDto { @get:Schema(description = PostalAddressDescription.door) val door: String? - - fun adminLevel1Key(): String? - - fun countryCode(): CountryCode? } diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/DataClassUnwrappedJsonDeserializer.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/DataClassUnwrappedJsonDeserializer.kt index 5dfd30366..8843317aa 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/DataClassUnwrappedJsonDeserializer.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/DataClassUnwrappedJsonDeserializer.kt @@ -19,6 +19,7 @@ package org.eclipse.tractusx.bpdm.common.service +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.annotation.JsonUnwrapped import com.fasterxml.jackson.core.JsonParser import com.fasterxml.jackson.databind.* @@ -58,7 +59,7 @@ private class DataClassUnwrappedJsonDeserializerForType(destinationJavaType: Jav this.primaryConstructor = destinationClass.primaryConstructor ?: throw IllegalStateException("Primary constructor required for '$destinationClass'") - // Annotation @field:JsonUnwrapped is stored on the Java field, not the constructor parameter. + // Annotations @field:JsonUnwrapped and @field:JsonProperty are stored on the Java field, not the constructor parameter. val propertiesByName = destinationClass.memberProperties.associateBy { it.name } this.constructorParameters = primaryConstructor.parameters.map { param -> @@ -66,7 +67,9 @@ private class DataClassUnwrappedJsonDeserializerForType(destinationJavaType: Jav ?: throw IllegalStateException("Some primary constructor parameter of '$destinationClass' doesn't have a name") val type = param.type val jsonUnwrapped = propertiesByName[name]?.javaField?.getAnnotation(JsonUnwrapped::class.java) != null - ConstructorParameter(name, type, jsonUnwrapped) + val altName = propertiesByName[name]?.javaField?.getAnnotation(JsonProperty::class.java)?.value + val finalName = if (altName.isNullOrEmpty()) name else altName + ConstructorParameter(finalName, type, jsonUnwrapped) } } diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AlternativePostalAddressDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AlternativePostalAddressDto.kt index 11dff433c..006c864be 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AlternativePostalAddressDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/AlternativePostalAddressDto.kt @@ -41,12 +41,4 @@ data class AlternativePostalAddressDto( override val deliveryServiceQualifier: String? = null, override val deliveryServiceNumber: String? = null -) : IBaseAlternativePostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - - override fun countryCode(): CountryCode? { - return country - } -} +) : IBaseAlternativePostalAddressDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressDto.kt index 16f27978f..9abe2700b 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/PhysicalPostalAddressDto.kt @@ -46,12 +46,4 @@ data class PhysicalPostalAddressDto( override val floor: String? = null, override val door: String? = null -) : IBasePhysicalPostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - - override fun countryCode(): CountryCode? { - return country - } -} +) : IBasePhysicalPostalAddressDto diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/AlternativePostalAddressDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/AlternativePostalAddressDto.kt index 958f99a93..b300633e6 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/AlternativePostalAddressDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/AlternativePostalAddressDto.kt @@ -25,6 +25,7 @@ import org.eclipse.tractusx.bpdm.common.dto.IBaseAlternativePostalAddressDto import org.eclipse.tractusx.bpdm.common.model.DeliveryServiceType data class AlternativePostalAddressDto( + override val geographicCoordinates: GeoCoordinateDto? = null, override val country: CountryCode? = null, override val administrativeAreaLevel1: String? = null, @@ -34,11 +35,4 @@ data class AlternativePostalAddressDto( override val deliveryServiceQualifier: String? = null, override val deliveryServiceNumber: String? = null -) : IBaseAlternativePostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - override fun countryCode(): CountryCode? { - return country - } -} +) : IBaseAlternativePostalAddressDto diff --git a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PhysicalPostalAddressDto.kt b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PhysicalPostalAddressDto.kt index 906b694ad..a24d6193a 100644 --- a/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PhysicalPostalAddressDto.kt +++ b/bpdm-orchestrator-api/src/main/kotlin/org/eclipse/tractusx/orchestrator/api/model/PhysicalPostalAddressDto.kt @@ -24,6 +24,7 @@ import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.dto.IBasePhysicalPostalAddressDto data class PhysicalPostalAddressDto( + override val geographicCoordinates: GeoCoordinateDto? = null, override val country: CountryCode? = null, override val administrativeAreaLevel1: String? = null, @@ -39,12 +40,4 @@ data class PhysicalPostalAddressDto( override val floor: String? = null, override val door: String? = null -) : IBasePhysicalPostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - - override fun countryCode(): CountryCode? { - return country - } -} +) : IBasePhysicalPostalAddressDto diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressDto.kt index 4a87f050b..55de92411 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressDto.kt @@ -44,12 +44,4 @@ data class AlternativePostalAddressDto( override val deliveryServiceQualifier: String?, override val deliveryServiceNumber: String -) : IBaseAlternativePostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - - override fun countryCode(): CountryCode { - return country - } -} +) : IBaseAlternativePostalAddressDto diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressVerboseDto.kt index d8d7251b6..047464f55 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/AlternativePostalAddressVerboseDto.kt @@ -19,6 +19,8 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.neovisionaries.i18n.CountryCode import io.swagger.v3.oas.annotations.media.Schema @@ -34,8 +36,15 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ data class AlternativePostalAddressVerboseDto( override val geographicCoordinates: GeoCoordinateDto?, - override val country: TypeKeyNameVerboseDto, - override val administrativeAreaLevel1: RegionDto?, + + @field:JsonProperty("country") + @get:Schema(description = PostalAddressDescription.country) + val countryVerbose: TypeKeyNameVerboseDto, + + @field:JsonProperty("administrativeAreaLevel1") + @get:Schema(description = PostalAddressDescription.administrativeAreaLevel1) + val administrativeAreaLevel1Verbose: RegionDto?, + override val postalCode: String?, override val city: String, override val deliveryServiceType: DeliveryServiceType, @@ -43,11 +52,12 @@ data class AlternativePostalAddressVerboseDto( override val deliveryServiceNumber: String ) : IBaseAlternativePostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1?.regionCode - } - override fun countryCode(): CountryCode { - return country.technicalKey - } -} + @get:JsonIgnore + override val country: CountryCode + get() = countryVerbose.technicalKey + + @get:JsonIgnore + override val administrativeAreaLevel1: String? + get() = administrativeAreaLevel1Verbose?.regionCode +} diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressDto.kt index 52d8ed0c1..d8d703f4d 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressDto.kt @@ -46,12 +46,4 @@ data class PhysicalPostalAddressDto( override val floor: String?, override val door: String? -) : IBasePhysicalPostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1 - } - - override fun countryCode(): CountryCode { - return country - } -} +) : IBasePhysicalPostalAddressDto diff --git a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressVerboseDto.kt b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressVerboseDto.kt index cec5f7cfd..4eb72fec0 100644 --- a/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressVerboseDto.kt +++ b/bpdm-pool-api/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/api/model/PhysicalPostalAddressVerboseDto.kt @@ -19,6 +19,8 @@ package org.eclipse.tractusx.bpdm.pool.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.annotation.JsonDeserialize import com.neovisionaries.i18n.CountryCode import io.swagger.v3.oas.annotations.media.Schema @@ -33,8 +35,15 @@ import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializ data class PhysicalPostalAddressVerboseDto( override val geographicCoordinates: GeoCoordinateDto?, - override val country: TypeKeyNameVerboseDto, - override val administrativeAreaLevel1: RegionDto?, + + @field:JsonProperty("country") + @get:Schema(description = PostalAddressDescription.country) + val countryVerbose: TypeKeyNameVerboseDto, + + @field:JsonProperty("administrativeAreaLevel1") + @get:Schema(description = PostalAddressDescription.administrativeAreaLevel1) + val administrativeAreaLevel1Verbose: RegionDto?, + override val administrativeAreaLevel2: String?, override val administrativeAreaLevel3: String?, override val postalCode: String?, @@ -48,11 +57,12 @@ data class PhysicalPostalAddressVerboseDto( override val door: String? ) : IBasePhysicalPostalAddressDto { - override fun adminLevel1Key(): String? { - return administrativeAreaLevel1?.regionCode - } - override fun countryCode(): CountryCode { - return country.technicalKey - } + @get:JsonIgnore + override val country: CountryCode + get() = countryVerbose.technicalKey + + @get:JsonIgnore + override val administrativeAreaLevel1: String? + get() = administrativeAreaLevel1Verbose?.regionCode } 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 a5995e5c4..bd5e01a52 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 @@ -538,13 +538,13 @@ class BusinessPartnerBuildService( fun createPhysicalAddress(physicalAddress: IBasePhysicalPostalAddressDto, regions: Map): PhysicalPostalAddress { - if (physicalAddress.countryCode() == null || physicalAddress.city == null) { + if (physicalAddress.country == null || physicalAddress.city == null) { throw BpdmValidationException(TaskStepBuildService.CleaningError.COUNTRY_CITY_IS_NULL.message) } return PhysicalPostalAddress( geographicCoordinates = physicalAddress.geographicCoordinates?.let { GeographicCoordinate(it.latitude, it.longitude, it.altitude) }, - country = physicalAddress.countryCode()!!, + country = physicalAddress.country!!, administrativeAreaLevel1 = regions[physicalAddress.administrativeAreaLevel1], administrativeAreaLevel2 = physicalAddress.administrativeAreaLevel2, administrativeAreaLevel3 = physicalAddress.administrativeAreaLevel3, @@ -569,7 +569,7 @@ class BusinessPartnerBuildService( fun createAlternativeAddress(alternativeAddress: IBaseAlternativePostalAddressDto, regions: Map): AlternativePostalAddress { - if (alternativeAddress.countryCode() == null || alternativeAddress.city == null || + if (alternativeAddress.country == null || alternativeAddress.city == null || alternativeAddress.deliveryServiceType == null || alternativeAddress.deliveryServiceNumber == null ) { @@ -578,7 +578,7 @@ class BusinessPartnerBuildService( return AlternativePostalAddress( geographicCoordinates = alternativeAddress.geographicCoordinates?.let { GeographicCoordinate(it.latitude, it.longitude, it.altitude) }, - country = alternativeAddress.countryCode()!!, + country = alternativeAddress.country!!, administrativeAreaLevel1 = regions[alternativeAddress.administrativeAreaLevel1], postCode = alternativeAddress.postalCode, city = alternativeAddress.city!!, diff --git a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt index a3b8e0e2e..ef3bf9994 100644 --- a/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt +++ b/bpdm-pool/src/main/kotlin/org/eclipse/tractusx/bpdm/pool/service/MetadataService.kt @@ -155,8 +155,8 @@ class MetadataService( val idTypeKeys = requests.flatMap { it.identifiers }.map { it.type }.toSet() val idTypes = identifierTypeRepository.findByBusinessPartnerTypeAndTechnicalKeyIn(IdentifierBusinessPartnerType.ADDRESS, idTypeKeys) - val regionKeys = requests.mapNotNull { it.physicalPostalAddress?.adminLevel1Key() } - .plus(requests.mapNotNull { it.alternativePostalAddress?.adminLevel1Key() }) + val regionKeys = requests.mapNotNull { it.physicalPostalAddress?.administrativeAreaLevel1 } + .plus(requests.mapNotNull { it.alternativePostalAddress?.administrativeAreaLevel1 }) .toSet() val regions = regionRepository.findByRegionCodeIn(regionKeys) @@ -165,8 +165,8 @@ class MetadataService( fun getRegions(requests: Collection): Set { - val regionKeys = requests.mapNotNull { it.physicalPostalAddress?.adminLevel1Key() } - .plus(requests.mapNotNull { it.alternativePostalAddress?.adminLevel1Key() }) + val regionKeys = requests.mapNotNull { it.physicalPostalAddress?.administrativeAreaLevel1 } + .plus(requests.mapNotNull { it.alternativePostalAddress?.administrativeAreaLevel1 }) .toSet() val regions = regionRepository.findByRegionCodeIn(regionKeys) return regions 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 5e0a82a0c..1b91fa3e9 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 @@ -145,10 +145,10 @@ fun LogisticAddress.toMainAddressResponse(): MainAddressVerboseDto { fun PhysicalPostalAddress.toDto(): PhysicalPostalAddressVerboseDto { return PhysicalPostalAddressVerboseDto( geographicCoordinates = geographicCoordinates?.toDto(), - country = country.toDto(), + countryVerbose = country.toDto(), postalCode = postCode, city = city, - administrativeAreaLevel1 = administrativeAreaLevel1?.let { RegionDto(it.countryCode, it.regionCode, it.regionName) }, + administrativeAreaLevel1Verbose = administrativeAreaLevel1?.let { RegionDto(it.countryCode, it.regionCode, it.regionName) }, administrativeAreaLevel2 = administrativeAreaLevel2, administrativeAreaLevel3 = administrativeAreaLevel3, district = districtLevel1, @@ -164,10 +164,10 @@ fun PhysicalPostalAddress.toDto(): PhysicalPostalAddressVerboseDto { fun AlternativePostalAddress.toDto(): AlternativePostalAddressVerboseDto { return AlternativePostalAddressVerboseDto( geographicCoordinates = geographicCoordinates?.toDto(), - country = country.toDto(), + countryVerbose = country.toDto(), postalCode = postCode, city = city, - administrativeAreaLevel1 = administrativeAreaLevel1?.let { RegionDto(it.countryCode, it.regionCode, it.regionName) }, + administrativeAreaLevel1Verbose = administrativeAreaLevel1?.let { RegionDto(it.countryCode, it.regionCode, it.regionName) }, deliveryServiceType = deliveryServiceType, deliveryServiceNumber = deliveryServiceNumber, deliveryServiceQualifier = deliveryServiceQualifier diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt index 61362e12f..b44659ad5 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/service/TaskStepFetchAndReserveServiceTest.kt @@ -550,17 +550,17 @@ class TaskStepFetchAndReserveServiceTest @Autowired constructor( val verbosePhysicalAddress = verboseAddress.physicalPostalAddress val physicalAddress = address?.physicalPostalAddress assertThat(verbosePhysicalAddress).usingRecursiveComparison() - .ignoringFields("country", "administrativeAreaLevel1") + .ignoringFields("countryVerbose", "administrativeAreaLevel1Verbose") .isEqualTo(physicalAddress) - assertThat(verbosePhysicalAddress.country.technicalKey.name).isEqualTo(physicalAddress?.country?.name) - assertThat(verbosePhysicalAddress.administrativeAreaLevel1?.regionCode).isEqualTo(physicalAddress?.administrativeAreaLevel1) + assertThat(verbosePhysicalAddress.country.name).isEqualTo(physicalAddress?.country?.name) + assertThat(verbosePhysicalAddress.administrativeAreaLevel1).isEqualTo(physicalAddress?.administrativeAreaLevel1) val verboseAlternAddress = verboseAddress.alternativePostalAddress val alternAddress = address?.alternativePostalAddress assertThat(verboseAlternAddress).usingRecursiveComparison() - .ignoringFields("country", "administrativeAreaLevel1") + .ignoringFields("countryVerbose", "administrativeAreaLevel1Verbose") .isEqualTo(alternAddress) - assertThat(verboseAlternAddress?.country?.technicalKey?.name).isEqualTo(alternAddress?.country?.name) - assertThat(verboseAlternAddress?.administrativeAreaLevel1?.regionCode).isEqualTo(alternAddress?.administrativeAreaLevel1) + assertThat(verboseAlternAddress?.country?.name).isEqualTo(alternAddress?.country?.name) + assertThat(verboseAlternAddress?.administrativeAreaLevel1).isEqualTo(alternAddress?.administrativeAreaLevel1) } fun compareAddressStates(statesVerbose: Collection, states: Collection?) { diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerNonVerboseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerNonVerboseValues.kt index 0da145446..e0ebad69f 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerNonVerboseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerNonVerboseValues.kt @@ -146,7 +146,7 @@ object BusinessPartnerNonVerboseValues { private val postalAddress1 = PhysicalPostalAddressDto( geographicCoordinates = BusinessPartnerVerboseValues.address1.geographicCoordinates, - country = BusinessPartnerVerboseValues.address1.country.technicalKey, + country = BusinessPartnerVerboseValues.address1.country, postalCode = BusinessPartnerVerboseValues.address1.postalCode, city = BusinessPartnerVerboseValues.address1.city, administrativeAreaLevel1 = BusinessPartnerVerboseValues.address1.administrativeAreaLevel1?.toString(), @@ -163,7 +163,7 @@ object BusinessPartnerNonVerboseValues { private val postalAddress2 = PhysicalPostalAddressDto( geographicCoordinates = BusinessPartnerVerboseValues.address2.geographicCoordinates, - country = BusinessPartnerVerboseValues.address2.country.technicalKey, + country = BusinessPartnerVerboseValues.address2.country, postalCode = BusinessPartnerVerboseValues.address2.postalCode, city = BusinessPartnerVerboseValues.address2.city, administrativeAreaLevel1 = BusinessPartnerVerboseValues.address2.administrativeAreaLevel1?.toString(), @@ -180,7 +180,7 @@ object BusinessPartnerNonVerboseValues { private val postalAddress3 = PhysicalPostalAddressDto( geographicCoordinates = BusinessPartnerVerboseValues.address3.geographicCoordinates, - country = BusinessPartnerVerboseValues.address3.country.technicalKey, + country = BusinessPartnerVerboseValues.address3.country, postalCode = BusinessPartnerVerboseValues.address3.postalCode, city = BusinessPartnerVerboseValues.address3.city, administrativeAreaLevel1 = BusinessPartnerVerboseValues.address3.administrativeAreaLevel1?.toString(), diff --git a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt index e03cf0131..f8071faf6 100644 --- a/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt +++ b/bpdm-pool/src/test/kotlin/org/eclipse/tractusx/bpdm/pool/util/BusinessPartnerVerboseValues.kt @@ -99,10 +99,10 @@ object BusinessPartnerVerboseValues { val address1 = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country1, + countryVerbose = country1, postalCode = "71059 ", city = "Böblingen", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = "Böblingen", administrativeAreaLevel3 = null, district = "Sindelfingen-Ost", @@ -116,10 +116,10 @@ object BusinessPartnerVerboseValues { val address2 = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country2, + countryVerbose = country2, postalCode = "70547", city = "Atlanta", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = " Fulton County", administrativeAreaLevel3 = null, district = "District Level 1", @@ -133,10 +133,10 @@ object BusinessPartnerVerboseValues { val address3 = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country3, + countryVerbose = country3, postalCode = "30346", city = "Atlanta", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = " Fulton County", administrativeAreaLevel3 = null, district = "DL 1", @@ -261,10 +261,10 @@ object BusinessPartnerVerboseValues { bpna = "BPNA000000000001", physicalPostalAddress = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country1, + countryVerbose = country1, postalCode = null, city = "Stuttgart", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = null, administrativeAreaLevel3 = null, district = null, @@ -298,10 +298,10 @@ object BusinessPartnerVerboseValues { bpna = "BPNA000000000001", physicalPostalAddress = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country2, + countryVerbose = country2, postalCode = null, city = "5th Congressional District", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = null, administrativeAreaLevel3 = null, district = null, @@ -335,10 +335,10 @@ object BusinessPartnerVerboseValues { bpna = "BPNA000000000001", physicalPostalAddress = PhysicalPostalAddressVerboseDto( geographicCoordinates = null, - country = country3, + countryVerbose = country3, postalCode = null, city = "北京市", - administrativeAreaLevel1 = null, + administrativeAreaLevel1Verbose = null, administrativeAreaLevel2 = null, administrativeAreaLevel3 = null, district = null,