diff --git a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt index 40de4d375..9cc6f71e1 100644 --- a/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt +++ b/bpdm-common/src/main/kotlin/org/eclipse/tractusx/bpdm/common/service/SaasMappings.kt @@ -101,11 +101,11 @@ object SaasMappings { ) } - private fun BusinessPartnerSaas.toNameDto(): NameDto? { + private fun BusinessPartnerSaas.toNameDto(): SassNameDto? { if (names.size > 1) { logger.warn { "Business Partner with ID $externalId has more than one name" } } - return names.map { toDto(it) } + return names.map { SassNameDto(it) } .firstOrNull() } @@ -124,13 +124,6 @@ object SaasMappings { ) } - fun toDto(name: NameSaas): NameDto { - return NameDto( - name.value, - name.shortName - ) - } - fun toLegalEntityStatesDtos(status: BusinessPartnerStatusSaas?): Collection = listOfNotNull( status?.type?.let { @@ -300,4 +293,12 @@ object SaasMappings { ) } + private data class SassNameDto( + val value: String, + val shortName: String? + ) { + constructor(nameSass: NameSaas) : + this(value = nameSass.value, shortName = nameSass.shortName) + } + } \ No newline at end of file diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt index 5eaa955fe..ded9a5339 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/service/SaasRequestMappingService.kt @@ -126,13 +126,6 @@ class SaasRequestMappingService( private fun toLegalFormSaas(technicalKey: String?) = if (technicalKey != null) LegalFormSaas(technicalKey = technicalKey) else null - private fun NameDto.toSaasModel(): NameSaas { - return NameSaas( - value = value, - shortName = shortName - ) - } - private fun LegalEntityIdentifierDto.toSaasModel(): IdentifierSaas { return IdentifierSaas( type = TypeKeyNameUrlSaas(type), @@ -184,9 +177,6 @@ class SaasRequestMappingService( ) } - private fun toNamesSaas(nameDto: NameDto): List = - listOf(nameDto.toSaasModel()) - private fun toNamesSaas(name: String?): List = name?.let { listOf(NameSaas(value = it)) } ?: emptyList() 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 ed060369c..9efc5540c 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 @@ -45,6 +45,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import org.assertj.core.api.Assertions.assertThat import org.eclipse.tractusx.bpdm.common.dto.saas.* import org.eclipse.tractusx.bpdm.gate.api.client.GateClient +import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.OptionalLsaType import org.eclipse.tractusx.bpdm.gate.api.model.response.TypeMatchResponse import org.eclipse.tractusx.bpdm.gate.config.TypeMatchConfigProperties @@ -88,6 +89,12 @@ class BusinessPartnerControllerIT @Autowired constructor( } } + val candidate1 = BusinessPartnerCandidateDto( + identifiers = listOf(RequestValues.genericIdentifier), + names = listOf(RequestValues.name1), + address = RequestValues.address1 + ) + /** * Given business partner candidate whose properties are matching existing legal entity * When invoking type match for candidate @@ -96,7 +103,7 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `match legal entity type`() { //make sure candidate is valid by providing identifier and name - val givenCandidate = with(RequestValues.candidate1) { + val givenCandidate = with(candidate1) { copy( identifiers = listOf(RequestValues.genericIdentifier), names = listOf(RequestValues.name1) @@ -121,7 +128,7 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `match no type`() { //make sure candidate is valid by providing identifier and name - val givenCandidate = with(RequestValues.candidate1) { + val givenCandidate = with(candidate1) { copy( identifiers = listOf(RequestValues.genericIdentifier), names = listOf(RequestValues.name1) @@ -146,7 +153,7 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `accept candidate without name`() { //create candidate without name - val givenCandidate = with(RequestValues.candidate1) { + val givenCandidate = with(candidate1) { copy( identifiers = listOf(RequestValues.genericIdentifier), names = emptyList() @@ -171,7 +178,7 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `accept candidate without identifier`() { //create candidate without identifier - val givenCandidate = with(RequestValues.candidate1) { + val givenCandidate = with(candidate1) { copy( identifiers = emptyList(), names = listOf(RequestValues.name1) @@ -196,7 +203,7 @@ class BusinessPartnerControllerIT @Autowired constructor( @Test fun `refuse candidate without name and identifier`() { //create candidate without identifier - val givenCandidate = with(RequestValues.candidate1) { + val givenCandidate = with(candidate1) { copy( identifiers = emptyList(), names = emptyList() diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt index e85a9a5c5..5e2c23bd1 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/RequestValues.kt @@ -21,7 +21,6 @@ package org.eclipse.tractusx.bpdm.gate.util import org.eclipse.tractusx.bpdm.common.dto.* import org.eclipse.tractusx.bpdm.gate.api.model.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.BusinessPartnerCandidateDto import org.eclipse.tractusx.bpdm.gate.api.model.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.SiteGateInputRequest @@ -328,9 +327,4 @@ object RequestValues { bpn = CommonValues.bpnAddress2 ) - val candidate1 = BusinessPartnerCandidateDto( - identifiers = listOf(genericIdentifier), - names = listOf(name1), - address = address1 - ) } \ No newline at end of file