Skip to content

Commit

Permalink
Merge pull request #928 from eclipse-tractusx/fix/gate-api/business-p…
Browse files Browse the repository at this point in the history
…artner-types

fix(gate): remove unused business partner type filter from sharing state
  • Loading branch information
nicoprow authored May 20, 2024
2 parents 3fd7d38 + 731b756 commit 9910dda
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ interface GateSharingStateApi {
@GetMapping
fun getSharingStates(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@Parameter(description = "Business partner type") @RequestParam(required = false) businessPartnerType: BusinessPartnerType?,
@Parameter(description = "External IDs") @RequestParam(required = false) externalIds: Collection<String>?
): PageDto<SharingStateDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ interface SharingStateApiClient : GateSharingStateApi {
@GetExchange
override fun getSharingStates(
@ParameterObject @Valid paginationRequest: PaginationRequest,
@Parameter(description = "Business partner type") @RequestParam(required = false) businessPartnerType: BusinessPartnerType?,
@Parameter(description = "External IDs") @RequestParam(required = false) externalIds: Collection<String>?
): PageDto<SharingStateDto>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ class SharingStateController(
@PreAuthorize("hasAuthority(${PermissionConfigProperties.READ_SHARING_STATE})")
override fun getSharingStates(
paginationRequest: PaginationRequest,
businessPartnerType: BusinessPartnerType?,
externalIds: Collection<String>?
): PageDto<SharingStateDto> {
return sharingStateService.findSharingStates(paginationRequest, externalIds, getCurrentUserBpn())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ abstract class AuthTestBase(

@Test
fun `GET Sharing State`() {
authAssertions.assert(authExpectations.sharingState.getSharingState) { gateClient.sharingState.getSharingStates(PaginationRequest(), null, null) }
authAssertions.assert(authExpectations.sharingState.getSharingState) { gateClient.sharingState.getSharingStates(PaginationRequest(), null) }
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(
)
)

val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)


assertHelpers.assertRecursively(upsertSharingStateResponses).isEqualTo(upsertSharingStatesRequests)
Expand Down Expand Up @@ -175,7 +175,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(

//Firstly verifies if the Sharing States was created for new Business Partners
val externalIds = listOf(externalId4, externalId5)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers
.assertRecursively(upsertSharingStateResponses)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
Expand Down Expand Up @@ -204,7 +204,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(
)

//Check for both Sharing State changes (Error and Success)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers.assertRecursively(readCleanedSharingState)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
.isEqualTo(cleanedSharingState)
Expand Down Expand Up @@ -240,7 +240,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(

//Firstly verifies if the Sharing States was created for new Business Partner
val externalIds = listOf(externalId3)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers
.assertRecursively(upsertSharingStateResponses)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
Expand All @@ -261,7 +261,7 @@ class BusinessPartnerControllerAndSharingControllerIT @Autowired constructor(
)

//Check for Sharing State
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers.assertRecursively(readCleanedSharingState)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
.isEqualTo(cleanedSharingState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ class BusinessPartnerControllerIT @Autowired constructor(
)
)

val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)


assertHelpers.assertRecursively(upsertSharingStateResponses).isEqualTo(upsertSharingStatesRequests)
Expand Down Expand Up @@ -312,7 +312,7 @@ class BusinessPartnerControllerIT @Autowired constructor(

//Firstly verifies if the Sharing States was created for new Business Partners
val externalIds = listOf(externalId4, externalId5)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers
.assertRecursively(upsertSharingStateResponses)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
Expand Down Expand Up @@ -341,7 +341,7 @@ class BusinessPartnerControllerIT @Autowired constructor(
)

//Check for both Sharing State changes (Error and Success)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers.assertRecursively(readCleanedSharingState)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
.isEqualTo(cleanedSharingState)
Expand Down Expand Up @@ -377,7 +377,7 @@ class BusinessPartnerControllerIT @Autowired constructor(

//Firstly verifies if the Sharing States was created for new Business Partner
val externalIds = listOf(externalId3)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val upsertSharingStateResponses = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers
.assertRecursively(upsertSharingStateResponses)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
Expand All @@ -398,7 +398,7 @@ class BusinessPartnerControllerIT @Autowired constructor(
)

//Check for Sharing State
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(BusinessPartnerType.GENERIC, externalIds)
val readCleanedSharingState = this.mockAndAssertUtils.readSharingStates(externalIds)
assertHelpers.assertRecursively(readCleanedSharingState)
.ignoringFieldsMatchingRegexes(".*${SharingStateDto::sharingProcessStarted.name}")
.isEqualTo(cleanedSharingState)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,9 @@ class MockAndAssertUtils @Autowired constructor(
)
}

fun readSharingStates(businessPartnerType: BusinessPartnerType?, externalIds: Collection<String>?): Collection<SharingStateDto> {
fun readSharingStates(externalIds: Collection<String>?): Collection<SharingStateDto> {

return gateClient.sharingState.getSharingStates(PaginationRequest(), businessPartnerType, externalIds).content
return gateClient.sharingState.getSharingStates(PaginationRequest(), externalIds).content
}

fun assertUpsertOutputResponsesMatchRequests(responses: Collection<BusinessPartnerOutputDto>, requests: List<BusinessPartnerOutputDto>) {
Expand Down Expand Up @@ -281,7 +281,7 @@ class MockAndAssertUtils @Autowired constructor(
org.junit.jupiter.api.Assertions.assertEquals(upsertedBusinessPartners.size.toLong(), searchResponsePage.totalElements)
assertHelpers.assertRecursively(searchResponsePage.content).isEqualTo(upsertedBusinessPartners)

val sharingStateResponse = gateClient.sharingState.getSharingStates(PaginationRequest(), businessPartnerType = null, externalIds = null)
val sharingStateResponse = gateClient.sharingState.getSharingStates(PaginationRequest(), externalIds = null)
org.junit.jupiter.api.Assertions.assertEquals(upsertedBusinessPartners.size.toLong(), sharingStateResponse.totalElements)
Assertions.assertThat(sharingStateResponse.content).isEqualTo(
upsertedBusinessPartners.map {
Expand Down

0 comments on commit 9910dda

Please sign in to comment.