From 30751a7b51be445d3ba7f85de8e6564a6c089dde Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Wed, 13 Dec 2023 16:05:57 +0800 Subject: [PATCH] feat(Gate): separate L/S/A attributes in generic business partner model --- .../api/model/IBaseBusinessPartnerGateDto.kt | 74 ++++++++ .../request/BusinessPartnerInputRequest.kt | 18 +- .../request/BusinessPartnerOutputRequest.kt | 48 ----- ...rtnerInputDto.kt => BusinessPartnerDto.kt} | 35 ++-- .../response/BusinessPartnerOutputDto.kt | 46 +++-- .../gate/service/BusinessPartnerMappings.kt | 149 ++++++++-------- .../gate/service/BusinessPartnerService.kt | 10 +- .../controller/BusinessPartnerControllerIT.kt | 96 ++++------ .../util/BusinessPartnerNonVerboseValues.kt | 12 +- .../gate/util/BusinessPartnerVerboseValues.kt | 164 +++++++++++------- 10 files changed, 352 insertions(+), 300 deletions(-) delete mode 100644 bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt rename bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/{BusinessPartnerInputDto.kt => BusinessPartnerDto.kt} (65%) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt index 54f7116d1..6b5d4d2c2 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/IBaseBusinessPartnerGateDto.kt @@ -19,8 +19,12 @@ package org.eclipse.tractusx.bpdm.gate.api.model +import com.fasterxml.jackson.annotation.JsonIgnore +import io.swagger.v3.oas.annotations.media.ArraySchema import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerDto +import org.eclipse.tractusx.bpdm.common.dto.IBaseBusinessPartnerPostalAddressDto +import org.eclipse.tractusx.bpdm.common.dto.IBusinessPartnerClassificationDto import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription interface IBaseBusinessPartnerGateDto : IBaseBusinessPartnerDto { @@ -30,4 +34,74 @@ interface IBaseBusinessPartnerGateDto : IBaseBusinessPartnerDto { @get:Schema(description = "True if the sharing member declares itself as the owner of the business partner.") val isOwnCompanyData: Boolean + + val legalEntity: IBaseLegalEntityComponent + + val site: IBaseSiteComponent + + val address: IBaseAddressComponent + + // Overrides to satisfy the base class but will be not shown on API level. + // That way we inherit from the base but keep the Gate model changes separate from now + // ToDo: Once all other BPDM module models are adapted, update the Base Interface and delete the overrides + + override val legalEntityBpn: String? + @JsonIgnore + get() = legalEntity.bpnL + + override val legalName: String? + @JsonIgnore + get() = legalEntity.legalName + + override val shortName: String? + @JsonIgnore + get() = legalEntity.shortName + + override val legalForm: String? + @JsonIgnore + get() = legalEntity.legalForm + + override val classifications: Collection + @JsonIgnore + get() = legalEntity.classifications + + override val siteBpn: String? + @JsonIgnore + get() = site.bpnS + + override val addressBpn: String? + @JsonIgnore + get() = address.bpnA + + override val postalAddress: IBaseBusinessPartnerPostalAddressDto + @JsonIgnore + get() = address } + +interface IBaseLegalEntityComponent { + + @get:Schema(description = "BPNL of the golden record legal entity this business partner refers to") + val bpnL: String? + + @get:Schema(description = "The name according to official registers.") + val legalName: String? + + @get:Schema(description = "Abbreviated name or shorthand.") + val shortName: String? + + @get:Schema(description = "Technical key of the legal form.") + val legalForm: String? + + @get:ArraySchema(arraySchema = Schema(description = "The list of classifications of the business partner, such as a specific industry. Sorted and duplicates removed by the service.")) + val classifications: Collection +} + +interface IBaseSiteComponent { + @get:Schema(description = "BPNS of the golden record site this business partner refers to") + val bpnS: String? +} + +interface IBaseAddressComponent : IBaseBusinessPartnerPostalAddressDto { + @get:Schema(description = "BPNA of the golden record address this business partner refers to") + val bpnA: String? +} \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt index 03447caaa..2e112d39e 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerInputRequest.kt @@ -21,7 +21,12 @@ package org.eclipse.tractusx.bpdm.gate.api.model.request import io.swagger.v3.oas.annotations.media.Schema import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.gate.api.model.* +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerIdentifierDto +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerStateDto +import org.eclipse.tractusx.bpdm.gate.api.model.IBaseBusinessPartnerGateDto +import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressComponentInputDto +import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityComponentInputDto +import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteComponentInputDto @Schema( description = "Generic business partner with external id", @@ -31,17 +36,12 @@ data class BusinessPartnerInputRequest( override val externalId: String, override val nameParts: List = emptyList(), - override val shortName: String? = null, override val identifiers: Collection = emptyList(), - override val legalName: String? = null, - override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), - override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), override val isOwnCompanyData: Boolean = false, - override val legalEntityBpn: String? = null, - override val siteBpn: String? = null, - override val addressBpn: String? = null + override val legalEntity: LegalEntityComponentInputDto = LegalEntityComponentInputDto(), + override val site: SiteComponentInputDto = SiteComponentInputDto(), + override val address: AddressComponentInputDto = AddressComponentInputDto() ) : IBaseBusinessPartnerGateDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt deleted file mode 100644 index 1a1666b98..000000000 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/BusinessPartnerOutputRequest.kt +++ /dev/null @@ -1,48 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2021,2023 Contributors to the Eclipse Foundation - * - * See the NOTICE file(s) distributed with this work for additional - * information regarding copyright ownership. - * - * This program and the accompanying materials are made available under the - * terms of the Apache License, Version 2.0 which is available at - * https://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - * SPDX-License-Identifier: Apache-2.0 - ******************************************************************************/ - -package org.eclipse.tractusx.bpdm.gate.api.model.request - -import io.swagger.v3.oas.annotations.media.Schema -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole -import org.eclipse.tractusx.bpdm.gate.api.model.* - - -@Schema( - description = "Generic business partner with external id", - requiredProperties = ["externalId"] -) -data class BusinessPartnerOutputRequest( - - override val externalId: String, - override val nameParts: List = emptyList(), - override val shortName: String? = null, - override val identifiers: Collection = emptyList(), - override val legalName: String? = null, - override val legalForm: String? = null, - override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), - override val roles: Collection = emptyList(), - override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(), - override val isOwnCompanyData: Boolean = false, - override val legalEntityBpn: String? = null, - override val siteBpn: String? = null, - override val addressBpn: String? = null - -) : IBaseBusinessPartnerGateDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerDto.kt similarity index 65% rename from bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerDto.kt index 2533140c5..02a76b43c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerInputDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerDto.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription import org.eclipse.tractusx.bpdm.gate.api.model.* @@ -28,24 +29,19 @@ import java.time.Instant @Schema( description = "Generic business partner with external id", - requiredProperties = ["externalId", "postalAddress"] + requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"] ) data class BusinessPartnerInputDto( override val externalId: String, override val nameParts: List = emptyList(), - override val shortName: String?, override val identifiers: Collection = emptyList(), - override val legalName: String? = null, - override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), - override val postalAddress: BusinessPartnerPostalAddressDto, - override val isOwnCompanyData: Boolean, - override val legalEntityBpn: String?, - override val siteBpn: String?, - override val addressBpn: String?, + override val isOwnCompanyData: Boolean = false, + override val legalEntity: LegalEntityComponentInputDto = LegalEntityComponentInputDto(), + override val site: SiteComponentInputDto = SiteComponentInputDto(), + override val address: AddressComponentInputDto = AddressComponentInputDto(), @get:Schema(description = CommonDescription.createdAt) val createdAt: Instant, @@ -54,3 +50,22 @@ data class BusinessPartnerInputDto( val updatedAt: Instant ) : IBaseBusinessPartnerGateDto + +data class LegalEntityComponentInputDto( + override val bpnL: String? = null, + override val legalName: String? = null, + override val shortName: String? = null, + override val legalForm: String? = null, + override val classifications: Collection = emptyList() +) : IBaseLegalEntityComponent + +data class SiteComponentInputDto( + override val bpnS: String? = null +) : IBaseSiteComponent + +data class AddressComponentInputDto( + override val bpnA: String? = null, + override val addressType: AddressType? = null, + override val physicalPostalAddress: PhysicalPostalAddressDto = PhysicalPostalAddressDto(), + override val alternativePostalAddress: AlternativePostalAddressDto = AlternativePostalAddressDto() +) : IBaseAddressComponent \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt index fbb2470c8..dbf4bd12c 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/response/BusinessPartnerOutputDto.kt @@ -20,6 +20,7 @@ package org.eclipse.tractusx.bpdm.gate.api.model.response import io.swagger.v3.oas.annotations.media.Schema +import org.eclipse.tractusx.bpdm.common.dto.AddressType import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerRole import org.eclipse.tractusx.bpdm.common.dto.openapidescription.CommonDescription import org.eclipse.tractusx.bpdm.gate.api.model.* @@ -27,24 +28,19 @@ import java.time.Instant @Schema( description = "Generic business partner output with external id", - requiredProperties = ["externalId", "postalAddress", "bpnL", "bpnA"] + requiredProperties = ["externalId"] ) data class BusinessPartnerOutputDto( override val externalId: String, override val nameParts: List = emptyList(), - override val shortName: String?, override val identifiers: Collection = emptyList(), - override val legalName: String? = null, - override val legalForm: String? = null, override val states: Collection = emptyList(), - override val classifications: Collection = emptyList(), override val roles: Collection = emptyList(), - override val postalAddress: BusinessPartnerPostalAddressDto, - override val isOwnCompanyData: Boolean, - override val legalEntityBpn: String, - override val siteBpn: String?, - override val addressBpn: String, + override val isOwnCompanyData: Boolean = false, + override val legalEntity: LegalEntityComponentOutputDto, + override val site: SiteComponentOutputDto = SiteComponentOutputDto(), + override val address: AddressComponentOutputDto, @get:Schema(description = CommonDescription.createdAt) val createdAt: Instant, @@ -53,3 +49,33 @@ data class BusinessPartnerOutputDto( val updatedAt: Instant ) : IBaseBusinessPartnerGateDto + +@Schema( + description = "Legal Entity properties of business partner output data", + requiredProperties = ["bpnL"] +) +data class LegalEntityComponentOutputDto( + override val bpnL: String, + override val legalName: String? = null, + override val shortName: String? = null, + override val legalForm: String? = null, + override val classifications: Collection = emptyList() +) : IBaseLegalEntityComponent + +@Schema( + description = "Site properties of business partner output data" +) +data class SiteComponentOutputDto( + override val bpnS: String? = null +) : IBaseSiteComponent + +@Schema( + description = "Address properties of business partner output data", + requiredProperties = ["bpnA"] +) +data class AddressComponentOutputDto( + override val bpnA: String, + override val addressType: AddressType? = null, + override val physicalPostalAddress: PhysicalPostalAddressDto = PhysicalPostalAddressDto(), + override val alternativePostalAddress: AlternativePostalAddressDto = AlternativePostalAddressDto() +) : IBaseAddressComponent diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt index 301e89f27..62dd1f938 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerMappings.kt @@ -19,15 +19,13 @@ package org.eclipse.tractusx.bpdm.gate.service -import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType + import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto import org.eclipse.tractusx.bpdm.common.exception.BpdmNullMappingException import org.eclipse.tractusx.bpdm.common.model.StageType import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto -import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto +import org.eclipse.tractusx.bpdm.gate.api.model.response.* import org.eclipse.tractusx.bpdm.gate.entity.AlternativePostalAddress import org.eclipse.tractusx.bpdm.gate.entity.GeographicCoordinate import org.eclipse.tractusx.bpdm.gate.entity.PhysicalPostalAddress @@ -42,18 +40,13 @@ class BusinessPartnerMappings { return BusinessPartnerInputDto( externalId = entity.externalId, nameParts = entity.nameParts, - shortName = entity.shortName, identifiers = entity.identifiers.map(::toIdentifierDto), - legalName = entity.legalName, - legalForm = entity.legalForm, states = entity.states.map(::toStateDto), - classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, - postalAddress = toPostalAddressDto(entity.postalAddress), isOwnCompanyData = entity.isOwnCompanyData, - legalEntityBpn = entity.bpnL, - siteBpn = entity.bpnS, - addressBpn = entity.bpnA, + legalEntity = toLegalEntityComponentInputDto(entity), + site = toSiteComponentInputDto(entity), + address = toAddressComponentInputDto(entity), createdAt = entity.createdAt, updatedAt = entity.updatedAt ) @@ -63,20 +56,13 @@ class BusinessPartnerMappings { return BusinessPartnerOutputDto( externalId = entity.externalId, nameParts = entity.nameParts, - shortName = entity.shortName, identifiers = entity.identifiers.map(::toIdentifierDto), - legalName = entity.legalName, - legalForm = entity.legalForm, states = entity.states.map(::toStateDto), - classifications = entity.classifications.map(::toClassificationDto), roles = entity.roles, - postalAddress = toPostalAddressDto(entity.postalAddress), isOwnCompanyData = entity.isOwnCompanyData, - legalEntityBpn = entity.bpnL - ?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnL, entity.externalId), - siteBpn = entity.bpnS, - addressBpn = entity.bpnA - ?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnA, entity.externalId), + legalEntity = toLegalEntityComponentOutputDto(entity), + site = toSiteComponentOutputDto(entity), + address = toAddressComponentOutputDto(entity), createdAt = entity.createdAt, updatedAt = entity.updatedAt ) @@ -90,75 +76,86 @@ class BusinessPartnerMappings { roles = dto.roles.toSortedSet(), identifiers = dto.identifiers.mapNotNull(::toIdentifier).toSortedSet(), states = dto.states.mapNotNull(::toState).toSortedSet(), - classifications = dto.classifications.mapNotNull(::toClassification).toSortedSet(), - shortName = dto.shortName, - legalName = dto.legalName, - legalForm = dto.legalForm, + classifications = dto.legalEntity.classifications.mapNotNull(::toClassification).toSortedSet(), + shortName = dto.legalEntity.shortName, + legalName = dto.legalEntity.legalName, + legalForm = dto.legalEntity.legalForm, isOwnCompanyData = dto.isOwnCompanyData, - bpnL = dto.legalEntityBpn, - bpnS = dto.siteBpn, - bpnA = dto.addressBpn, - postalAddress = toPostalAddress(dto.postalAddress), - parentId = null, - parentType = null, + bpnL = dto.legalEntity.bpnL, + bpnS = dto.site.bpnS, + bpnA = dto.address.bpnA, + postalAddress = toPostalAddress(dto.address) ) } - //Output - fun toBusinessPartnerOutput(dto: BusinessPartnerOutputRequest): BusinessPartner { - return BusinessPartner( - stage = StageType.Output, - externalId = dto.externalId, - nameParts = dto.nameParts.toMutableList(), - roles = dto.roles.toSortedSet(), - identifiers = dto.identifiers.mapNotNull(::toIdentifier).toSortedSet(), - states = dto.states.mapNotNull(::toState).toSortedSet(), - classifications = dto.classifications.mapNotNull(::toClassification).toSortedSet(), - shortName = dto.shortName, - legalName = dto.legalName, - legalForm = dto.legalForm, - isOwnCompanyData = dto.isOwnCompanyData, - bpnL = dto.legalEntityBpn, - bpnS = dto.siteBpn, - bpnA = dto.addressBpn, - parentId = null, - parentType = BusinessPartnerType.GENERIC, - postalAddress = toPostalAddress(dto.postalAddress) + private fun toLegalEntityComponentInputDto(entity: BusinessPartner): LegalEntityComponentInputDto { + return LegalEntityComponentInputDto( + bpnL = entity.bpnL, + legalName = entity.legalName, + shortName = entity.shortName, + legalForm = entity.legalForm, + classifications = entity.classifications.map(::toClassificationDto) ) } - private fun toPostalAddressDto(entity: PostalAddress) = - BusinessPartnerPostalAddressDto( - addressType = entity.addressType, - physicalPostalAddress = entity.physicalPostalAddress?.let(::toPhysicalPostalAddressDto), - alternativePostalAddress = entity.alternativePostalAddress?.let(::toAlternativePostalAddressDto) + private fun toSiteComponentInputDto(entity: BusinessPartner): SiteComponentInputDto { + return SiteComponentInputDto( + bpnS = entity.bpnS ) + } + + private fun toAddressComponentInputDto(entity: BusinessPartner): AddressComponentInputDto { + return AddressComponentInputDto( + bpnA = entity.bpnA, + addressType = entity.postalAddress.addressType, + physicalPostalAddress = entity.postalAddress.physicalPostalAddress?.toPhysicalPostalAddress() ?: PhysicalPostalAddressDto(), + alternativePostalAddress = entity.postalAddress.alternativePostalAddress?.toAlternativePostalAddressDto() ?: AlternativePostalAddressDto() + ) + } - private fun toPostalAddress(dto: BusinessPartnerPostalAddressDto) = + private fun toLegalEntityComponentOutputDto(entity: BusinessPartner): LegalEntityComponentOutputDto { + return LegalEntityComponentOutputDto( + bpnL = entity.bpnL ?: throw BpdmNullMappingException( + BusinessPartner::class, + BusinessPartnerOutputDto::class, + BusinessPartner::bpnL, + entity.externalId + ), + legalName = entity.legalName, + shortName = entity.shortName, + legalForm = entity.legalForm, + classifications = entity.classifications.map(::toClassificationDto) + ) + } + + private fun toSiteComponentOutputDto(entity: BusinessPartner): SiteComponentOutputDto { + return SiteComponentOutputDto( + bpnS = entity.bpnS + ) + } + + private fun toAddressComponentOutputDto(entity: BusinessPartner): AddressComponentOutputDto { + return AddressComponentOutputDto( + bpnA = entity.bpnA ?: throw BpdmNullMappingException( + BusinessPartner::class, + BusinessPartnerOutputDto::class, + BusinessPartner::bpnA, + entity.externalId + ), + addressType = entity.postalAddress.addressType, + physicalPostalAddress = entity.postalAddress.physicalPostalAddress?.toPhysicalPostalAddress() ?: PhysicalPostalAddressDto(), + alternativePostalAddress = entity.postalAddress.alternativePostalAddress?.toAlternativePostalAddressDto() ?: AlternativePostalAddressDto() + ) + } + + + private fun toPostalAddress(dto: AddressComponentInputDto) = PostalAddress( addressType = dto.addressType, physicalPostalAddress = normalize(dto.physicalPostalAddress)?.let(::toPhysicalPostalAddress), alternativePostalAddress = normalize(dto.alternativePostalAddress)?.let(::toAlternativePostalAddress) ) - private fun toPhysicalPostalAddressDto(entity: PhysicalPostalAddress) = - PhysicalPostalAddressDto( - geographicCoordinates = entity.geographicCoordinates?.let(::toGeoCoordinateDto), - country = entity.country, - administrativeAreaLevel1 = entity.administrativeAreaLevel1, - administrativeAreaLevel2 = entity.administrativeAreaLevel2, - administrativeAreaLevel3 = entity.administrativeAreaLevel3, - postalCode = entity.postalCode, - city = entity.city, - district = entity.district, - street = entity.street?.let(::toStreetDto), - companyPostalCode = entity.companyPostalCode, - industrialZone = entity.industrialZone, - building = entity.building, - floor = entity.floor, - door = entity.door - ) - // convert empty DTO to null private fun normalize(dto: PhysicalPostalAddressDto?) = if (dto != PhysicalPostalAddressDto()) dto diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt index d20e13fb8..9973d299a 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/BusinessPartnerService.kt @@ -21,8 +21,8 @@ package org.eclipse.tractusx.bpdm.gate.service import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType -import org.eclipse.tractusx.bpdm.common.dto.PaginationRequest import org.eclipse.tractusx.bpdm.common.dto.PageDto +import org.eclipse.tractusx.bpdm.common.dto.PaginationRequest import org.eclipse.tractusx.bpdm.common.model.StageType import org.eclipse.tractusx.bpdm.common.service.toPageDto import org.eclipse.tractusx.bpdm.common.util.copyAndSync @@ -31,7 +31,6 @@ import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError import org.eclipse.tractusx.bpdm.gate.api.model.ChangelogType import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto import org.eclipse.tractusx.bpdm.gate.config.PoolConfigProperties @@ -77,13 +76,6 @@ class BusinessPartnerService( return upsertBusinessPartnersInputFromCandidates(validatedEntities).map(businessPartnerMappings::toBusinessPartnerInputDto) } - @Transactional - fun upsertBusinessPartnersOutput(dtos: Collection): Collection { - logger.debug { "Executing upsertBusinessPartnersOutput() with parameters $dtos" } - val entities = dtos.map { dto -> businessPartnerMappings.toBusinessPartnerOutput(dto) } - return upsertBusinessPartnersOutputFromCandidates(entities).map(businessPartnerMappings::toBusinessPartnerOutputDto) - } - fun getBusinessPartnersInput(pageRequest: PageRequest, externalIds: Collection?): PageDto { logger.debug { "Executing getBusinessPartnersInput() with parameters $pageRequest and $externalIds" } val stage = StageType.Input diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt index 0da277231..b80a6141d 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerIT.kt @@ -24,8 +24,9 @@ import com.github.tomakehurst.wiremock.client.WireMock import com.github.tomakehurst.wiremock.core.WireMockConfiguration import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions -import org.eclipse.tractusx.bpdm.common.dto.* -import org.eclipse.tractusx.bpdm.common.exception.BpdmNullMappingException +import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType +import org.eclipse.tractusx.bpdm.common.dto.PageDto +import org.eclipse.tractusx.bpdm.common.dto.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.BusinessPartnerSharingError import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerClassificationDto @@ -33,11 +34,9 @@ import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerIdentifierDto import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerStateDto import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerInputDto import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto import org.eclipse.tractusx.bpdm.gate.api.model.response.SharingStateDto -import org.eclipse.tractusx.bpdm.gate.entity.generic.BusinessPartner import org.eclipse.tractusx.bpdm.gate.service.BusinessPartnerService import org.eclipse.tractusx.bpdm.gate.util.* import org.eclipse.tractusx.bpdm.pool.api.model.ChangelogType @@ -236,9 +235,9 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `query business partners by externalId`() { val upsertRequests = listOf( - BusinessPartnerNonVerboseValues.bpInputRequestFull.copy(externalId = BusinessPartnerVerboseValues.externalId1, shortName = "1"), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") + BusinessPartnerNonVerboseValues.bpInputRequestFull.fastCopy(externalId = BusinessPartnerVerboseValues.externalId1, shortName = "1"), + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") ) gateClient.businessParters.upsertBusinessPartnersInput(upsertRequests) @@ -250,9 +249,9 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `query business partners by missing externalId`() { val upsertRequests = listOf( - BusinessPartnerNonVerboseValues.bpInputRequestFull.copy(externalId = BusinessPartnerVerboseValues.externalId1, shortName = "1"), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") + BusinessPartnerNonVerboseValues.bpInputRequestFull.fastCopy(externalId = BusinessPartnerVerboseValues.externalId1, shortName = "1"), + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") ) gateClient.businessParters.upsertBusinessPartnersInput(upsertRequests) @@ -265,12 +264,12 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `query business partners using paging`() { val upsertRequests = listOf( - BusinessPartnerNonVerboseValues.bpInputRequestFull.copy( + BusinessPartnerNonVerboseValues.bpInputRequestFull.fastCopy( externalId = BusinessPartnerNonVerboseValues.bpInputRequestFull.externalId, shortName = "1" ), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), - BusinessPartnerNonVerboseValues.bpInputRequestMinimal.copy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId2, shortName = "2"), + BusinessPartnerNonVerboseValues.bpInputRequestMinimal.fastCopy(externalId = BusinessPartnerVerboseValues.externalId3, shortName = "3") ) gateClient.businessParters.upsertBusinessPartnersInput(upsertRequests) @@ -298,62 +297,18 @@ class BusinessPartnerControllerIT @Autowired constructor( .isEqualTo(requests.map(::toExpectedResponse)) } - private fun assertUpsertOutputResponsesMatchRequests(responses: Collection, requests: List) { - Assertions.assertThat(responses) - .usingRecursiveComparison() - .ignoringFieldsOfTypes(Instant::class.java) - .isEqualTo(requests.map(::toExpectedResponseOutput)) - } - private fun toExpectedResponse(request: BusinessPartnerInputRequest): BusinessPartnerInputDto { // same sorting order as defined for entity return BusinessPartnerInputDto( externalId = request.externalId, nameParts = request.nameParts, - shortName = request.shortName, identifiers = request.identifiers.toSortedSet(identifierDtoComparator), - legalName = request.legalName, - legalForm = request.legalForm, states = request.states.toSortedSet(stateDtoComparator), - classifications = request.classifications.toSortedSet(classificationDtoComparator), roles = request.roles.toSortedSet(), - postalAddress = request.postalAddress, isOwnCompanyData = request.isOwnCompanyData, - legalEntityBpn = request.legalEntityBpn, - siteBpn = request.siteBpn, - addressBpn = request.addressBpn, - createdAt = Instant.now(), - updatedAt = Instant.now() - ) - } - - private fun toExpectedResponseOutput(request: BusinessPartnerOutputRequest): BusinessPartnerOutputDto { - // same sorting order as defined for entity - return BusinessPartnerOutputDto( - externalId = request.externalId, - nameParts = request.nameParts, - shortName = request.shortName, - identifiers = request.identifiers.toSortedSet(identifierDtoComparator), - legalName = request.legalName, - legalForm = request.legalForm, - states = request.states.toSortedSet(stateDtoComparator), - classifications = request.classifications.toSortedSet(classificationDtoComparator), - roles = request.roles.toSortedSet(), - postalAddress = request.postalAddress, - isOwnCompanyData = request.isOwnCompanyData, - legalEntityBpn = request.legalEntityBpn ?: throw BpdmNullMappingException( - BusinessPartner::class, - BusinessPartnerOutputDto::class, - BusinessPartner::bpnL, - request.externalId - ), - siteBpn = request.siteBpn, - addressBpn = request.addressBpn ?: throw BpdmNullMappingException( - BusinessPartner::class, - BusinessPartnerOutputDto::class, - BusinessPartner::bpnA, - request.externalId - ), + legalEntity = request.legalEntity.copy(classifications = request.legalEntity.classifications.toSortedSet(classificationDtoComparator)), + site = request.site, + address = request.address, createdAt = Instant.now(), updatedAt = Instant.now() ) @@ -518,19 +473,19 @@ class BusinessPartnerControllerIT @Autowired constructor( contentSize = 3, content = listOf( ChangelogEntryVerboseDto( - bpn = BusinessPartnerNonVerboseValues.bpOutputRequestCleaned.legalEntityBpn!!, + bpn = BusinessPartnerVerboseValues.bpOutputDtoCleaned.legalEntity.bpnL, businessPartnerType = BusinessPartnerType.LEGAL_ENTITY, timestamp = Instant.now(), changelogType = ChangelogType.UPDATE ), ChangelogEntryVerboseDto( - bpn = BusinessPartnerNonVerboseValues.bpOutputRequestCleaned.addressBpn!!, + bpn = BusinessPartnerVerboseValues.bpOutputDtoCleaned.address.bpnA, businessPartnerType = BusinessPartnerType.ADDRESS, timestamp = Instant.now(), changelogType = ChangelogType.UPDATE ), ChangelogEntryVerboseDto( - bpn = BusinessPartnerNonVerboseValues.bpOutputRequestCleaned.siteBpn!!, + bpn = BusinessPartnerVerboseValues.bpOutputDtoCleaned.site.bpnS!!, businessPartnerType = BusinessPartnerType.SITE, timestamp = Instant.now(), changelogType = ChangelogType.UPDATE @@ -557,7 +512,7 @@ class BusinessPartnerControllerIT @Autowired constructor( this.mockOrchestratorApiCleaned() val outputBusinessPartners = listOf( - BusinessPartnerNonVerboseValues.bpOutputRequestCleaned + BusinessPartnerVerboseValues.bpOutputDtoCleaned ) val upsertRequests = listOf( @@ -702,7 +657,7 @@ class BusinessPartnerControllerIT @Autowired constructor( this.mockOrchestratorApiCleanedResponseSizeOne() val outputBusinessPartners = listOf( - BusinessPartnerNonVerboseValues.bpOutputRequestCleaned + BusinessPartnerVerboseValues.bpOutputDtoCleaned ) val upsertRequests = listOf( BusinessPartnerNonVerboseValues.bpInputRequestCleaned @@ -737,7 +692,16 @@ class BusinessPartnerControllerIT @Autowired constructor( //Assert that sharing state are created testHelpers.assertRecursively(upsertSharingStateResponses).ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}") .isEqualTo(upsertSharingStatesRequests) + } - + private fun assertUpsertOutputResponsesMatchRequests(responses: Collection, requests: List) { + Assertions.assertThat(responses) + .usingRecursiveComparison() + .ignoringCollectionOrder() + .ignoringFieldsOfTypes(Instant::class.java) + .isEqualTo(requests) } + + private fun BusinessPartnerInputRequest.fastCopy(externalId: String, shortName: String) = + copy(externalId = externalId, legalEntity = legalEntity.copy(shortName = shortName)) } diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerNonVerboseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerNonVerboseValues.kt index 7e205eb69..6a4d1d135 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerNonVerboseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerNonVerboseValues.kt @@ -21,22 +21,21 @@ package org.eclipse.tractusx.bpdm.gate.util import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateOutputChildRequest import org.eclipse.tractusx.bpdm.gate.api.model.AddressIdentifierDto -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerPostalAddressDto import org.eclipse.tractusx.bpdm.gate.api.model.request.* +import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressComponentInputDto object BusinessPartnerNonVerboseValues { val physicalAddressMinimal = BusinessPartnerVerboseValues.physicalAddressMinimal - val physicalAddressChina = BusinessPartnerVerboseValues.physicalAddressChina - - val bpPostalAddressInputDtoMinimal = BusinessPartnerPostalAddressDto( + val bpPostalAddressInputDtoMinimal = AddressComponentInputDto( addressType = null, physicalPostalAddress = physicalAddressMinimal ) val bpInputRequestMinimal = BusinessPartnerInputRequest( - externalId = BusinessPartnerVerboseValues.externalId2, postalAddress = bpPostalAddressInputDtoMinimal + externalId = BusinessPartnerVerboseValues.externalId2, + address = bpPostalAddressInputDtoMinimal ) val bpInputRequestFull = BusinessPartnerVerboseValues.bpInputRequestFull @@ -47,9 +46,6 @@ object BusinessPartnerNonVerboseValues { val bpInputRequestError = BusinessPartnerVerboseValues.bpInputRequestError - //Output Business Partner Test Values - val bpOutputRequestCleaned = BusinessPartnerVerboseValues.bpOutputRequestCleaned - val legalEntityGateInputRequest1 = LegalEntityGateInputRequest( legalEntity = BusinessPartnerVerboseValues.legalEntity1, legalAddress = BusinessPartnerVerboseValues.physicalAddress1, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt index 7b769484f..4b9fb7d08 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/BusinessPartnerVerboseValues.kt @@ -29,8 +29,8 @@ import org.eclipse.tractusx.bpdm.common.model.ClassificationType import org.eclipse.tractusx.bpdm.common.model.DeliveryServiceType import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.BusinessPartnerOutputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.* +import java.time.Instant import java.time.LocalDateTime object BusinessPartnerVerboseValues { @@ -308,17 +308,27 @@ object BusinessPartnerVerboseValues { val bpInputRequestFull = BusinessPartnerInputRequest( externalId = externalId1, nameParts = listOf("Business Partner Name", "Company ABC AG", "Another Organisation Corp", "Catena Test Name"), - shortName = "short1", - legalName = "Limited Liability Company Name", - legalForm = "Limited Liability Company", isOwnCompanyData = true, identifiers = listOf(bpIdentifier1, bpIdentifier2, bpIdentifier3), - classifications = listOf(bpClassification1, bpClassification2, bpClassification3), states = listOf(bpState1, bpState2), roles = listOf(BusinessPartnerRole.SUPPLIER), - postalAddress = bpPostalAddressInputDtoFull, - legalEntityBpn = "BPNL0000000000XY", - addressBpn = "BPNA0000000001XY" + legalEntity = LegalEntityComponentInputDto( + bpnL = "BPNL0000000000XY", + shortName = "short1", + legalName = "Limited Liability Company Name", + legalForm = "Limited Liability Company", + classifications = listOf(bpClassification1, bpClassification2, bpClassification3) + ), + site = SiteComponentInputDto( + bpnS = null + ), + address = AddressComponentInputDto( + bpnA = "BPNA0000000001XY", + addressType = AddressType.LegalAddress, + physicalPostalAddress = postalAddress2, + alternativePostalAddress = alternativeAddressFull + ) + ) //New Values for Logistic Addresses Tests @@ -592,80 +602,96 @@ object BusinessPartnerVerboseValues { street = null, ) - val bpPostalAddressInputDtoChina = BusinessPartnerPostalAddressDto( - addressType = AddressType.LegalAndSiteMainAddress, - physicalPostalAddress = physicalAddressChina - ) - val bpInputRequestChina = BusinessPartnerInputRequest( externalId = externalId3, nameParts = listOf("好公司 合伙制企业"), - shortName = "short3", - legalName = "姓名测试", - legalForm = "股份有限", isOwnCompanyData = true, identifiers = listOf( bpIdentifier1, bpIdentifier2, bpIdentifier1 - ), // duplicate, but they are elimnated - classifications = listOf( - bpClassificationChina, bpClassification3, bpClassificationChina - ), // duplicate, but they are elimnated + ), // duplicate, but they are eliminated states = listOf(bpState2, bpState1), roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER), - postalAddress = bpPostalAddressInputDtoChina, - legalEntityBpn = "BPNL0000000002XY", - siteBpn = "BPNS0000000003X9", - addressBpn = "BPNA0000000001XY" + legalEntity = LegalEntityComponentInputDto( + bpnL = "BPNL0000000002XY", + shortName = "short3", + legalName = "姓名测试", + legalForm = "股份有限", + classifications = listOf( + bpClassificationChina, bpClassification3, bpClassificationChina + ) // duplicate, but they are eliminated + ), + site = SiteComponentInputDto( + bpnS = "BPNS0000000003X9", + ), + address = AddressComponentInputDto( + bpnA = "BPNA0000000001XY", + addressType = AddressType.LegalAndSiteMainAddress, + physicalPostalAddress = physicalAddressChina, + alternativePostalAddress = AlternativePostalAddressDto() + ) ) val bpInputRequestCleaned = BusinessPartnerInputRequest( externalId = externalId4, nameParts = listOf("Name Part Value"), - shortName = "Random Short Name", - legalName = "Random Name Value", - legalForm = "Random Form Value", isOwnCompanyData = true, identifiers = listOf( bpIdentifier1, bpIdentifier2, bpIdentifier1 ), - classifications = listOf( - bpClassification1, bpClassification3 - ), states = listOf(bpState2, bpState1), roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER), - postalAddress = bpPostalAddressInputDtoFull, - legalEntityBpn = "BPNL0000000002XY", - siteBpn = "BPNS0000000003X9", - addressBpn = "BPNA0000000001XY" + legalEntity = LegalEntityComponentInputDto( + bpnL = "BPNL0000000002XY", + shortName = "Random Short Name", + legalName = "Random Name Value", + legalForm = "Random Form Value", + classifications = listOf( + bpClassification1, bpClassification3 + ) + ), + site = SiteComponentInputDto( + bpnS = "BPNS0000000003X9", + ), + address = AddressComponentInputDto( + bpnA = "BPNA0000000001XY", + addressType = AddressType.LegalAddress, + physicalPostalAddress = postalAddress2, + alternativePostalAddress = alternativeAddressFull + ) ) val bpInputRequestError = BusinessPartnerInputRequest( externalId = externalId5, nameParts = listOf("Name Part Value"), - shortName = "Random Short Name", - legalName = "Random Name Value", - legalForm = "Random Form Value", isOwnCompanyData = true, identifiers = listOf( bpIdentifier1, bpIdentifier2, bpIdentifier1 ), - classifications = listOf( - bpClassification1, bpClassification3 - ), states = listOf(bpState2, bpState1), roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER), - postalAddress = bpPostalAddressInputDtoFull, - legalEntityBpn = "BPNL0000000002XY", - siteBpn = "BPNS0000000003X9", - addressBpn = "BPNA0000000001XY" + legalEntity = LegalEntityComponentInputDto( + bpnL = "BPNL0000000002XY", + shortName = "Random Short Name", + legalName = "Random Name Value", + legalForm = "Random Form Value", + classifications = listOf( + bpClassification1, bpClassification3 + ) + ), + site = SiteComponentInputDto( + bpnS = "BPNS0000000003X9", + ), + address = AddressComponentInputDto( + bpnA = "BPNA0000000001XY", + addressType = AddressType.LegalAddress, + physicalPostalAddress = postalAddress2, + alternativePostalAddress = alternativeAddressFull + ) ) - val bpOutputRequestCleaned = BusinessPartnerOutputRequest( + val bpOutputDtoCleaned = BusinessPartnerOutputDto( externalId = externalId4, nameParts = listOf("part-cleaned-1", "name-cleaned-2"), - shortName = "shot-name-cleaned", - legalName = "legal-name-cleaned", - legalForm = "legal-form-cleaned", identifiers = listOf( BusinessPartnerIdentifierDto( type = "identifier-type-1-cleaned", @@ -678,18 +704,6 @@ object BusinessPartnerVerboseValues { issuingBody = "issuingBody-2-cleaned" ), ), - classifications = listOf( - BusinessPartnerClassificationDto( - type = ClassificationType.NACE, - code = "code-1-cleaned", - value = "value-1-cleaned" - ), - BusinessPartnerClassificationDto( - type = ClassificationType.NAF, - code = "code-2-cleaned", - value = "value-2-cleaned" - ), - ), states = listOf( BusinessPartnerStateDto( validFrom = LocalDateTime.of(2020, 9, 22, 15, 50), @@ -708,7 +722,29 @@ object BusinessPartnerVerboseValues { BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER ), - postalAddress = BusinessPartnerPostalAddressDto( + legalEntity = LegalEntityComponentOutputDto( + bpnL = "000000123AAA123", + shortName = "shot-name-cleaned", + legalName = "legal-name-cleaned", + legalForm = "legal-form-cleaned", + classifications = listOf( + BusinessPartnerClassificationDto( + type = ClassificationType.NACE, + code = "code-1-cleaned", + value = "value-1-cleaned" + ), + BusinessPartnerClassificationDto( + type = ClassificationType.NAF, + code = "code-2-cleaned", + value = "value-2-cleaned" + ), + ) + ), + site = SiteComponentOutputDto( + bpnS = "000000123BBB222" + ), + address = AddressComponentOutputDto( + bpnA = "000000123CCC333", addressType = AddressType.AdditionalAddress, physicalPostalAddress = PhysicalPostalAddressDto( geographicCoordinates = GeoCoordinateDto(0.5f, 0.5f, 0.5f), @@ -747,9 +783,9 @@ object BusinessPartnerVerboseValues { deliveryServiceType = DeliveryServiceType.PO_BOX ) ), - legalEntityBpn = "000000123AAA123", - siteBpn = "000000123BBB222", - addressBpn = "000000123CCC333" + isOwnCompanyData = false, + createdAt = Instant.now(), + updatedAt = Instant.now() ) } \ No newline at end of file