Skip to content

Commit

Permalink
fix(api): API-Model: Rename DTOs #268
Browse files Browse the repository at this point in the history
- undo rename of LogisticAddressResponse
  • Loading branch information
rainer-exxcellent committed Jun 28, 2023
1 parent b25cd04 commit 142f4a0
Show file tree
Hide file tree
Showing 22 changed files with 60 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant


@Schema(name = "LogisticAddressVerboseDto", description = "Logistic address ")
data class LogisticAddressVerboseDto(
@Schema(name = "LogisticAddressResponse", description = "Logistic address ")
data class LogisticAddressResponse(

@get:Schema(description = "Business Partner Number of this address")
val bpna: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ data class PoolLegalEntityVerboseDto(
val legalEntity: LegalEntityVerboseDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressVerboseDto,
val legalAddress: LogisticAddressResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ object ResponseValues {

val legalEntityResponsePool1 = PoolLegalEntityVerboseDto(
legalName = CommonValues.name1,
legalAddress = LogisticAddressVerboseDto(
legalAddress = LogisticAddressResponse(
bpna = CommonValues.bpnAddress1,
physicalPostalAddress = address1,
bpnLegalEntity = CommonValues.bpn1,
Expand All @@ -229,7 +229,7 @@ object ResponseValues {

val legalEntityResponsePool2 = PoolLegalEntityVerboseDto(
legalName = CommonValues.name3,
legalAddress = LogisticAddressVerboseDto(
legalAddress = LogisticAddressResponse(
bpna = CommonValues.bpnAddress2,
physicalPostalAddress = address2,
bpnLegalEntity = CommonValues.bpn2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest
import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerSearchRequest
Expand Down Expand Up @@ -80,7 +80,7 @@ interface PoolAddressApi {
@GetExchange("/{bpna}")
fun getAddress(
@Parameter(description = "Bpn value") @PathVariable bpna: String
): LogisticAddressVerboseDto
): LogisticAddressResponse

@Operation(
summary = "Search address partners by BPNs and/or parent BPNs",
Expand All @@ -97,7 +97,7 @@ interface PoolAddressApi {
fun searchAddresses(
@RequestBody addressSearchRequest: AddressPartnerBpnSearchRequest,
@ParameterObject paginationRequest: PaginationRequest
): PageResponse<LogisticAddressVerboseDto>
): PageResponse<LogisticAddressResponse>

@Operation(
summary = "Create new address business partners",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ interface PoolLegalEntityApi {
fun getAddresses(
@Parameter(description = "Bpn value") @PathVariable bpnl: String,
@ParameterObject paginationRequest: PaginationRequest
): PageResponse<LogisticAddressVerboseDto>
): PageResponse<LogisticAddressResponse>

@Operation(
summary = "Search Legal Addresses",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.pool.api.model.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse


@Schema(name = "AddressMatchResponse", description = "Match with score for a business partner record of type address")
Expand All @@ -30,5 +30,5 @@ data class AddressMatchResponse(
val score: Float,

@Schema(description = "Matched address business partner record")
val address: LogisticAddressVerboseDto
val address: LogisticAddressResponse
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ package org.eclipse.tractusx.bpdm.pool.api.model.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.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
@Schema(name = "AddressPartnerCreateResponse", description = "Created business partners of type address")
data class AddressPartnerCreateResponse(

@field:JsonUnwrapped
val address: LogisticAddressVerboseDto,
val address: LogisticAddressResponse,

@Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request")
val index: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.pool.api.model.response

import io.swagger.v3.oas.annotations.media.Schema
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse

open class EntitiesWithErrors<ENTITY, out ERROR : ErrorCode>(

Expand Down Expand Up @@ -85,9 +85,9 @@ data class AddressPartnerCreateResponseWrapper(
description = "Holds information about successfully and failed entities after the creating/updating of several objects"
)
data class AddressPartnerUpdateResponseWrapper(
override val entities: Collection<LogisticAddressVerboseDto>,
override val entities: Collection<LogisticAddressResponse>,
override val errors: Collection<ErrorInfo<AddressUpdateError>>
) : EntitiesWithErrors<LogisticAddressVerboseDto, AddressUpdateError>(entities, errors)
) : EntitiesWithErrors<LogisticAddressResponse, AddressUpdateError>(entities, errors)



Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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.response.LegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -40,5 +40,5 @@ data class LegalEntityMatchResponse(
val legalEntity: LegalEntityVerboseDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressVerboseDto,
val legalAddress: LogisticAddressResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ 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.response.LegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

@JsonDeserialize(using = DataClassUnwrappedJsonDeserializer::class)
Expand All @@ -37,7 +37,7 @@ data class LegalEntityPartnerCreateResponse(
val legalEntity: LegalEntityVerboseDto,

@get:Schema(description = "Address of the official seat of this legal entity")
val legalAddress: LogisticAddressVerboseDto,
val legalAddress: LogisticAddressResponse,

@Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request")
val index: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.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.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

Expand All @@ -34,7 +34,7 @@ data class SitePartnerCreateResponse(
val site: SiteVerboseDto,

@Schema(description = "Main address of this site")
val mainAddress: LogisticAddressVerboseDto,
val mainAddress: LogisticAddressResponse,

@Schema(description = "User defined index to conveniently match this entry to the corresponding entry from the request")
val index: String?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.api.model.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.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto
import org.eclipse.tractusx.bpdm.common.service.DataClassUnwrappedJsonDeserializer

Expand All @@ -34,5 +34,5 @@ data class SitePoolResponse(
val site: SiteVerboseDto,

@Schema(description = "Main address where this site resides")
val mainAddress: LogisticAddressVerboseDto,
val mainAddress: LogisticAddressResponse,
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller

import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.pool.api.PoolAddressApi
import org.eclipse.tractusx.bpdm.pool.api.model.request.AddressPartnerCreateRequest
Expand Down Expand Up @@ -55,15 +55,15 @@ class AddressController(
@PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())")
override fun getAddress(
bpna: String
): LogisticAddressVerboseDto {
): LogisticAddressResponse {
return addressService.findByBpn(bpna.uppercase())
}

@PreAuthorize("hasAuthority(@poolSecurityConfigProperties.getReadPoolPartnerDataAsRole())")
override fun searchAddresses(
addressSearchRequest: AddressPartnerBpnSearchRequest,
paginationRequest: PaginationRequest
): PageResponse<LogisticAddressVerboseDto> {
): PageResponse<LogisticAddressResponse> {
return addressService.findByPartnerAndSiteBpns(addressSearchRequest, paginationRequest)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.pool.controller

import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.SiteVerboseDto
Expand Down Expand Up @@ -103,7 +103,7 @@ class LegalEntityController(
override fun getAddresses(
bpnl: String,
paginationRequest: PaginationRequest
): PageResponse<LogisticAddressVerboseDto> {
): PageResponse<LogisticAddressResponse> {
return addressService.findByPartnerBpn(bpnl.uppercase(), paginationRequest.page, paginationRequest.size)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.pool.service
import jakarta.transaction.Transactional
import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.common.exception.BpdmNotFoundException
import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalAddressResponse
Expand All @@ -40,7 +40,7 @@ class AddressService(
private val legalEntityRepository: LegalEntityRepository,
private val siteRepository: SiteRepository,
) {
fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageResponse<LogisticAddressVerboseDto> {
fun findByPartnerBpn(bpn: String, pageIndex: Int, pageSize: Int): PageResponse<LogisticAddressResponse> {
if (!legalEntityRepository.existsByBpn(bpn)) {
throw BpdmNotFoundException("Business Partner", bpn)
}
Expand All @@ -50,7 +50,7 @@ class AddressService(
return page.toDto(page.content.map { it.toDto() })
}

fun findByBpn(bpn: String): LogisticAddressVerboseDto {
fun findByBpn(bpn: String): LogisticAddressResponse {
val address = logisticAddressRepository.findByBpn(bpn) ?: throw BpdmNotFoundException("Address", bpn)
return address.toDto()
}
Expand All @@ -59,7 +59,7 @@ class AddressService(
fun findByPartnerAndSiteBpns(
searchRequest: AddressPartnerBpnSearchRequest,
paginationRequest: PaginationRequest
): PageResponse<LogisticAddressVerboseDto> {
): PageResponse<LogisticAddressResponse> {
val partners = if (searchRequest.legalEntities.isNotEmpty()) legalEntityRepository.findDistinctByBpnIn(searchRequest.legalEntities) else emptyList()
val sites = if (searchRequest.sites.isNotEmpty()) siteRepository.findDistinctByBpnIn(searchRequest.sites) else emptyList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ fun AddressState.toDto(): AddressStateVerboseDto {
return AddressStateVerboseDto(description, validFrom, validTo, type.toDto())
}

fun LogisticAddress.toDto(): LogisticAddressVerboseDto {
return LogisticAddressVerboseDto(
fun LogisticAddress.toDto(): LogisticAddressResponse {
return LogisticAddressResponse(
bpna = bpn,
bpnLegalEntity = legalEntity?.bpn,
isLegalAddress = legalEntity?.legalAddress == this,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension
import org.assertj.core.api.Assertions.assertThat
import org.eclipse.tractusx.bpdm.common.dto.request.AddressPartnerBpnSearchRequest
import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.pool.Application
import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient
import org.eclipse.tractusx.bpdm.pool.api.model.response.AddressCreateError
Expand Down Expand Up @@ -436,21 +436,21 @@ class AddressControllerIT @Autowired constructor(

testHelpers.assertRecursively(actuals)
.ignoringFields(
AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpna.name,
AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpnLegalEntity.name,
AddressPartnerCreateResponse::address.name + "." + LogisticAddressVerboseDto::bpnSite.name
AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpna.name,
AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpnLegalEntity.name,
AddressPartnerCreateResponse::address.name + "." + LogisticAddressResponse::bpnSite.name
)
.isEqualTo(expected)
}

private fun assertAddressesAreEqual(actuals: Collection<LogisticAddressVerboseDto>, expected: Collection<LogisticAddressVerboseDto>) {
private fun assertAddressesAreEqual(actuals: Collection<LogisticAddressResponse>, expected: Collection<LogisticAddressResponse>) {
actuals.forEach { assertThat(it.bpna).matches(testHelpers.bpnAPattern) }

testHelpers.assertRecursively(actuals)
.ignoringFields(
LogisticAddressVerboseDto::bpna.name,
LogisticAddressVerboseDto::bpnLegalEntity.name,
LogisticAddressVerboseDto::bpnSite.name
LogisticAddressResponse::bpna.name,
LogisticAddressResponse::bpnLegalEntity.name,
LogisticAddressResponse::bpnSite.name
)
.isEqualTo(expected)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
package org.eclipse.tractusx.bpdm.pool.controller

import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.pool.Application
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl
Expand Down Expand Up @@ -76,7 +76,7 @@ class AddressControllerSearchIT @Autowired constructor(
addresses = listOf(RequestValues.addressPartnerCreate4)
)

private lateinit var givenAddress1: LogisticAddressVerboseDto
private lateinit var givenAddress1: LogisticAddressResponse


@BeforeEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration
import com.github.tomakehurst.wiremock.junit5.WireMockExtension
import org.assertj.core.api.Assertions.assertThat
import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PoolLegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.pool.Application
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl
Expand Down Expand Up @@ -525,7 +525,7 @@ class LegalEntityControllerIT @Autowired constructor(
throw IllegalArgumentException("Can't change case of string $value")
}

private fun toLegalAddressResponse(it: LogisticAddressVerboseDto) = LegalAddressResponse(
private fun toLegalAddressResponse(it: LogisticAddressResponse) = LegalAddressResponse(
physicalPostalAddress = it.physicalPostalAddress,
alternativePostalAddress = it.alternativePostalAddress,
bpnLegalEntity = it.bpnLegalEntity!!,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package org.eclipse.tractusx.bpdm.pool.controller

import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest
import org.eclipse.tractusx.bpdm.common.dto.response.LegalEntityVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto
import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressResponse
import org.eclipse.tractusx.bpdm.common.dto.response.PageResponse
import org.eclipse.tractusx.bpdm.pool.Application
import org.eclipse.tractusx.bpdm.pool.api.client.PoolClientImpl
Expand Down Expand Up @@ -69,8 +69,8 @@ class LegalEntityControllerSearchIT @Autowired constructor(
private lateinit var givenPartner2: LegalEntityVerboseDto
private lateinit var legalName1: String
private lateinit var legalName2: String
private lateinit var legalAddress1: LogisticAddressVerboseDto
private lateinit var legalAddress2: LogisticAddressVerboseDto
private lateinit var legalAddress1: LogisticAddressResponse
private lateinit var legalAddress2: LogisticAddressResponse

@BeforeEach
fun beforeEach() {
Expand Down
Loading

0 comments on commit 142f4a0

Please sign in to comment.