Skip to content

Commit

Permalink
Merge pull request #541 from catenax-ng/feat/business_partner_type_Ge…
Browse files Browse the repository at this point in the history
…neric

Feat: Add business partner type 'Generic' to Gate
  • Loading branch information
nicoprow authored Oct 19, 2023
2 parents 1c7a84c + 5ea7270 commit 60c74d1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ package org.eclipse.tractusx.bpdm.common.dto
enum class BusinessPartnerType {
LEGAL_ENTITY,
SITE,
ADDRESS
ADDRESS,
GENERIC
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ChangelogEntry(

@Enumerated(EnumType.STRING)
@Column(name = "business_partner_type", nullable = false, updatable = false)
val businessPartnerType: BusinessPartnerType?,
val businessPartnerType: BusinessPartnerType,

@Enumerated(EnumType.STRING)
@Column(name = "changelog_type", nullable = false, updatable = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ class BusinessPartnerService(

private fun initSharingState(entity: BusinessPartner) {
// TODO make businessPartnerType optional
sharingStateService.upsertSharingState(SharingStateDto(BusinessPartnerType.ADDRESS, entity.externalId))
sharingStateService.upsertSharingState(SharingStateDto(BusinessPartnerType.GENERIC, entity.externalId))
}

private fun saveChangelog(resolutionResults: Collection<ResolutionResult>) {
Expand All @@ -135,9 +135,7 @@ class BusinessPartnerService(
}

private fun saveChangelog(partner: BusinessPartner, changelogType: ChangelogType) {
val businessPartnerTypes = partner.postalAddress.addressType?.businessPartnerTypes ?: listOf(null)

businessPartnerTypes.forEach { type -> changelogRepository.save(ChangelogEntry(partner.externalId, type, changelogType, partner.stage)) }
changelogRepository.save(ChangelogEntry(partner.externalId, BusinessPartnerType.GENERIC, changelogType, partner.stage))
}

private fun assertInputStageExists(externalIds: Collection<String>) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,11 @@ class SharingStateControllerIT @Autowired constructor(
val stateSite = insertSharingStateSuccess(BusinessPartnerType.SITE, externalId = "exIdSite")
val stateLegalEntity1 = insertSharingStateSuccess(BusinessPartnerType.LEGAL_ENTITY, externalId = "exIdEntity1")
val stateLegalEntity2 = insertSharingStateSuccess(BusinessPartnerType.LEGAL_ENTITY, externalId = "exIdEntity2")
val stateGeneric = insertSharingStateSuccess(BusinessPartnerType.GENERIC, externalId = "exIdGeneric1")
insertSharingStateSuccess(BusinessPartnerType.ADDRESS, externalId = "exIdMultiple")
insertSharingStateSuccess(BusinessPartnerType.SITE, externalId = "exIdMultiple")
insertSharingStateSuccess(BusinessPartnerType.LEGAL_ENTITY, externalId = "exIdMultiple")
insertSharingStateSuccess(BusinessPartnerType.GENERIC, externalId = "exIdMultiple")

val searchAddressById = readSharingStates(BusinessPartnerType.ADDRESS, "exIdAddress")
assertThat(searchAddressById).hasSize(1)
Expand All @@ -80,16 +82,20 @@ class SharingStateControllerIT @Autowired constructor(
assertThat(searchEntitySingle).hasSize(1)
assertThat(searchEntitySingle.first()).isEqualTo(stateLegalEntity2)

val searchGenericSingle = readSharingStates(BusinessPartnerType.GENERIC, "exIdGeneric1")
assertThat(searchGenericSingle).hasSize(1)
assertThat(searchGenericSingle.first()).isEqualTo(stateGeneric)

val searchAll = readSharingStates(null)
assertThat(searchAll).hasSize(7)
assertThat(searchAll).hasSize(9)

val searchEntityAllLegalEntities = readSharingStates(BusinessPartnerType.LEGAL_ENTITY)
assertThat(searchEntityAllLegalEntities).hasSize(3)
assertThat(searchEntityAllLegalEntities).extracting(SharingStateDto::externalId.name)
.contains(stateLegalEntity1.externalId, stateLegalEntity2.externalId, "exIdMultiple")

val searchAllWithSameId = readSharingStates(null, "exIdMultiple")
assertThat(searchAllWithSameId).hasSize(3)
assertThat(searchAllWithSameId).hasSize(4)
assertThat(searchAllWithSameId).extracting(SharingStateDto::externalId.name)
.containsOnly("exIdMultiple")

Expand All @@ -107,6 +113,7 @@ class SharingStateControllerIT @Autowired constructor(
assertThat(searchAddress.first()).isEqualTo(stateAddress1)
}


@Test
fun `insert and update states`() {

Expand Down

0 comments on commit 60c74d1

Please sign in to comment.