Skip to content

Commit

Permalink
feat(pool-api): Administrative Level 1 endpoint - don't call it "regi…
Browse files Browse the repository at this point in the history
…on" in descriptions and properties
  • Loading branch information
martinfkaeser committed Oct 4, 2023
1 parent 8f791a2 commit 7e36dd4
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ private fun poolToGatePhysicalAddress(address: PhysicalPostalAddressVerboseDto):
country = address.country.technicalKey,
postalCode = address.postalCode,
city = address.city,
administrativeAreaLevel1 = address.administrativeAreaLevel1?.regionCode,
administrativeAreaLevel1 = address.administrativeAreaLevel1?.code,
administrativeAreaLevel2 = address.administrativeAreaLevel2,
administrativeAreaLevel3 = address.administrativeAreaLevel3,
district = address.district,
Expand All @@ -196,7 +196,7 @@ private fun poolToGateAlternativeAddress(address: AlternativePostalAddressVerbos
country = address.country.technicalKey,
postalCode = address.postalCode,
city = address.city,
administrativeAreaLevel1 = address.administrativeAreaLevel1?.regionCode,
administrativeAreaLevel1 = address.administrativeAreaLevel1?.code,
deliveryServiceNumber = address.deliveryServiceNumber,
deliveryServiceType = address.deliveryServiceType,
deliveryServiceQualifier = address.deliveryServiceQualifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ package org.eclipse.tractusx.bpdm.common.dto.response
import com.neovisionaries.i18n.CountryCode
import io.swagger.v3.oas.annotations.media.Schema

@Schema(name = "RegionDto", description = "Region within a country")
@Schema(name = "CountrySubdivisionDto", description = "Country subdivision")
data class RegionDto(

@get:Schema(description = "Country code")
val countryCode: CountryCode,

@get:Schema(description = "Abbreviation or shorthand of the area")
val regionCode: String,
@get:Schema(description = "The country subdivision code according to ISO 3166-2")
val code: String,

@get:Schema(description = "Describes the full name of the region within a country according to ISO 3166-214")
val regionName: String
@get:Schema(description = "The name of the country subdivision according to ISO 3166-2")
val name: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,12 @@ interface PoolMetadataApi {
fun getRegions(@ParameterObject paginationRequest: PaginationRequest): PageDto<RegionDto>

@Operation(
summary = "Get page of regions suitable for the administrativeAreaLevel1 address property",
description = "Lists all currently known regions in a paginated result"
summary = "Get page of country subdivisions suitable for the administrativeAreaLevel1 address property",
description = "Lists all currently known country subdivisions according to ISO 3166-2 in a paginated result"
)
@ApiResponses(
value = [
ApiResponse(responseCode = "200", description = "Page of existing regions, may be empty"),
ApiResponse(responseCode = "200", description = "Page of existing country subdivisions, may be empty"),
ApiResponse(responseCode = "400", description = "On malformed request parameters", content = [Content()])
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,12 @@ class MetadataService(
@Transactional
fun createRegion(request: RegionDto): RegionDto {

logger.info { "Create new Region with key ${request.regionCode} and name ${request.regionName}" }
logger.info { "Create new Region with key ${request.code} and name ${request.name}" }

val region = Region(
countryCode = request.countryCode,
regionCode = request.regionCode,
regionName = request.regionName
regionCode = request.code,
regionName = request.name
)

return regionRepository.save(region).toDto()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ class MetadataControllerIT @Autowired constructor(
// INSERT INTO bpdm.regions (country_code, region_code, region_name) VALUES ('AD', 'AD-02', 'Canillo');
with(firstPage.content.first()) {
assertThat(countryCode).isEqualTo(AD)
assertThat(regionCode).isEqualTo("AD-02")
assertThat(regionName).isEqualTo("Canillo")
assertThat(code).isEqualTo("AD-02")
assertThat(name).isEqualTo("Canillo")
}

val lastPage = poolClient.metadata.getAdminAreasLevel1(PaginationRequest(347))
Expand All @@ -452,8 +452,8 @@ class MetadataControllerIT @Autowired constructor(
// INSERT INTO bpdm.regions (country_code, region_code, region_name) VALUES ('ZW', 'ZW-MW', 'Mashonaland West');
with(lastPage.content.last()) {
assertThat(countryCode).isEqualTo(ZW)
assertThat(regionCode).isEqualTo("ZW-MW")
assertThat(regionName).isEqualTo("Mashonaland West")
assertThat(code).isEqualTo("ZW-MW")
assertThat(name).isEqualTo("Mashonaland West")
}
}
}

0 comments on commit 7e36dd4

Please sign in to comment.