Skip to content

Commit

Permalink
fix: resolving pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hamidonos committed Oct 27, 2023
1 parent 09fe21f commit 9a02841
Show file tree
Hide file tree
Showing 16 changed files with 92 additions and 118 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.samples.advanced.advanced00opentelemetry;
package org.eclipse.edc.samples.advanced;

import org.apache.http.HttpStatus;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
Expand All @@ -30,20 +30,20 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.transfer.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.transfer.TransferUtil.startTransfer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createAsset;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createContractDefinition;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createPolicy;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.getContractAgreementId;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.createAsset;
import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition;
import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy;
import static org.eclipse.edc.samples.common.NegotiationCommon.getContractAgreementId;
import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

@EndToEndTest
@Testcontainers
public class Advanced00openTelemetryTest {
public class Advanced01openTelemetryTest {

private static final String DOCKER_COMPOSE_YAML = "advanced/advanced-01-open-telemetry/docker-compose.yaml";
private static final String NEGOTIATE_CONTRACT_FILE_PATH = "advanced/advanced-01-open-telemetry/resources/negotiate-contract.json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*
* Contributors:
* Microsoft Corporation - initial test implementation for sample
* Mercedes-Benz Tech Innovation GmbH - refactor test cases
*
*/

package org.eclipse.edc.samples.transfer;
package org.eclipse.edc.samples.common;

import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.http.ContentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,18 @@
*
*/

package org.eclipse.edc.samples.transfer.transfer01negotiation;
package org.eclipse.edc.samples.common;


import java.util.Objects;

import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.TransferUtil.POLL_INTERVAL;
import static org.eclipse.edc.samples.transfer.TransferUtil.TIMEOUT;
import static org.eclipse.edc.samples.transfer.TransferUtil.get;
import static org.eclipse.edc.samples.transfer.TransferUtil.post;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.CONSUMER_MANAGEMENT_URL;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.PROVIDER_MANAGEMENT_URL;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.util.TransferUtil.POLL_INTERVAL;
import static org.eclipse.edc.samples.util.TransferUtil.TIMEOUT;
import static org.eclipse.edc.samples.util.TransferUtil.get;
import static org.eclipse.edc.samples.util.TransferUtil.post;

public class NegotiationCommon {

Expand All @@ -43,23 +41,23 @@ public class NegotiationCommon {
private static final String CONTRACT_AGREEMENT_ID = "'edc:contractAgreementId'";

public static void createAsset() {
post(PROVIDER_MANAGEMENT_URL + V2_ASSETS_PATH, getFileContentFromRelativePath(CREATE_ASSET_FILE_PATH));
post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_ASSETS_PATH, getFileContentFromRelativePath(CREATE_ASSET_FILE_PATH));
}

public static void createPolicy() {
post(PROVIDER_MANAGEMENT_URL + V2_POLICY_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_POLICY_FILE_PATH));
post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_POLICY_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_POLICY_FILE_PATH));
}

public static void createContractDefinition() {
post(PROVIDER_MANAGEMENT_URL + V2_CONTRACT_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_CONTRACT_DEFINITION_FILE_PATH));
post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V2_CONTRACT_DEFINITIONS_PATH, getFileContentFromRelativePath(CREATE_CONTRACT_DEFINITION_FILE_PATH));
}

public static void fetchCatalog() {
post(CONSUMER_MANAGEMENT_URL + V2_CATALOG_REQUEST_PATH, getFileContentFromRelativePath(FETCH_CATALOG_FILE_PATH));
post(PrerequisitesCommon.CONSUMER_MANAGEMENT_URL + V2_CATALOG_REQUEST_PATH, getFileContentFromRelativePath(FETCH_CATALOG_FILE_PATH));
}

public static String negotiateContract(String negotiateContractFilePath) {
var contractNegotiationId = post(CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH, getFileContentFromRelativePath(negotiateContractFilePath), CONTRACT_NEGOTIATION_ID);
var contractNegotiationId = post(PrerequisitesCommon.CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH, getFileContentFromRelativePath(negotiateContractFilePath), CONTRACT_NEGOTIATION_ID);
assertThat(contractNegotiationId).isNotEmpty();
return contractNegotiationId;
}
Expand All @@ -72,7 +70,7 @@ public static String getContractAgreementId(String contractNegotiationId) {
return await()
.atMost(TIMEOUT)
.pollInterval(POLL_INTERVAL)
.until(() -> get(CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH + contractNegotiationId, CONTRACT_AGREEMENT_ID), Objects::nonNull);
.until(() -> get(PrerequisitesCommon.CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH + contractNegotiationId, CONTRACT_AGREEMENT_ID), Objects::nonNull);
}

public static String runNegotiation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.samples.transfer.transfer00prerequisites;
package org.eclipse.edc.samples.common;

import io.restassured.http.ContentType;
import org.apache.http.HttpStatus;
Expand All @@ -21,7 +21,7 @@
import java.util.Map;

import static io.restassured.RestAssured.given;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

