From 6002ee7960ba8f2aca724a451ec678f01c610e44 Mon Sep 17 00:00:00 2001 From: Enrico Risa Date: Tue, 1 Oct 2024 10:50:29 +0200 Subject: [PATCH] fix(jsonld): add missing ODRL mapping in ContractAgreement (#4517) * fix(jsonld): add missing ODRL mapping in ContractAgreement * chore: deps file --- DEPENDENCIES | 4 ---- .../resources/document/management-context-v1.jsonld | 12 ++++++++++-- .../test/e2e/managementapi/SerdeEndToEndTest.java | 5 ++++- .../edc/test/e2e/managementapi/TestFunctions.java | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/DEPENDENCIES b/DEPENDENCIES index 3a300d4d04d..f8dc208dbdd 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -17,18 +17,15 @@ maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.14.0, Apache maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.14.1, Apache-2.0, approved, #5303 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.16.2, Apache-2.0, approved, #11606 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.17.1, Apache-2.0, approved, #13672 -maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.17.2, Apache-2.0, approved, #13672 maven/mavencentral/com.fasterxml.jackson.core/jackson-annotations/2.18.0, Apache-2.0, approved, #16364 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.14.1, Apache-2.0 AND MIT, approved, #4303 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.16.2, Apache-2.0 AND MIT, approved, #11602 -maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.17.2, Apache-2.0 AND MIT, approved, #13665 maven/mavencentral/com.fasterxml.jackson.core/jackson-core/2.18.0, Apache-2.0 AND MIT, approved, #16371 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.11.0, Apache-2.0, approved, CQ23093 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.0, Apache-2.0, approved, #4105 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.14.1, Apache-2.0, approved, #15232 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.16.2, Apache-2.0, approved, #11605 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.17.1, Apache-2.0, approved, #13671 -maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.17.2, Apache-2.0, approved, #13671 maven/mavencentral/com.fasterxml.jackson.core/jackson-databind/2.18.0, Apache-2.0, approved, #16372 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.14.0, Apache-2.0, approved, #5933 maven/mavencentral/com.fasterxml.jackson.dataformat/jackson-dataformat-yaml/2.16.2, Apache-2.0, approved, #11855 @@ -43,7 +40,6 @@ maven/mavencentral/com.fasterxml.jackson.jakarta.rs/jackson-jakarta-rs-json-prov maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.17.1, Apache-2.0, approved, #13668 maven/mavencentral/com.fasterxml.jackson.module/jackson-module-jakarta-xmlbind-annotations/2.18.0, Apache-2.0, approved, #16368 maven/mavencentral/com.fasterxml.jackson/jackson-bom/2.16.2, Apache-2.0, approved, #11852 -maven/mavencentral/com.fasterxml.jackson/jackson-bom/2.17.2, Apache-2.0, approved, #14162 maven/mavencentral/com.fasterxml.jackson/jackson-bom/2.18.0, , restricted, clearlydefined maven/mavencentral/com.fasterxml.uuid/java-uuid-generator/4.1.0, Apache-2.0, approved, clearlydefined maven/mavencentral/com.github.cliftonlabs/json-simple/3.0.2, Apache-2.0, approved, clearlydefined diff --git a/extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld b/extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld index be4720ee959..b80652e4d36 100644 --- a/extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld +++ b/extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld @@ -40,7 +40,15 @@ "CallbackAddress": "edc:CallbackAddress", "NegotiationState": "edc:NegotiationState", "TerminateNegotiation": "edc:TerminateNegotiation", - "ContractAgreement": "edc:ContractAgreement", + "ContractAgreement": { + "@id": "edc:ContractAgreement", + "@context": { + "@import": "http://www.w3.org/ns/odrl.jsonld", + "@propagate": true, + "uid": null, + "type": null + } + }, "TransferRequest": "edc:TransferRequest", "TransferState": "edc:TransferState", "TransferProcess": { @@ -187,4 +195,4 @@ "@container": "@set" } } -} \ No newline at end of file +} diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/SerdeEndToEndTest.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/SerdeEndToEndTest.java index 325233722c0..fe8bf9f8ccb 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/SerdeEndToEndTest.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/SerdeEndToEndTest.java @@ -106,7 +106,10 @@ void ser_ContractAgreement() { assertThat(compactResult.getString("providerId")).isEqualTo(agreement.getProviderId()); assertThat(compactResult.getString("consumerId")).isEqualTo(agreement.getConsumerId()); assertThat(compactResult.getString("assetId")).isEqualTo(agreement.getAssetId()); - assertThat(compactResult.getJsonObject("policy")).isNotNull(); + assertThat(compactResult.getJsonObject("policy")).isNotNull() + .satisfies(policy -> { + assertThat(policy.get(TYPE)).isEqualTo(Json.createValue("Agreement")); + }); assertThat(compactResult.getJsonNumber("contractSigningDate")).isNotNull(); } diff --git a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TestFunctions.java b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TestFunctions.java index bb3876e9ef5..2c7ddbaa5a6 100644 --- a/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TestFunctions.java +++ b/system-tests/management-api/management-api-test-runner/src/test/java/org/eclipse/edc/test/e2e/managementapi/TestFunctions.java @@ -37,6 +37,7 @@ import org.eclipse.edc.policy.model.AtomicConstraint; import org.eclipse.edc.policy.model.LiteralExpression; import org.eclipse.edc.policy.model.Policy; +import org.eclipse.edc.policy.model.PolicyType; import org.eclipse.edc.policy.model.Rule; import org.eclipse.edc.spi.types.domain.DataAddress; import org.eclipse.edc.spi.types.domain.callback.CallbackAddress; @@ -202,7 +203,7 @@ public static ContractAgreement createContractAgreement(String id) { .providerId("providerId") .consumerId("consumerId") .assetId("assetId") - .policy(Policy.Builder.newInstance().build()) + .policy(Policy.Builder.newInstance().type(PolicyType.CONTRACT).build()) .build(); }