forked from boschresearch/catena-x-edc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add business test for http proxy transfer
Signed-off-by: Dominik Pinsel <dominik.pinsel@daimler.com>
- Loading branch information
1 parent
d46894f
commit 32c04be
Showing
21 changed files
with
343 additions
and
144 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
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
68 changes: 68 additions & 0 deletions
68
edc-tests/src/test/java/org/eclipse/tractusx/edc/tests/HttpProxyTransferSteps.java
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,68 @@ | ||
package org.eclipse.tractusx.edc.tests; | ||
|
||
import io.cucumber.datatable.DataTable; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
import java.io.IOException; | ||
import java.util.List; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.eclipse.tractusx.edc.tests.data.Asset; | ||
import org.eclipse.tractusx.edc.tests.data.ContractNegotiation; | ||
import org.eclipse.tractusx.edc.tests.data.DataAddress; | ||
import org.eclipse.tractusx.edc.tests.data.HttpProxySinkDataAddress; | ||
import org.eclipse.tractusx.edc.tests.data.HttpProxySourceDataAddress; | ||
import org.eclipse.tractusx.edc.tests.data.Transfer; | ||
import org.junit.jupiter.api.Assertions; | ||
|
||
@Slf4j | ||
public class HttpProxyTransferSteps { | ||
|
||
private static final String ID = "id"; | ||
private static final String DESCRIPTION = "description"; | ||
private static final String BASE_URL = "baseUrl"; | ||
private static final String DEFINITION_ID = "definition id"; | ||
private static final String ASSET_ID = "asset id"; | ||
|
||
@Given("'{connector}' has a http proxy assets") | ||
public void hasAssets(Connector connector, DataTable table) throws Exception { | ||
final DataManagementAPI api = connector.getDataManagementAPI(); | ||
|
||
for (var map : table.asMaps()) { | ||
final String id = map.get(ID); | ||
final String description = map.get(DESCRIPTION); | ||
final String baseUrl = map.get(BASE_URL); | ||
|
||
final DataAddress address = new HttpProxySourceDataAddress(baseUrl); | ||
final Asset asset = new Asset(id, description, address); | ||
|
||
api.createAsset(asset); | ||
} | ||
} | ||
|
||
@When("'{connector}' initiates HttpProxy transfer from '{connector}'") | ||
public void sokratesInitiateHttpProxyTransferProcessFromPlato( | ||
Connector consumer, Connector provider, DataTable dataTable) throws IOException { | ||
final DataManagementAPI api = consumer.getDataManagementAPI(); | ||
final String receiverUrl = provider.getEnvironment().getIdsUrl() + "/data"; | ||
|
||
final List<ContractNegotiation> negotiation = api.getNegotiations(); | ||
final String agreementId = negotiation.get(0).getAgreementId(); | ||
final DataAddress dataAddress = new HttpProxySinkDataAddress(); | ||
|
||
for (var map : dataTable.asMaps()) { | ||
final String assetId = map.get(ASSET_ID); | ||
final Transfer transfer = | ||
api.initiateTransferProcess(receiverUrl, agreementId, assetId, dataAddress); | ||
|
||
transfer.waitUntilComplete(api); | ||
} | ||
} | ||
|
||
@Then("the backend application of '{connector}' has received data") | ||
public void theBackendApplicationOfSocratesHasReceivedData(Connector consumer) { | ||
final BackendServiceBackendAPI api = consumer.getBackendServiceBackendAPI(); | ||
final List<String> transferredData = api.list("/"); | ||
Assertions.assertNotEquals(0, transferredData.size()); | ||
} | ||
} |
Oops, something went wrong.