From 82301be524ae5302ec43851978b8afb9bb1b8dc5 Mon Sep 17 00:00:00 2001 From: ndr_brt Date: Wed, 10 Jan 2024 15:27:28 +0100 Subject: [PATCH] fix: add missing detail in transfer-01 --- .../resources/negotiate-contract.json | 2 +- .../org/eclipse/edc/samples/common/NegotiationCommon.java | 4 ++-- .../java/org/eclipse/edc/samples/util/TransferUtil.java | 8 ++++---- transfer/transfer-01-negotiation/README.md | 5 ++++- .../resources/negotiate-contract.json | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/advanced/advanced-01-open-telemetry/resources/negotiate-contract.json b/advanced/advanced-01-open-telemetry/resources/negotiate-contract.json index b16050ac..548d1f5e 100644 --- a/advanced/advanced-01-open-telemetry/resources/negotiate-contract.json +++ b/advanced/advanced-01-open-telemetry/resources/negotiate-contract.json @@ -11,7 +11,7 @@ "protocol": "dataspace-protocol-http", "policy": { "@context": "http://www.w3.org/ns/odrl.jsonld", - "@id": "{{contract-negotiation-id}}", + "@id": "{{contract-offer-id}}", "@type": "Set", "permission": [], "prohibition": [], diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java b/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java index a64c288b..3c66574b 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/common/NegotiationCommon.java @@ -41,7 +41,7 @@ public class NegotiationCommon { private static final String V2_CONTRACT_NEGOTIATIONS_PATH = "/v2/contractnegotiations/"; private static final String CONTRACT_NEGOTIATION_ID = "@id"; private static final String CONTRACT_AGREEMENT_ID = "contractAgreementId"; - private static final String CONTRACT_NEGOTIATION_ID_KEY = "\\{\\{contract-negotiation-id\\}\\}"; + private static final String CONTRACT_OFFER_ID_KEY = "{{contract-offer-id}}"; public static void createAsset() { post(PrerequisitesCommon.PROVIDER_MANAGEMENT_URL + V3_ASSETS_PATH, getFileContentFromRelativePath(CREATE_ASSET_FILE_PATH)); @@ -67,7 +67,7 @@ public static String fetchDatasetFromCatalog(String fetchDatasetFromCatalogFileP public static String negotiateContract(String negotiateContractFilePath, String catalogDatasetId) { var requestBody = getFileContentFromRelativePath(negotiateContractFilePath) - .replaceAll(CONTRACT_NEGOTIATION_ID_KEY, catalogDatasetId); + .replace(CONTRACT_OFFER_ID_KEY, catalogDatasetId); var contractNegotiationId = post( PrerequisitesCommon.CONSUMER_MANAGEMENT_URL + V2_CONTRACT_NEGOTIATIONS_PATH, requestBody, diff --git a/system-tests/src/test/java/org/eclipse/edc/samples/util/TransferUtil.java b/system-tests/src/test/java/org/eclipse/edc/samples/util/TransferUtil.java index 01971112..769ed50c 100644 --- a/system-tests/src/test/java/org/eclipse/edc/samples/util/TransferUtil.java +++ b/system-tests/src/test/java/org/eclipse/edc/samples/util/TransferUtil.java @@ -23,6 +23,7 @@ import static io.restassured.RestAssured.given; import static org.awaitility.Awaitility.await; +import static org.eclipse.edc.jsonld.spi.JsonLdKeywords.ID; 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_MANAGEMENT_URL; @@ -35,8 +36,7 @@ public class TransferUtil { public static final Duration POLL_DELAY = Duration.ofMillis(1000); public static final Duration POLL_INTERVAL = Duration.ofMillis(500); - private static final String TRANSFER_PROCESS_ID = "@id"; - private static final String CONTRACT_AGREEMENT_ID_KEY = "\\{\\{contract-agreement-id\\}\\}"; + private static final String CONTRACT_AGREEMENT_ID_KEY = "{{contract-agreement-id}}"; private static final String V2_TRANSFER_PROCESSES_PATH = "/v2/transferprocesses/"; private static final String EDC_STATE = "state"; @@ -95,8 +95,8 @@ public static String post(String url, String requestBody, String jsonPath) { } public static String startTransfer(String requestBody, String contractAgreementId) { - requestBody = requestBody.replaceAll(CONTRACT_AGREEMENT_ID_KEY, contractAgreementId); - return post(CONSUMER_MANAGEMENT_URL + V2_TRANSFER_PROCESSES_PATH, requestBody, TRANSFER_PROCESS_ID); + requestBody = requestBody.replace(CONTRACT_AGREEMENT_ID_KEY, contractAgreementId); + return post(CONSUMER_MANAGEMENT_URL + V2_TRANSFER_PROCESSES_PATH, requestBody, ID); } public static void checkTransferStatus(String transferProcessId, TransferProcessStates status) { diff --git a/transfer/transfer-01-negotiation/README.md b/transfer/transfer-01-negotiation/README.md index 5d05e600..01dbebf2 100644 --- a/transfer/transfer-01-negotiation/README.md +++ b/transfer/transfer-01-negotiation/README.md @@ -181,6 +181,9 @@ looks as follows: Of course, this is the simplest possible negotiation sequence. Later on, both connectors can also send counteroffers in addition to just confirming or declining an offer. +Please replace the `{{contract-offer-id}}` placeholder in the [`negotiate-contract.json`](resources/negotiate-contract.json) +file with the contract offer id you found in the catalog at the path `dcat:dataset.odrl:hasPolicy.@id`. + ```bash curl -d @transfer/transfer-01-negotiation/resources/negotiate-contract.json \ -X POST -H 'content-type: application/json' http://localhost:29193/management/v2/contractnegotiations \ @@ -217,7 +220,7 @@ Sample output: ```json { - "@type": "ContractNegotiationDto", + "@type": "ContractNegotiation", "@id": "5ca21b82-075b-4682-add8-c26c9a2ced67", "type": "CONSUMER", "protocol": "dataspace-protocol-http", diff --git a/transfer/transfer-01-negotiation/resources/negotiate-contract.json b/transfer/transfer-01-negotiation/resources/negotiate-contract.json index 2464f0cc..85762a75 100644 --- a/transfer/transfer-01-negotiation/resources/negotiate-contract.json +++ b/transfer/transfer-01-negotiation/resources/negotiate-contract.json @@ -10,7 +10,7 @@ "protocol": "dataspace-protocol-http", "policy": { "@context": "http://www.w3.org/ns/odrl.jsonld", - "@id": "{{contract-negotiation-id}}", + "@id": "{{contract-offer-id}}", "@type": "Set", "permission": [], "prohibition": [],