Skip to content

Commit

Permalink
feat(api): #178 API: Remove Street from Alternative Address
Browse files Browse the repository at this point in the history
  • Loading branch information
rainer-exxcellent committed May 25, 2023
1 parent 7e15d4c commit abfb070
Show file tree
Hide file tree
Showing 17 changed files with 51 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,5 @@ data class BasePostalAddressDto(

@get:Schema(description = "The city of the address (Synonym: Town, village, municipality)")
val city: String,

@get:Schema(description = "Address country")
val street: StreetDto? = null,

)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ data class PhysicalPostalAddressDto(
@field:JsonUnwrapped
val baseAddress: BasePostalAddressDto,

@get:Schema(description = "Address Street")
val street: StreetDto? = null,

@field:JsonUnwrapped
val areaPart: AreaDistrictDto,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ package org.eclipse.tractusx.bpdm.common.dto.response
import com.neovisionaries.i18n.CountryCode
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.GeoCoordinateDto
import org.eclipse.tractusx.bpdm.common.dto.StreetDto
import org.eclipse.tractusx.bpdm.common.dto.response.type.TypeKeyNameDto

@Schema(name = "PostalAddressResponse", description = "Address record of a business partner")
Expand All @@ -40,6 +39,4 @@ data class BasePostalAddressResponse(
@get:Schema(description = "The city of the address (Synonym: Town, village, municipality)")
val city: String,

@get:Schema(description = "Street")
val street: StreetDto? = null,
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package org.eclipse.tractusx.bpdm.common.dto.response
import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.StreetDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -31,6 +32,9 @@ data class PhysicalPostalAddressResponse(
@field:JsonUnwrapped
val baseAddress: BasePostalAddressResponse,

@get:Schema(description = "Street")
val street: StreetDto? = null,

@field:JsonUnwrapped
val areaPart: AreaDistrictResponse,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ object SaasMappings {
administrativeAreaLevel3 = null,
district = map.district(),
),
street = toStreetDto(map),
baseAddress = BasePostalAddressDto(
geographicCoordinates = map.geoCoordinates(),
city = city,
country = country,
postCode = map.postcode(),
street = toStreetDto(map),
)
)
}
Expand Down Expand Up @@ -260,7 +260,6 @@ object SaasMappings {
city = city,
country = country,
postCode = map.postcode(),
street = toStreetDto(map),
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ fun AlternativePostalAddressDto.toAlternativePostalAddressEntity(): AlternativeP
administrativeAreaLevel1 = null, // TODO Add region mapping Logic
postCode = baseAddress.postCode,
city = baseAddress.city,
street = baseAddress.street?.toStreetEntity(),
deliveryServiceType = deliveryServiceType,
deliveryServiceNumber = deliveryServiceNumber
)
Expand All @@ -83,7 +82,7 @@ fun PhysicalPostalAddressDto.toPhysicalPostalAddressEntity(): PhysicalPostalAddr
postCode = baseAddress.postCode,
city = baseAddress.city,
districtLevel1 = areaPart.district,
street = baseAddress.street?.toStreetEntity(),
street = street?.toStreetEntity(),
companyPostCode = companyPostCode,
industrialZone = industrialZone,
building = building,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class SaasDtoToSaasAddressMapping(private val postalAdress: BasePostalAddressDto

fun thoroughfares(physicalAddress: PhysicalPostalAddressDto?): Collection<ThoroughfareSaas> {
return listOfNotNull(
postalAdress.street?.let {
physicalAddress?.street?.let {
ThoroughfareSaas(
type = SaasThoroughfareType.STREET.toSaasTypeDto(),
name = it.name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SaasDtoToSaasAddressMappingTest {

val addressSaas = SaasValues.addressBusinessPartner1.addresses.first()
val baseAddressDto = addressDto.physicalPostalAddress.baseAddress
val streetDto = addressDto.physicalPostalAddress.street
val areaPart = addressDto.physicalPostalAddress.areaPart
assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION))
assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY))
Expand All @@ -30,10 +31,10 @@ class SaasDtoToSaasAddressMappingTest {
assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude)
assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude)
assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR))
assertThat(baseAddressDto.street?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(baseAddressDto.street?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(baseAddressDto.street?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(baseAddressDto.street?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)
assertThat(streetDto?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(streetDto?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)

assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name)
assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING))
Expand Down Expand Up @@ -64,6 +65,7 @@ class SaasDtoToSaasAddressMappingTest {

val addressSaas = SaasValues.addressBusinessPartner1.addresses.first()
val baseAddressDto = addressDto.physicalPostalAddress.baseAddress
val streetDto = addressDto.physicalPostalAddress.street
val areaPart = addressDto.physicalPostalAddress.areaPart
assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION))
assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY))
Expand All @@ -74,10 +76,10 @@ class SaasDtoToSaasAddressMappingTest {
assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude)
assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude)
assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR))
assertThat(baseAddressDto.street?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(baseAddressDto.street?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(baseAddressDto.street?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(baseAddressDto.street?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)
assertThat(streetDto?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(streetDto?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)

assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name)
assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING))
Expand All @@ -92,6 +94,7 @@ class SaasDtoToSaasAddressMappingTest {

val addressSaas = SaasValues.addressBusinessPartner2.addresses.first()
val baseAddressDto = addressDto.physicalPostalAddress.baseAddress
val streetDto = addressDto.physicalPostalAddress.street
val areaPart = addressDto.physicalPostalAddress.areaPart
assertThat(areaPart.administrativeAreaLevel1).isEqualTo(findValue(addressSaas.administrativeAreas, REGION))
assertThat(areaPart.administrativeAreaLevel2).isEqualTo(findValue(addressSaas.administrativeAreas, COUNTY))
Expand All @@ -102,10 +105,10 @@ class SaasDtoToSaasAddressMappingTest {
assertThat(baseAddressDto.geographicCoordinates?.latitude).isEqualTo(addressSaas.geographicCoordinates?.latitude)
assertThat(baseAddressDto.geographicCoordinates?.longitude).isEqualTo(addressSaas.geographicCoordinates?.longitude)
assertThat(baseAddressDto.postCode).isEqualTo(findValue(addressSaas.postCodes, SaasPostCodeType.REGULAR))
assertThat(baseAddressDto.street?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(baseAddressDto.street?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(baseAddressDto.street?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(baseAddressDto.street?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)
assertThat(streetDto?.name).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.name)
assertThat(streetDto?.houseNumber).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.number)
assertThat(streetDto?.direction).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.direction)
assertThat(streetDto?.milestone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.STREET)?.shortName)

assertThat(addressDto.physicalPostalAddress.industrialZone).isEqualTo(findObject(addressSaas.thoroughfares, SaasThoroughfareType.INDUSTRIAL_ZONE)?.name)
assertThat(addressDto.physicalPostalAddress.building).isEqualTo(findValue(addressSaas.premises, SaasPremiseType.BUILDING))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ object RequestValues {
administrativeAreaLevel2 = CommonValues.county1,
district = CommonValues.district1,
),
street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1),
baseAddress = BasePostalAddressDto(
geographicCoordinates = geoCoordinate1,
country = CommonValues.country1,
postCode = CommonValues.postCode1,
city = CommonValues.city1,
street = StreetDto(name = CommonValues.street1, houseNumber = CommonValues.houseNumber1, direction = CommonValues.direction1)
)
)

