Skip to content

Commit ef65f8d

Browse files
authored
refactor: switch all E2E tests to 2025/1 DSP version (#5427)
1 parent aefa942 commit ef65f8d

File tree

17 files changed

+162
-212
lines changed

17 files changed

+162
-212
lines changed

.github/workflows/publish-context.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ on:
2626
push:
2727
branches: [ main ]
2828
paths:
29-
- 'extensions/common/json-ld/src/main/resources/document/**'
29+
- 'core/common/lib/json-ld-lib/src/main/resources/document/**'
3030
- 'extensions/common/api/management-api-schema-validator/src/main/resources/schema/management/**'
3131

3232
jobs:
@@ -40,14 +40,14 @@ jobs:
4040
- name: copy contexts into public folder
4141
run: |
4242
mkdir -p public/context
43-
cp extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld public/context/
44-
cp extensions/common/json-ld/src/main/resources/document/management-context-v2.jsonld public/context/
45-
cp extensions/common/json-ld/src/main/resources/document/dspace-edc-context-v1.jsonld public/context/
43+
cp core/common/lib/json-ld-lib/src/main/resources/document/management-context-v1.jsonld public/context/
44+
cp core/common/lib/json-ld-lib/src/main/resources/document/management-context-v2.jsonld public/context/
45+
cp core/common/lib/json-ld-lib/src/main/resources/document/dspace-edc-context-v1.jsonld public/context/
4646
mkdir -p public/schema
4747
cp -r extensions/common/api/management-api-schema-validator/src/main/resources/schema/management public/schema/
4848
- name: deploy to gh-pages
4949
uses: peaceiris/actions-gh-pages@v4
5050
with:
5151
github_token: ${{ secrets.GITHUB_TOKEN }}
5252
publish_dir: ./public
53-
keep_files: true
53+
keep_files: true
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.jsonld;
16+
17+
import org.eclipse.edc.jsonld.spi.JsonLdContext;
18+
import org.eclipse.edc.spi.result.Result;
19+
20+
import java.net.URI;
21+
import java.net.URISyntaxException;
22+
import java.util.Map;
23+
import java.util.stream.Stream;
24+
25+
import static java.lang.String.format;
26+
import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_CONTEXT_2025_1;
27+
import static org.eclipse.edc.jsonld.spi.Namespaces.DSPACE_ODRL_PROFILE_2025_1;
28+
import static org.eclipse.edc.jsonld.spi.Namespaces.EDC_DSPACE_CONTEXT;
29+
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_CONNECTOR_MANAGEMENT_CONTEXT;
30+
import static org.eclipse.edc.spi.constants.CoreConstants.EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2;
31+
32+
/**
33+
* Manages the hardcoded json-ld documents cached
34+
*/
35+
public class CachedDocumentRegistry {
36+
37+
/**
38+
* Get the cached documents
39+
*
40+
* @return the cached documents
41+
*/
42+
public static Stream<Result<JsonLdContext>> getDocuments() {
43+
return Map.of(
44+
"odrl.jsonld", "http://www.w3.org/ns/odrl.jsonld",
45+
"dspace.jsonld", "https://w3id.org/dspace/2024/1/context.json",
46+
"management-context-v1.jsonld", EDC_CONNECTOR_MANAGEMENT_CONTEXT,
47+
"management-context-v2.jsonld", EDC_CONNECTOR_MANAGEMENT_CONTEXT_V2,
48+
"dspace-edc-context-v1.jsonld", EDC_DSPACE_CONTEXT,
49+
"dspace-v2025-1.jsonld", DSPACE_CONTEXT_2025_1,
50+
"dspace-v2025-1-odrl.jsonld", DSPACE_ODRL_PROFILE_2025_1
51+
).entrySet().stream()
52+
.map(entry -> getResourceUri("document/" + entry.getKey())
53+
.map(uri -> new JsonLdContext(uri, entry.getValue())));
54+
}
55+
56+
static Result<URI> getResourceUri(String name) {
57+
var uri = CachedDocumentRegistry.class.getClassLoader().getResource(name);
58+
if (uri == null) {
59+
return Result.failure(format("Cannot find resource %s", name));
60+
}
61+
62+
try {
63+
return Result.success(uri.toURI());
64+
} catch (URISyntaxException e) {
65+
return Result.failure(format("Cannot read resource %s: %s", name, e.getMessage()));
66+
}
67+
}
68+
69+
}

extensions/common/json-ld/src/main/resources/document/dspace-edc-context-v1.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/dspace-edc-context-v1.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/dspace-v2025-1-odrl.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/dspace-v2025-1-odrl.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/dspace-v2025-1.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/dspace-v2025-1.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/dspace.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/dspace.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/management-context-v1.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/management-context-v1.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/management-context-v2.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/management-context-v2.jsonld

File renamed without changes.

extensions/common/json-ld/src/main/resources/document/odrl.jsonld renamed to core/common/lib/json-ld-lib/src/main/resources/document/odrl.jsonld

File renamed without changes.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Think-it GmbH
3+
*
4+
* This program and the accompanying materials are made available under the
5+
* terms of the Apache License, Version 2.0 which is available at
6+
* https://www.apache.org/licenses/LICENSE-2.0
7+
*
8+
* SPDX-License-Identifier: Apache-2.0
9+
*
10+
* Contributors:
11+
* Think-it GmbH - initial API and implementation
12+
*
13+
*/
14+
15+
package org.eclipse.edc.jsonld;
16+
17+
import org.eclipse.edc.spi.result.Result;
18+
import org.junit.jupiter.api.Test;
19+
20+
import static org.eclipse.edc.junit.assertions.AbstractResultAssert.assertThat;
21+
22+
class CachedDocumentRegistryTest {
23+
24+
@Test
25+
void shouldGetCachedDocuments() {
26+
var contexts = CachedDocumentRegistry.getDocuments().collect(Result.collector());
27+
28+
assertThat(contexts).isSucceeded();
29+
}
30+
}

0 commit comments

Comments
 (0)