Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Generic): naming of BPN fields in generic business partner #596

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ class CleaningServiceDummy(

val legalAddress = addressPartner.copy(bpnAReference = legalAddressBpnReference)

val bpnReferenceDto = createBpnReference(genericPartner.bpnL)
val bpnReferenceDto = createBpnReference(genericPartner.legalEntityBpn)

return genericPartner.toLegalEntityDto(bpnReferenceDto, legalAddress)

}

fun createAddressRepresentation(genericPartner: BusinessPartnerGenericDto): LogisticAddressDto {
val bpnReferenceDto = createBpnReference(genericPartner.bpnA)
val bpnReferenceDto = createBpnReference(genericPartner.addressBpn)
return genericPartner.toLogisticAddressDto(bpnReferenceDto)
}

fun createSiteRepresentation(genericPartner: BusinessPartnerGenericDto, siteAddressReference: LogisticAddressDto): SiteDto {
val legalName = genericPartner.nameParts.joinToString(" ")
val bpnReferenceDto = createBpnReference(genericPartner.bpnS)
val bpnReferenceDto = createBpnReference(genericPartner.siteBpn)
return genericPartner.toSiteDto(bpnReferenceDto, legalName, siteAddressReference)
}

Expand All @@ -152,7 +152,7 @@ class CleaningServiceDummy(
fun shouldCreateSite(genericPartner: BusinessPartnerGenericDto): Boolean {
return genericPartner.postalAddress.addressType == AddressType.SiteMainAddress ||
genericPartner.postalAddress.addressType == AddressType.LegalAndSiteMainAddress ||
genericPartner.bpnS != null
genericPartner.siteBpn != null
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

package org.eclipse.tractusx.bpdm.cleaning.service

import com.github.tomakehurst.wiremock.client.WireMock.*
import org.assertj.core.api.Assertions
import org.assertj.core.api.RecursiveComparisonAssert
import org.eclipse.tractusx.bpdm.cleaning.testdata.CommonValues.businessPartnerWithBpnA
Expand All @@ -30,7 +29,6 @@ import org.eclipse.tractusx.bpdm.cleaning.testdata.CommonValues.businessPartnerW
import org.eclipse.tractusx.bpdm.cleaning.testdata.CommonValues.expectedLegalEntityDto
import org.eclipse.tractusx.bpdm.cleaning.testdata.CommonValues.expectedLogisticAddressDto
import org.eclipse.tractusx.bpdm.cleaning.testdata.CommonValues.expectedSiteDto
import org.eclipse.tractusx.bpdm.common.dto.*
import org.eclipse.tractusx.orchestrator.api.model.*
import org.junit.jupiter.api.Assertions.*
import org.junit.jupiter.api.Test
Expand All @@ -53,7 +51,7 @@ class CleaningServiceDummyTest @Autowired constructor(

val result = cleaningServiceDummy.processCleaningTask(taskStepReservationEntryDto)

val expectedBpnA = taskStepReservationEntryDto.businessPartner.generic.bpnA
val expectedBpnA = taskStepReservationEntryDto.businessPartner.generic.addressBpn

val resultedAddress = result.businessPartner?.address

Expand Down Expand Up @@ -114,9 +112,9 @@ class CleaningServiceDummyTest @Autowired constructor(

val result = cleaningServiceDummy.processCleaningTask(taskStepReservationEntryDto)

val expectedBpnA = taskStepReservationEntryDto.businessPartner.generic.bpnA
val expectedBpnA = taskStepReservationEntryDto.businessPartner.generic.addressBpn

val expectedBpnL = taskStepReservationEntryDto.businessPartner.generic.bpnL
val expectedBpnL = taskStepReservationEntryDto.businessPartner.generic.legalEntityBpn

val resultedAddress = result.businessPartner?.address

Expand Down Expand Up @@ -154,9 +152,9 @@ class CleaningServiceDummyTest @Autowired constructor(

val resultedSite = result.businessPartner?.site

val expectedBpnA = taskStepReservationResponse.businessPartner.generic.bpnA
val expectedBpnA = taskStepReservationResponse.businessPartner.generic.addressBpn

val expectedBpnS = taskStepReservationResponse.businessPartner.generic.bpnS
val expectedBpnS = taskStepReservationResponse.businessPartner.generic.siteBpn


// legalEntity should Generate new bpnL and legalAddress should use passed bpnA since address type is LegalAndSiteMainAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ object CommonValues {

val businessPartnerWithBpnA = businessPartnerWithEmptyBpns.copy(
postalAddress = postalAddressForAdditional,
bpnA = "FixedBPNA"
addressBpn = "FixedBPNA"
)


val businessPartnerWithBpnLAndBpnAAndLegalAddressType = businessPartnerWithEmptyBpns.copy(
postalAddress = postalAddressForLegal,
bpnA = "FixedBPNA",
bpnL = "FixedBPNL"
addressBpn = "FixedBPNA",
legalEntityBpn = "FixedBPNL"
)

val businessPartnerWithEmptyBpnLAndAdditionalAddressType = businessPartnerWithEmptyBpns.copy(
Expand All @@ -132,8 +132,8 @@ object CommonValues {

val businessPartnerWithBpnSAndBpnAAndLegalAndSiteMainAddressType = businessPartnerWithEmptyBpns.copy(
postalAddress = postalAddressForLegalAndSite,
bpnA = "FixedBPNA",
bpnS = "FixedBPNS"
addressBpn = "FixedBPNA",
siteBpn = "FixedBPNS"
)

val businessPartnerWithEmptyBpnAndSiteMainAddressType = businessPartnerWithEmptyBpns.copy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ interface IBaseBusinessPartnerDto {
@get:Schema(description = "Address of the official seat of this business partner.")
val postalAddress: IBaseBusinessPartnerPostalAddressDto

@get:Schema(description = "BPNL")
val bpnL: String?
@get:Schema(description = "BPNL of the golden record legal entity this business partner refers to")
val legalEntityBpn: String?

@get:Schema(description = "BPNS")
val bpnS: String?
@get:Schema(description = "BPNS of the golden record site this business partner refers to")
val siteBpn: String?

@get:Schema(description = "BPNA")
val bpnA: String?
@get:Schema(description = "BPNA of the golden record address this business partner refers to")
val addressBpn: String?

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ data class BusinessPartnerInputRequest(
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(),
override val isOwnCompanyData: Boolean = false,
override val bpnL: String? = null,
override val bpnS: String? = null,
override val bpnA: String? = null,
override val legalEntityBpn: String? = null,
override val siteBpn: String? = null,
override val addressBpn: String? = null,

) : IBaseBusinessPartnerGateDto
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ data class BusinessPartnerOutputRequest(
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: BusinessPartnerPostalAddressDto = BusinessPartnerPostalAddressDto(),
override val isOwnCompanyData: Boolean = false,
override val bpnL: String? = null,
override val bpnS: String? = null,
override val bpnA: String? = null,
override val legalEntityBpn: String? = null,
override val siteBpn: String? = null,
override val addressBpn: String? = null,

) : IBaseBusinessPartnerGateDto
) : IBaseBusinessPartnerGateDto
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ data class BusinessPartnerInputDto(
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: BusinessPartnerPostalAddressDto,
override val isOwnCompanyData: Boolean,
override val bpnL: String?,
override val bpnS: String?,
override val bpnA: String?,
override val legalEntityBpn: String?,
override val siteBpn: String?,
override val addressBpn: String?,

@get:Schema(description = CommonDescription.createdAt)
val createdAt: Instant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ data class BusinessPartnerOutputDto(
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: BusinessPartnerPostalAddressDto,
override val isOwnCompanyData: Boolean,
override val bpnL: String,
override val bpnS: String?,
override val bpnA: String,
override val legalEntityBpn: String,
override val siteBpn: String?,
override val addressBpn: String,

@get:Schema(description = CommonDescription.createdAt)
val createdAt: Instant,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ class BusinessPartnerMappings {
roles = entity.roles,
postalAddress = toPostalAddressDto(entity.postalAddress),
isOwnCompanyData = entity.isOwnCompanyData,
bpnL = entity.bpnL,
bpnS = entity.bpnS,
bpnA = entity.bpnA,
legalEntityBpn = entity.bpnL,
siteBpn = entity.bpnS,
addressBpn = entity.bpnA,
createdAt = entity.createdAt,
updatedAt = entity.updatedAt
)
Expand All @@ -74,10 +74,10 @@ class BusinessPartnerMappings {
roles = entity.roles,
postalAddress = toPostalAddressDto(entity.postalAddress),
isOwnCompanyData = entity.isOwnCompanyData,
bpnL = entity.bpnL
legalEntityBpn = entity.bpnL
?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnL, entity.externalId),
bpnS = entity.bpnS,
bpnA = entity.bpnA
siteBpn = entity.bpnS,
addressBpn = entity.bpnA
?: throw BpdmNullMappingException(BusinessPartner::class, BusinessPartnerOutputDto::class, BusinessPartner::bpnA, entity.externalId),
createdAt = entity.createdAt,
updatedAt = entity.updatedAt
Expand All @@ -97,9 +97,9 @@ class BusinessPartnerMappings {
legalName = dto.legalName,
legalForm = dto.legalForm,
isOwnCompanyData = dto.isOwnCompanyData,
bpnL = dto.bpnL,
bpnS = dto.bpnS,
bpnA = dto.bpnA,
bpnL = dto.legalEntityBpn,
bpnS = dto.siteBpn,
bpnA = dto.addressBpn,
postalAddress = toPostalAddress(dto.postalAddress),
parentId = null,
parentType = null,
Expand All @@ -120,9 +120,9 @@ class BusinessPartnerMappings {
legalName = dto.legalName,
legalForm = dto.legalForm,
isOwnCompanyData = dto.isOwnCompanyData,
bpnL = dto.bpnL,
bpnS = dto.bpnS,
bpnA = dto.bpnA,
bpnL = dto.legalEntityBpn,
bpnS = dto.siteBpn,
bpnA = dto.addressBpn,
parentId = null,
parentType = null,
postalAddress = toPostalAddress(dto.postalAddress)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class OrchestratorMappings(
classifications = entity.classifications.map { toClassificationDto(it) },
roles = entity.roles,
postalAddress = toPostalAddressDto(entity.postalAddress),
bpnL = entity.bpnL,
bpnS = entity.bpnS,
bpnA = entity.bpnA,
legalEntityBpn = entity.bpnL,
siteBpn = entity.bpnS,
addressBpn = entity.bpnA,
ownerBpnL = getOwnerBpnL(entity)
)

Expand Down Expand Up @@ -142,9 +142,9 @@ class OrchestratorMappings(
classifications = entity.classifications.map { toClassification(it) }.toSortedSet(),
roles = entity.roles.toSortedSet(),
postalAddress = toPostalAddress(entity.postalAddress),
bpnL = entity.bpnL,
bpnS = entity.bpnS,
bpnA = entity.bpnA,
bpnL = entity.legalEntityBpn,
bpnS = entity.siteBpn,
bpnA = entity.addressBpn,
stage = StageType.Output
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,9 @@ class BusinessPartnerControllerIT @Autowired constructor(
roles = request.roles.toSortedSet(),
postalAddress = request.postalAddress,
isOwnCompanyData = request.isOwnCompanyData,
bpnL = request.bpnL,
bpnS = request.bpnS,
bpnA = request.bpnA,
legalEntityBpn = request.legalEntityBpn,
siteBpn = request.siteBpn,
addressBpn = request.addressBpn,
createdAt = Instant.now(),
updatedAt = Instant.now()
)
Expand All @@ -332,14 +332,14 @@ class BusinessPartnerControllerIT @Autowired constructor(
roles = request.roles.toSortedSet(),
postalAddress = request.postalAddress,
isOwnCompanyData = request.isOwnCompanyData,
bpnL = request.bpnL ?: throw BpdmNullMappingException(
legalEntityBpn = request.legalEntityBpn ?: throw BpdmNullMappingException(
BusinessPartner::class,
BusinessPartnerOutputDto::class,
BusinessPartner::bpnL,
request.externalId
),
bpnS = request.bpnS,
bpnA = request.bpnA ?: throw BpdmNullMappingException(
siteBpn = request.siteBpn,
addressBpn = request.addressBpn ?: throw BpdmNullMappingException(
BusinessPartner::class,
BusinessPartnerOutputDto::class,
BusinessPartner::bpnA,
Expand Down Expand Up @@ -546,7 +546,7 @@ class BusinessPartnerControllerIT @Autowired constructor(
sharingStateType = SharingStateType.Success,
sharingErrorCode = null,
sharingErrorMessage = null,
bpn = BusinessPartnerGenericMockValues.businessPartner1.bpnA,
bpn = BusinessPartnerGenericMockValues.businessPartner1.addressBpn,
sharingProcessStarted = null,
taskId = "0"
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ object BusinessPartnerGenericMockValues {
)
),
ownerBpnL = "BPNL_CLEANED_VALUES",
bpnL = "000000123AAA123",
bpnS = "000000123BBB222",
bpnA = "000000123CCC333"
legalEntityBpn = "000000123AAA123",
siteBpn = "000000123BBB222",
addressBpn = "000000123CCC333"
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,8 @@ object BusinessPartnerVerboseValues {
states = listOf(bpState1, bpState2),
roles = listOf(BusinessPartnerRole.SUPPLIER),
postalAddress = bpPostalAddressInputDtoFull,
bpnL = "BPNL0000000000XY",
bpnA = "BPNA0000000001XY"
legalEntityBpn = "BPNL0000000000XY",
addressBpn = "BPNA0000000001XY"
)

val address1 = PhysicalPostalAddressVerboseDto(
Expand Down Expand Up @@ -769,9 +769,9 @@ object BusinessPartnerVerboseValues {
states = listOf(bpState2, bpState1),
roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER),
postalAddress = bpPostalAddressInputDtoChina,
bpnL = "BPNL0000000002XY",
bpnS = "BPNS0000000003X9",
bpnA = "BPNA0000000001XY"
legalEntityBpn = "BPNL0000000002XY",
siteBpn = "BPNS0000000003X9",
addressBpn = "BPNA0000000001XY"
)

val bpInputRequestCleaned = BusinessPartnerInputRequest(
Expand All @@ -790,9 +790,9 @@ object BusinessPartnerVerboseValues {
states = listOf(bpState2, bpState1),
roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER),
postalAddress = bpPostalAddressInputDtoFull,
bpnL = "BPNL0000000002XY",
bpnS = "BPNS0000000003X9",
bpnA = "BPNA0000000001XY"
legalEntityBpn = "BPNL0000000002XY",
siteBpn = "BPNS0000000003X9",
addressBpn = "BPNA0000000001XY"
)

val bpInputRequestError = BusinessPartnerInputRequest(
Expand All @@ -811,9 +811,9 @@ object BusinessPartnerVerboseValues {
states = listOf(bpState2, bpState1),
roles = listOf(BusinessPartnerRole.CUSTOMER, BusinessPartnerRole.SUPPLIER),
postalAddress = bpPostalAddressInputDtoFull,
bpnL = "BPNL0000000002XY",
bpnS = "BPNS0000000003X9",
bpnA = "BPNA0000000001XY"
legalEntityBpn = "BPNL0000000002XY",
siteBpn = "BPNS0000000003X9",
addressBpn = "BPNA0000000001XY"
)

val bpOutputRequestCleaned = BusinessPartnerOutputRequest(
Expand Down Expand Up @@ -903,9 +903,9 @@ object BusinessPartnerVerboseValues {
deliveryServiceType = DeliveryServiceType.PO_BOX
)
),
bpnL = "000000123AAA123",
bpnS = "000000123BBB222",
bpnA = "000000123CCC333"
legalEntityBpn = "000000123AAA123",
siteBpn = "000000123BBB222",
addressBpn = "000000123CCC333"
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ data class BusinessPartnerGenericDto(
override val classifications: Collection<ClassificationDto> = emptyList(),
override val roles: Collection<BusinessPartnerRole> = emptyList(),
override val postalAddress: PostalAddressDto = PostalAddressDto(),
override val bpnL: String? = null,
override val bpnS: String? = null,
override val bpnA: String? = null,
override val legalEntityBpn: String? = null,
override val siteBpn: String? = null,
override val addressBpn: String? = null,

@get:Schema(description = "The BPNL of the company sharing and claiming this business partner as its own")
val ownerBpnL: String? = null,
Expand Down
Loading