Expand All @@ -146,12 +146,12 @@ object RequestValues {
administrativeAreaLevel2 = CommonValues.county2,
district = CommonValues.district2,
),
street = StreetDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2),
baseAddress = BasePostalAddressDto(
geographicCoordinates = geoCoordinate2,
country = CommonValues.country2,
postCode = CommonValues.postCode2,
city = CommonValues.city2,
street = StreetDto(name = CommonValues.street2, houseNumber = CommonValues.houseNumber2, direction = CommonValues.direction2),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,12 @@ object ResponseValues {
administrativeAreaLevel2 = CommonValues.county1,
district = CommonValues.district1,
),
street = StreetDto(CommonValues.street1, CommonValues.houseNumber1),
baseAddress = BasePostalAddressResponse(
geographicCoordinates = geoCoordinate1,
country = country1,
postCode = CommonValues.postCode1,
city = CommonValues.city1,
street = StreetDto(CommonValues.street1, CommonValues.houseNumber1),
)
)

Expand All @@ -193,12 +193,12 @@ object ResponseValues {
administrativeAreaLevel2 = CommonValues.county2,
district = CommonValues.district2,
),
street = StreetDto(CommonValues.street2, CommonValues.houseNumber2),
baseAddress = BasePostalAddressResponse(
geographicCoordinates = geoCoordinate2,
country = country2,
postCode = CommonValues.postCode2,
city = CommonValues.city2,
street = StreetDto(CommonValues.street2, CommonValues.houseNumber2),
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ class BusinessPartnerBuildService(
postCode = baseAddress.postCode,
city = baseAddress.city,
districtLevel1 = area.district,
street = baseAddress.street?.let { createStreet(it) },
street = physicalAddress.street?.let { createStreet(it) },
companyPostCode = physicalAddress.companyPostCode,
industrialZone = physicalAddress.industrialZone,
building = physicalAddress.building,
Expand All @@ -457,7 +457,6 @@ class BusinessPartnerBuildService(
administrativeAreaLevel1 = null,
postCode = baseAddress.postCode,
city = baseAddress.city,
street = baseAddress.street?.let { createStreet(it) },
deliveryServiceType = alternativeAddress.deliveryServiceType,
deliveryServiceNumber = alternativeAddress.deliveryServiceNumber
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ fun PhysicalPostalAddress.toDto(): PhysicalPostalAddressResponse {
country = country.toDto(),
postCode = postCode,
city = city,
street = street?.toDto()
),
street = street?.toDto(),
areaPart = AreaDistrictResponse(
administrativeAreaLevel1 = administrativeAreaLevel1?.let { NameRegioncodeDto(it.regionName, it.regionCode) },
administrativeAreaLevel2 = administrativeAreaLevel2,
Expand All @@ -176,7 +176,6 @@ fun AlternativePostalAddress.toDto(): AlternativePostalAddressResponse {
country = country.toDto(),
postCode = postCode,
city = city,
street = street?.toDto()
),
areaPart = AreaDistrictAlternativResponse(
administrativeAreaLevel1 = administrativeAreaLevel1?.let { NameRegioncodeDto(it.regionName, it.regionCode) },
Expand Down
Loading

0 comments on commit abfb070

Please sign in to comment.