public class PrerequisitesCommon {
public static final String API_KEY_HEADER_KEY = "X-Api-Key";
Expand Down Expand Up @@ -65,13 +65,8 @@ public static void registerDataPlaneProvider() {
registerDataPlane(PROVIDER_MANAGEMENT_URL, REGISTER_DATA_PLANE_PROVIDER_JSON);
}

public static void registerDataPlaneConsumer() {
registerDataPlane(CONSUMER_MANAGEMENT_URL, REGISTER_DATA_PLANE_CONSUMER_JSON);
}

public static void runPrerequisites() {
registerDataPlaneProvider();
registerDataPlaneConsumer();
}

private static EdcRuntimeExtension getConnector(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
*
*/

package org.eclipse.edc.samples.transfer.transfer00prerequisites;
package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.registerDataPlaneConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.registerDataPlaneProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.registerDataPlaneProvider;

@EndToEndTest
public class Transfer00prerequisitesTest {
Expand All @@ -36,6 +35,5 @@ public class Transfer00prerequisitesTest {
@Test
void runSampleSteps() {
registerDataPlaneProvider();
registerDataPlaneConsumer();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
*
*/

package org.eclipse.edc.samples.transfer.transfer01negotiation;
package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createAsset;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createContractDefinition;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.createPolicy;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.fetchCatalog;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.getContractAgreementId;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.NegotiationCommon.createAsset;
import static org.eclipse.edc.samples.common.NegotiationCommon.createContractDefinition;
import static org.eclipse.edc.samples.common.NegotiationCommon.createPolicy;
import static org.eclipse.edc.samples.common.NegotiationCommon.fetchCatalog;
import static org.eclipse.edc.samples.common.NegotiationCommon.getContractAgreementId;
import static org.eclipse.edc.samples.common.NegotiationCommon.negotiateContract;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;

@EndToEndTest
public class Transfer01negotiationTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@
*
* Contributors:
* Microsoft Corporation - initial test implementation for sample
* Mercedes-Benz Tech Innovation GmbH - refactor test cases
*
*/

package org.eclipse.edc.samples.transfer.transfer02consumerpull;
package org.eclipse.edc.samples.transfer;

import org.apache.http.HttpStatus;
import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.samples.transfer.HttpRequestLoggerConsumer;
import org.eclipse.edc.samples.util.HttpRequestLoggerConsumer;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand All @@ -29,17 +30,17 @@
import static io.restassured.RestAssured.given;
import static org.apache.http.HttpHeaders.AUTHORIZATION;
import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.transfer.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.transfer.TransferUtil.startTransfer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.API_KEY_HEADER_KEY;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.API_KEY_HEADER_VALUE;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.CONSUMER_PUBLIC_URL;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_KEY;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.API_KEY_HEADER_VALUE;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.CONSUMER_PUBLIC_URL;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;
import static org.hamcrest.Matchers.emptyString;
import static org.hamcrest.Matchers.not;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
*
* Contributors:
* Microsoft Corporation - initial test implementation for sample
* Mercedes-Benz Tech Innovation GmbH - refactor test cases
*
*/

package org.eclipse.edc.samples.transfer.transfer03providerpush;
package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
import org.eclipse.edc.junit.extensions.EdcRuntimeExtension;
import org.eclipse.edc.samples.transfer.HttpRequestLoggerConsumer;
import org.eclipse.edc.samples.util.HttpRequestLoggerConsumer;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
Expand All @@ -26,14 +27,14 @@
import org.testcontainers.junit.jupiter.Testcontainers;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.transfer.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.transfer.TransferUtil.startTransfer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

@EndToEndTest
@Testcontainers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
*
* Contributors:
* Microsoft Corporation - initial test implementation for sample
* Mercedes-Benz Tech Innovation GmbH - refactor test cases
*
*/

package org.eclipse.edc.samples.transfer.transfer04eventconsumer;
package org.eclipse.edc.samples.transfer;

import org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates;
import org.eclipse.edc.junit.annotations.EndToEndTest;
Expand All @@ -27,14 +28,14 @@
import java.io.PrintStream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.transfer.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.transfer.TransferUtil.startTransfer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.transfer.transfer00prerequisites.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.transfer.transfer01negotiation.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.NegotiationCommon.runNegotiation;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getConsumer;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.getProvider;
import static org.eclipse.edc.samples.common.PrerequisitesCommon.runPrerequisites;
import static org.eclipse.edc.samples.util.HttpRequestLoggerUtil.getHttpRequestLoggerContainer;
import static org.eclipse.edc.samples.util.TransferUtil.checkTransferStatus;
import static org.eclipse.edc.samples.util.TransferUtil.startTransfer;

@EndToEndTest
public class Transfer04eventConsumerTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

@EndToEndTest
public class Streaming01httpToHttpTest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
import static org.eclipse.edc.connector.transfer.spi.types.TransferProcessStates.STARTED;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.transfer.FileTransferCommon.getFileFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileContentFromRelativePath;
import static org.eclipse.edc.samples.common.FileTransferCommon.getFileFromRelativePath;

@Testcontainers
@EndToEndTest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

package org.eclipse.edc.samples.transfer;
package org.eclipse.edc.samples.util;

import org.testcontainers.containers.output.ToStringConsumer;

Expand Down
Loading

0 comments on commit 9a02841

Please sign in to comment.