From 731b75699e282b89929bf9383109bd9a0e97e8d1 Mon Sep 17 00:00:00 2001 From: Nico Koprowski Date: Mon, 20 May 2024 11:54:01 +0200 Subject: [PATCH] fix(gate): remove unused business partner type filter from sharing state --- .../tractusx/bpdm/gate/api/GateSharingStateApi.kt | 1 - .../bpdm/gate/api/client/SharingStateApiClient.kt | 1 - .../bpdm/gate/controller/SharingStateController.kt | 1 - .../eclipse/tractusx/bpdm/gate/auth/AuthTestBase.kt | 2 +- .../BusinessPartnerControllerAndSharingControllerIT.kt | 10 +++++----- .../gate/controller/BusinessPartnerControllerIT.kt | 10 +++++----- .../tractusx/bpdm/gate/util/MockAndAssertUtils.kt | 6 +++--- 7 files changed, 14 insertions(+), 17 deletions(-) diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt index ea49eb3e5..24eb72ff5 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateSharingStateApi.kt @@ -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? ): PageDto diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/SharingStateApiClient.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/SharingStateApiClient.kt index c71754d84..739efc4ba 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/SharingStateApiClient.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/client/SharingStateApiClient.kt @@ -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? ): PageDto diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt index 2e121b717..42e60cbbb 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/SharingStateController.kt @@ -41,7 +41,6 @@ class SharingStateController( @PreAuthorize("hasAuthority(${PermissionConfigProperties.READ_SHARING_STATE})") override fun getSharingStates( paginationRequest: PaginationRequest, - businessPartnerType: BusinessPartnerType?, externalIds: Collection? ): PageDto { return sharingStateService.findSharingStates(paginationRequest, externalIds, getCurrentUserBpn()) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/auth/AuthTestBase.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/auth/AuthTestBase.kt index 2d5730153..4d4240360 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/auth/AuthTestBase.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/auth/AuthTestBase.kt @@ -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 diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt index 50dac0727..00b4db1dc 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/BusinessPartnerControllerAndSharingControllerIT.kt @@ -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) @@ -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}") @@ -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) @@ -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}") @@ -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) 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 28a962d07..638f6a613 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 @@ -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) @@ -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}") @@ -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) @@ -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}") @@ -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) diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt index 7d02934b8..09b391789 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/util/MockAndAssertUtils.kt @@ -229,9 +229,9 @@ class MockAndAssertUtils @Autowired constructor( ) } - fun readSharingStates(businessPartnerType: BusinessPartnerType?, externalIds: Collection?): Collection { + fun readSharingStates(externalIds: Collection?): Collection { - return gateClient.sharingState.getSharingStates(PaginationRequest(), businessPartnerType, externalIds).content + return gateClient.sharingState.getSharingStates(PaginationRequest(), externalIds).content } fun assertUpsertOutputResponsesMatchRequests(responses: Collection, requests: List) { @@ -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 {