diff --git a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt index 40c0e0942..4a4de52fe 100644 --- a/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt +++ b/bpdm-bridge-dummy/src/main/kotlin/com/catenax/bpdm/bridge/dummy/service/GateQueryService.kt @@ -27,7 +27,7 @@ import mu.KotlinLogging import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.* import org.springframework.stereotype.Service import java.time.Instant @@ -47,7 +47,7 @@ class GateQueryService( do { val pageResponse = gateClient.changelog().getInputChangelog( - searchRequest = ChangeLogSearchRequest(timestampAfter = modifiedAfter), + searchRequest = ChangelogSearchRequest(timestampAfter = modifiedAfter), paginationRequest = PaginationRequest(page, bridgeConfigProperties.queryPageSize) ) page++ diff --git a/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/BridgeSyncIT.kt b/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/BridgeSyncIT.kt index 38043fe29..a75a39401 100644 --- a/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/BridgeSyncIT.kt +++ b/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/BridgeSyncIT.kt @@ -30,12 +30,10 @@ import org.eclipse.tractusx.bpdm.common.dto.response.LogisticAddressVerboseDto import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.model.* import org.eclipse.tractusx.bpdm.gate.api.model.request.AddressGateInputRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.LegalEntityGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.request.SiteGateInputRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.SharingStateDto import org.eclipse.tractusx.bpdm.pool.api.client.PoolApiClient -import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.request.LegalEntityPropertiesSearchRequest import org.eclipse.tractusx.bpdm.pool.api.model.response.LegalEntityMatchVerboseDto import org.eclipse.tractusx.bpdm.pool.api.model.response.SitePoolVerboseDto @@ -44,6 +42,8 @@ import org.springframework.beans.factory.annotation.Autowired import org.springframework.boot.test.context.SpringBootTest import org.springframework.test.context.ActiveProfiles import org.springframework.test.context.ContextConfiguration +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest as GateChangelogSearchRequest +import org.eclipse.tractusx.bpdm.pool.api.model.request.ChangelogSearchRequest as PoolChangelogSearchRequest private val DEFAULT_PAGINATION_REQUEST = PaginationRequest(0, 100) @@ -67,7 +67,7 @@ class BridgeSyncIT @Autowired constructor( fun `just use API clients`() { assertGateChangelogHasCount(0) val poolChangelogResponses = poolClient.changelogs().getChangelogEntries( - paginationRequest = DEFAULT_PAGINATION_REQUEST, changelogSearchRequest = ChangelogSearchRequest(timestampAfter = null, bpns = null) + paginationRequest = DEFAULT_PAGINATION_REQUEST, changelogSearchRequest = PoolChangelogSearchRequest(timestampAfter = null, bpns = null) ) assertThat(poolChangelogResponses.contentSize).isZero() bridgeClient.bridge().triggerSync() @@ -220,7 +220,7 @@ class BridgeSyncIT @Autowired constructor( private fun assertGateChangelogHasCount(changelogCount: Int) { val gateChangelogResponses = gateClient.changelog().getInputChangelog( paginationRequest = DEFAULT_PAGINATION_REQUEST, - searchRequest = ChangeLogSearchRequest(timestampAfter = null, businessPartnerTypes = emptySet()) + searchRequest = GateChangelogSearchRequest(timestampAfter = null, businessPartnerTypes = emptySet()) ) assertThat(gateChangelogResponses.contentSize).isEqualTo(changelogCount) } @@ -228,7 +228,7 @@ class BridgeSyncIT @Autowired constructor( private fun assertPoolChangelogHasCount(changelogCount: Int) { val poolChangelogResponses = poolClient.changelogs().getChangelogEntries( paginationRequest = DEFAULT_PAGINATION_REQUEST, - changelogSearchRequest = ChangelogSearchRequest(timestampAfter = null, bpns = null) + changelogSearchRequest = PoolChangelogSearchRequest(timestampAfter = null, bpns = null) ) assertThat(poolChangelogResponses.contentSize).isEqualTo(changelogCount) diff --git a/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/SyncStateIT.kt b/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/SyncStateIT.kt index 51d51a2c3..bfedb9ba8 100644 --- a/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/SyncStateIT.kt +++ b/bpdm-bridge-dummy/src/test/kotlin/com/catenax/bpdm/bridge/dummy/SyncStateIT.kt @@ -29,7 +29,7 @@ import com.github.tomakehurst.wiremock.junit5.WireMockExtension import com.github.tomakehurst.wiremock.verification.LoggedRequest import org.assertj.core.api.Assertions import org.eclipse.tractusx.bpdm.common.service.BaseSyncRecordService -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogGateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogDto import org.junit.jupiter.api.Assertions.assertThrows @@ -125,15 +125,15 @@ class SyncStateIT @Autowired constructor( Assertions.assertThat(loggedRequests.size).isEqualTo(3) // 1st sync polls from initial timestamp (2000-01-01) - val pollFrom1stSync = parseBody(loggedRequests[0]).timestampAfter + val pollFrom1stSync = parseBody(loggedRequests[0]).timestampAfter Assertions.assertThat(pollFrom1stSync).isEqualTo(TS_INITIAL_POLL_FROM) // 2nd sync polls from around timestamp of 1st successful sync - val pollFrom2ndSync = parseBody(loggedRequests[1]).timestampAfter + val pollFrom2ndSync = parseBody(loggedRequests[1]).timestampAfter Assertions.assertThat(pollFrom2ndSync).isBetween(tsBefore1stSuccessfulSync, tsAfter1stSuccessfulSync) // 3rd sync polls from around timestamp of 2nd successful sync - val pollFrom3rdSync = parseBody(loggedRequests[2]).timestampAfter + val pollFrom3rdSync = parseBody(loggedRequests[2]).timestampAfter Assertions.assertThat(pollFrom3rdSync).isBetween(tsBefore2ndSuccessfulSync, tsAfter2ndSuccessfulSync) } @@ -211,23 +211,23 @@ class SyncStateIT @Autowired constructor( Assertions.assertThat(loggedRequests.size).isEqualTo(5) // 1st sync polls from initial timestamp (2000-01-01) - val pollFrom1stSync = parseBody(loggedRequests[0]).timestampAfter + val pollFrom1stSync = parseBody(loggedRequests[0]).timestampAfter Assertions.assertThat(pollFrom1stSync).isEqualTo(TS_INITIAL_POLL_FROM) // 2nd sync polls from around timestamp of 1st successful sync - val pollFrom2ndSync = parseBody(loggedRequests[1]).timestampAfter + val pollFrom2ndSync = parseBody(loggedRequests[1]).timestampAfter Assertions.assertThat(pollFrom2ndSync).isBetween(tsBefore1stSuccessfulSync, tsAfter1stSuccessfulSync) // 3rd sync still polls from same timestamp because last sync has failed! - val pollFrom3rdSync = parseBody(loggedRequests[2]).timestampAfter + val pollFrom3rdSync = parseBody(loggedRequests[2]).timestampAfter Assertions.assertThat(pollFrom3rdSync).isEqualTo(pollFrom2ndSync) // 4th sync still polls from same timestamp because last sync has failed! - val pollFrom4thSync = parseBody(loggedRequests[3]).timestampAfter + val pollFrom4thSync = parseBody(loggedRequests[3]).timestampAfter Assertions.assertThat(pollFrom4thSync).isEqualTo(pollFrom2ndSync) // 5th sync polls from around timestamp of 2nd successful sync - val pollFrom5thSync = parseBody(loggedRequests[4]).timestampAfter + val pollFrom5thSync = parseBody(loggedRequests[4]).timestampAfter Assertions.assertThat(pollFrom5thSync).isBetween(tsBefore2ndSuccessfulSync, tsAfter2ndSuccessfulSync) } diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt index cad9a1c5c..cb741b967 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/GateChangelogApi.kt @@ -25,7 +25,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse import io.swagger.v3.oas.annotations.responses.ApiResponses import jakarta.validation.Valid import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogGateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogDto import org.springdoc.core.annotations.ParameterObject @@ -53,7 +53,7 @@ interface GateChangelogApi { @PostExchange("/input/changelog/search") fun getInputChangelog( @ParameterObject @Valid paginationRequest: PaginationRequest, - @RequestBody searchRequest: ChangeLogSearchRequest + @RequestBody searchRequest: ChangelogSearchRequest ): PageChangeLogDto @@ -71,6 +71,6 @@ interface GateChangelogApi { @PostExchange("/output/changelog/search") fun getOutputChangelog( @ParameterObject @Valid paginationRequest: PaginationRequest, - @RequestBody searchRequest: ChangeLogSearchRequest + @RequestBody searchRequest: ChangelogSearchRequest ): PageChangeLogDto } \ No newline at end of file diff --git a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangelogSearchRequest.kt similarity index 97% rename from bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt rename to bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangelogSearchRequest.kt index 0badc2023..7599713b0 100644 --- a/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangeLogSearchRequest.kt +++ b/bpdm-gate-api/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/api/model/request/ChangelogSearchRequest.kt @@ -23,7 +23,7 @@ import io.swagger.v3.oas.annotations.Parameter import org.eclipse.tractusx.bpdm.common.dto.BusinessPartnerType import java.time.Instant -data class ChangeLogSearchRequest( +data class ChangelogSearchRequest( @field:Parameter(description = "From when to search changelog entries", example = "2023-03-20T10:23:28.194Z", required = false) val timestampAfter: Instant? = null, diff --git a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt index 9aec7a5ee..148a729a1 100644 --- a/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt +++ b/bpdm-gate/src/main/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangelogController.kt @@ -22,7 +22,7 @@ package org.eclipse.tractusx.bpdm.gate.controller import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.common.model.OutputInputEnum import org.eclipse.tractusx.bpdm.gate.api.GateChangelogApi -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogGateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.PageChangeLogDto import org.eclipse.tractusx.bpdm.gate.service.ChangelogService @@ -38,7 +38,7 @@ class ChangelogController( @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyInputDataAsRole())") override fun getInputChangelog( - paginationRequest: PaginationRequest, searchRequest: ChangeLogSearchRequest + paginationRequest: PaginationRequest, searchRequest: ChangelogSearchRequest ): PageChangeLogDto { return changelogService.getChangeLogEntries( searchRequest.externalIds, @@ -53,7 +53,7 @@ class ChangelogController( @PreAuthorize("hasAuthority(@gateSecurityConfigProperties.getReadCompanyOutputDataAsRole())") override fun getOutputChangelog( paginationRequest: PaginationRequest, - searchRequest: ChangeLogSearchRequest + searchRequest: ChangelogSearchRequest ): PageChangeLogDto { return changelogService.getChangeLogEntries( searchRequest.externalIds, diff --git a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt index 4608057b0..239744975 100644 --- a/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt +++ b/bpdm-gate/src/test/kotlin/org/eclipse/tractusx/bpdm/gate/controller/ChangeLogControllerIT.kt @@ -48,7 +48,7 @@ import org.eclipse.tractusx.bpdm.common.dto.request.PaginationRequest import org.eclipse.tractusx.bpdm.gate.api.client.GateClient import org.eclipse.tractusx.bpdm.gate.api.exception.ChangeLogOutputError import org.eclipse.tractusx.bpdm.gate.api.model.ChangelogType -import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangeLogSearchRequest +import org.eclipse.tractusx.bpdm.gate.api.model.request.ChangelogSearchRequest import org.eclipse.tractusx.bpdm.gate.api.model.response.ChangelogGateDto import org.eclipse.tractusx.bpdm.gate.api.model.response.ErrorInfo import org.eclipse.tractusx.bpdm.gate.entity.ChangelogEntry @@ -99,7 +99,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id`() { - val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1)) + val searchRequest = ChangelogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1)) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -117,7 +117,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id not found`() { - val searchRequest = ChangeLogSearchRequest(externalIds = setOf("NONEXIST")) + val searchRequest = ChangelogSearchRequest(externalIds = setOf("NONEXIST")) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -152,7 +152,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by external id and timeStamp`() { - val searchRequest = ChangeLogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1), timestampAfter = instant) + val searchRequest = ChangelogSearchRequest(externalIds = setOf(CommonValues.externalIdAddress1), timestampAfter = instant) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -168,7 +168,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by businessPartnerType`() { - val searchRequest = ChangeLogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamAddress)) + val searchRequest = ChangelogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamAddress)) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -189,7 +189,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog by businessPartnerType not found`() { - val searchRequest = ChangeLogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamNotFound)) + val searchRequest = ChangelogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamNotFound)) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -204,7 +204,7 @@ internal class ChangeLogControllerIT @Autowired constructor( */ @Test fun `get changeLog by businessPartnerType and timeStamp`() { - val searchRequest = ChangeLogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamAddress), timestampAfter = instant) + val searchRequest = ChangelogSearchRequest(businessPartnerTypes = setOf(businessPartnerTypeParamAddress), timestampAfter = instant) val searchResult = gateClient.changelog().getInputChangelog(PaginationRequest(), searchRequest) @@ -225,7 +225,7 @@ internal class ChangeLogControllerIT @Autowired constructor( @Test fun `get changeLog from timeStamp`() { - val searchRequest = ChangeLogSearchRequest(businessPartnerTypes = emptySet(), timestampAfter = instant) + val searchRequest = ChangelogSearchRequest(businessPartnerTypes = emptySet(), timestampAfter = instant) val searchResult = gateClient.changelog().getInputChangelog(paginationRequest = PaginationRequest(), searchRequest)