-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
193 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...kotlin/org/eclipse/tractusx/bpdm/test/system/stepdefinations/ShareGenericNoBpnStepDefs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
******************************************************************************/ | ||
|
||
package org.eclipse.tractusx.bpdm.test.system.stepdefinations | ||
|
||
import io.cucumber.java.en.Given | ||
import io.cucumber.java.en.Then | ||
import io.cucumber.java.en.When | ||
import org.eclipse.tractusx.bpdm.common.dto.AddressType | ||
import org.eclipse.tractusx.bpdm.common.dto.PaginationRequest | ||
import org.eclipse.tractusx.bpdm.gate.api.client.GateClient | ||
import org.eclipse.tractusx.bpdm.test.system.SpringTestRunConfiguration | ||
import org.eclipse.tractusx.bpdm.test.system.config.TestRunData | ||
import org.eclipse.tractusx.bpdm.test.system.utils.* | ||
|
||
class ShareGenericNoBpnStepDefs( | ||
private val gateInputDataFactory: GateInputFactory, | ||
private val gateOutputFactory: GateOutputFactory, | ||
private val gateClient: GateClient, | ||
private val stepUtils: StepUtils, | ||
private val testRunData: TestRunData | ||
): SpringTestRunConfiguration() { | ||
|
||
@Given("^output \"([^\"]*)\" with external-ID \"([^\"]*)\"$") | ||
fun `given output seed with externalId`(seed: String, externalId: String) { | ||
uploadInput(seed, externalId, null) | ||
stepUtils.waitForResult(testRunData.toExternalId(externalId)) | ||
} | ||
|
||
@When("^the sharing member uploads full valid input \"([^\"]*)\" with external-ID \"([^\"]*)\" with address type \"([^\"]*)\"$") | ||
fun `when the sharing member uploads input seed with address type`(seed: String, externalId: String, addressType: String) { | ||
uploadInput(seed, externalId, AddressType.valueOf(addressType)) | ||
} | ||
|
||
@When("^the sharing member uploads full valid input \"([^\"]*)\" with external-ID \"([^\"]*)\" without address type") | ||
fun `when the sharing member uploads input seed without address type`(seed: String, externalId: String) { | ||
uploadInput(seed, externalId, null) | ||
} | ||
|
||
@Then("^the sharing member receives output \"([^\"]*)\" with external-ID \"([^\"]*)\" with address type \"([^\"]*)\"$") | ||
fun `then the sharing member receives output seed with modifier`(seed: String, externalId: String, addressType: String) { | ||
val expectedOutput = gateOutputFactory.createOutput(seed, externalId) | ||
.withAddressType(AddressType.valueOf(addressType)) | ||
// On no auth config we can't get own company data to true | ||
.copy(isOwnCompanyData = false) | ||
|
||
stepUtils.waitForResult(expectedOutput.externalId) | ||
|
||
val actualOutput = gateClient.businessParters.getBusinessPartnersOutput(listOf(expectedOutput.externalId), PaginationRequest()).content.single() | ||
|
||
stepUtils.assertEqualIgnoreBpns(actualOutput, expectedOutput) | ||
} | ||
|
||
|
||
private fun uploadInput(seed: String, externalId: String, addressType: AddressType?){ | ||
val inputRequest = gateInputDataFactory.createFullValid(seed, externalId).withAddressType(addressType).withoutAnyBpn() | ||
gateClient.businessParters.upsertBusinessPartnersInput(listOf(inputRequest)) | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
bpdm-system-tester/src/main/kotlin/org/eclipse/tractusx/bpdm/test/system/utils/StepUtils.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021,2024 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Apache License, Version 2.0 which is available at | ||
* https://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
******************************************************************************/ | ||
|
||
package org.eclipse.tractusx.bpdm.test.system.utils | ||
|
||
import kotlinx.coroutines.runBlocking | ||
import kotlinx.coroutines.time.delay | ||
import kotlinx.coroutines.time.withTimeout | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.eclipse.tractusx.bpdm.common.dto.PaginationRequest | ||
import org.eclipse.tractusx.bpdm.gate.api.client.GateClient | ||
import org.eclipse.tractusx.bpdm.gate.api.model.ConfidenceCriteriaDto | ||
import org.eclipse.tractusx.bpdm.gate.api.model.SharingStateType | ||
import org.eclipse.tractusx.bpdm.gate.api.model.response.AddressComponentOutputDto | ||
import org.eclipse.tractusx.bpdm.gate.api.model.response.BusinessPartnerOutputDto | ||
import org.eclipse.tractusx.bpdm.gate.api.model.response.LegalEntityRepresentationOutputDto | ||
import org.eclipse.tractusx.bpdm.gate.api.model.response.SiteRepresentationOutputDto | ||
import java.time.Duration | ||
|
||
class StepUtils( | ||
private val gateClient: GateClient | ||
) { | ||
|
||
fun waitForResult(externalId: String): SharingStateType = runBlocking { | ||
println("Waiting for result for $externalId ...") | ||
withTimeout(Duration.ofMinutes(3)) { | ||
while (true) { | ||
val sharingState = gateClient.sharingState.getSharingStates(PaginationRequest(), listOf(externalId)).content.single() | ||
if (sharingState.sharingStateType == SharingStateType.Success || sharingState.sharingStateType == SharingStateType.Error) { | ||
return@withTimeout sharingState.sharingStateType | ||
} | ||
delay(Duration.ofSeconds(10)) | ||
} | ||
} as SharingStateType | ||
} | ||
|
||
fun assertEqualIgnoreBpns(actualOutput: BusinessPartnerOutputDto, expectedOutput: BusinessPartnerOutputDto){ | ||
assertThat(actualOutput) | ||
.usingRecursiveComparison() | ||
.ignoringCollectionOrder() | ||
.ignoringFields(*ignoredFields) | ||
.isEqualTo(expectedOutput) | ||
} | ||
|
||
val ignoredFields = arrayOf( | ||
BusinessPartnerOutputDto::createdAt.name, | ||
BusinessPartnerOutputDto::updatedAt.name, | ||
"${BusinessPartnerOutputDto::legalEntity.name}.${LegalEntityRepresentationOutputDto::legalEntityBpn.name}", | ||
"${BusinessPartnerOutputDto::site.name}.${SiteRepresentationOutputDto::siteBpn.name}", | ||
"${BusinessPartnerOutputDto::address.name}.${AddressComponentOutputDto::addressBpn.name}", | ||
// ToDo: Cleaning service dummy should have fixed confidence criteria dummy times otherwise we need to keep ignoring these fields | ||
"${BusinessPartnerOutputDto::legalEntity.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::lastConfidenceCheckAt.name}", | ||
"${BusinessPartnerOutputDto::legalEntity.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::nextConfidenceCheckAt.name}", | ||
"${BusinessPartnerOutputDto::site.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::lastConfidenceCheckAt.name}", | ||
"${BusinessPartnerOutputDto::site.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::nextConfidenceCheckAt.name}", | ||
"${BusinessPartnerOutputDto::address.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::lastConfidenceCheckAt.name}", | ||
"${BusinessPartnerOutputDto::address.name}.${AddressComponentOutputDto::confidenceCriteria.name}.${ConfidenceCriteriaDto::nextConfidenceCheckAt.name}", | ||
) | ||
|
||
|
||
} |
11 changes: 0 additions & 11 deletions
11
bpdm-system-tester/src/main/resources/cucumber/create_and_update_business_partner.feature
This file was deleted.
Oops, something went wrong.
20 changes: 20 additions & 0 deletions
20
bpdm-system-tester/src/main/resources/cucumber/share_generic_business_partner.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Feature: Share Valid Generic Business Partner without BPNs | ||
Scenario: Update Without Address Type | ||
Given output "CC_SHG_UWAT_1" with external-ID "CC_SHG_UWAT" | ||
When the sharing member uploads full valid input "CC_SHG_UWAT_2" with external-ID "CC_SHG_UWAT" without address type | ||
Then the sharing member receives output "CC_SHG_UWAT_2" with external-ID "CC_SHG_UWAT" with address type "LegalAndSiteMainAddress" | ||
|
||
Scenario: Share Without Address Type | ||
When the sharing member uploads full valid input "CC_SHG_WAT" with external-ID "CC_SHG_WAT" without address type | ||
Then the sharing member receives output "CC_SHG_WAT" with external-ID "CC_SHG_WAT" with address type "LegalAndSiteMainAddress" | ||
|
||
Scenario: Share With Address Type | ||
When the sharing member uploads full valid input "CC_SHG_WAT" with external-ID "CC_SHG_WAT" with address type "<inputAddressType>" | ||
Then the sharing member receives output "CC_SHG_WAT" with external-ID "CC_SHG_WAT" with address type "<outputAddressType>" | ||
|
||
Examples: | ||
| inputAddressType | outputAddressType | | ||
| LegalAndSiteMainAddress | LegalAndSiteMainAddress | | ||
| LegalAddress | LegalAndSiteMainAddress | | ||
| SiteMainAddress | SiteMainAddress | | ||
| AdditionalAddress | AdditionalAddress | |
11 changes: 0 additions & 11 deletions
11
...-system-tester/src/main/resources/cucumber/validate_business_partner_address_type.feature
This file was deleted.
Oops, something went wrong.
14 changes: 0 additions & 14 deletions
14
...ystem-tester/src/main/resources/cucumber/validate_business_partner_cleaning_error.feature
This file was deleted.
Oops, something went wrong.