Skip to content

Commit 1ba2e0b

Browse files
authored
fix: change callbackAddress in ContractAgreementMessage and ContractOfferMessage (#155)
* fix: removes callbackAddress from ContractAgreementMessage * fix: removes mandatory callbackAddress from ContractOfferMessage
1 parent 51bcca6 commit 1ba2e0b

13 files changed

+35
-32
lines changed

artifacts/src/main/resources/context/dspace.jsonld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@
101101
"@id": "dspace:agreement",
102102
"@type": "@id"
103103
},
104-
"callbackAddress": "dspace:callbackAddress",
105104
"timestamp": "dspace:timestamp"
106105
}
107106
},

artifacts/src/main/resources/negotiation/contract-agreement-message-schema.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,14 @@
2727
},
2828
"agreement": {
2929
"$ref": "https://w3id.org/dspace/2025/1/negotiation/contract-schema.json#/definitions/Agreement"
30-
},
31-
"callbackAddress": {
32-
"type": "string"
3330
}
3431
},
3532
"required": [
3633
"@context",
3734
"@type",
3835
"providerPid",
3936
"consumerPid",
40-
"agreement",
41-
"callbackAddress"
37+
"agreement"
4238
]
4339
}
4440
}

artifacts/src/main/resources/negotiation/contract-offer-message-schema.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,23 @@
5050
"type": "string"
5151
}
5252
},
53+
"oneOf": [
54+
{
55+
"required": [
56+
"callbackAddress"
57+
]
58+
},
59+
{
60+
"required": [
61+
"consumerPid"
62+
]
63+
}
64+
],
5365
"required": [
5466
"@context",
5567
"@type",
5668
"providerPid",
57-
"offer",
58-
"callbackAddress"
69+
"offer"
5970
]
6071
}
6172
}

artifacts/src/main/resources/negotiation/example/contract-agreement-message-full.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,5 @@
151151
]
152152
}
153153
]
154-
},
155-
"callbackAddress": "https://example.com/callback"
154+
}
156155
}

artifacts/src/main/resources/negotiation/example/contract-agreement-message.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,5 @@
2424
]
2525
}
2626
]
27-
},
28-
"callbackAddress": "https://example.com/callback"
27+
}
2928
}

artifacts/src/main/resources/negotiation/example/contract-offer-message.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@
2121
]
2222
}
2323
]
24-
},
25-
"callbackAddress": "https://example.com/callback"
24+
}
2625
}

artifacts/src/test/java/org/eclipse/dsp/schema/fixtures/AbstractSchemaTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import com.networknt.schema.JsonSchema;
1919
import com.networknt.schema.JsonSchemaFactory;
2020
import com.networknt.schema.SchemaLocation;
21+
import com.networknt.schema.ValidationMessage;
2122

2223
import static com.networknt.schema.SpecVersion.VersionFlag.V202012;
2324
import static org.eclipse.dsp.DspConstants.DSP_PREFIX;
@@ -45,4 +46,16 @@ protected void setUp(String schemaFile) {
4546

4647
schema = schemaFactory.getSchema(SchemaLocation.of(DSP_PREFIX + schemaFile));
4748
}
49+
50+
protected SchemaError errorExtractor(ValidationMessage validationMessage) {
51+
return new SchemaError(validationMessage.getProperty(), validationMessage.getType());
52+
}
53+
54+
protected SchemaError error(String property, String type) {
55+
return new SchemaError(property, type);
56+
}
57+
58+
public record SchemaError(String property, String type) {
59+
60+
}
4861
}

artifacts/src/test/java/org/eclipse/dsp/schema/negotiation/InvalidContractAgreementMessageSchemaTest.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ void verifyInvalidCases() {
3030
assertThat(schema.validate(INVALID_NO_TYPE, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
3131
assertThat(schema.validate(INVALID_NO_PROVIDER_ID, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
3232
assertThat(schema.validate(INVALID_NO_CONSUMER_ID, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
33-
assertThat(schema.validate(INVALID_NO_CALLBACK, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
3433
assertThat(schema.validate(NO_AGREEMENT, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
3534
}
3635

@@ -108,18 +107,6 @@ void setUp() {
108107
}
109108
""", AGREEMENT);
110109

111-
private static final String INVALID_NO_CALLBACK = format("""
112-
{
113-
"@context": [
114-
"https://w3id.org/dspace/2025/1/context.jsonld"
115-
],
116-
"@type": "ContractAgreementMessage",
117-
"providerPid": "urn:uuid:a343fcbf-99fc-4ce8-8e9b-148c97605aab",
118-
"consumerPid": "urn:uuid:32541fe6-c580-409e-85a8-8a9a32fbe833",
119-
%s
120-
}
121-
""", AGREEMENT);
122-
123110
private static final String NO_AGREEMENT = """
124111
{
125112
"@context": [

artifacts/src/test/java/org/eclipse/dsp/schema/negotiation/InvalidContractOfferMessageSchemaTest.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ public class InvalidContractOfferMessageSchemaTest extends AbstractSchemaTest {
2626
@Test
2727
void verifyInvalidCases() {
2828
assertThat(schema.validate(INVALID_MESSAGE_NO_TARGET, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
29-
assertThat(schema.validate(INVALID_MESSAGE_NO_CALLBACK, JSON).iterator().next().getType()).isEqualTo(REQUIRED);
29+
assertThat(schema.validate(INVALID_MESSAGE_NO_CALLBACK_NO_CONSUMER_PID, JSON))
30+
.hasSize(3)
31+
.extracting(this::errorExtractor)
32+
.contains(error("callbackAddress", REQUIRED), error("consumerPid", REQUIRED));
3033
}
3134

3235
@BeforeEach
@@ -55,14 +58,13 @@ void setUp() {
5558
}
5659
""";
5760

58-
private static final String INVALID_MESSAGE_NO_CALLBACK = """
61+
private static final String INVALID_MESSAGE_NO_CALLBACK_NO_CONSUMER_PID = """
5962
{
6063
"@context": [
6164
"https://w3id.org/dspace/2025/1/context.jsonld"
6265
],
6366
"@type": "ContractOfferMessage",
6467
"providerPid": "urn:uuid:a343fcbf-99fc-4ce8-8e9b-148c97605aab",
65-
"consumerPid": "urn:uuid:32541fe6-c580-409e-85a8-8a9a32fbe833",
6668
"offer": {
6769
"@type": "Offer",
6870
"@id": "urn:uuid:6bcea82e-c509-443d-ba8c-8eef25984c07",
-2.95 KB
Loading

0 commit comments

Comments
 (0)