-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b42ce9
commit 266efee
Showing
17 changed files
with
224 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...-common-mappers/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/TestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.mappers; | ||
|
||
import lombok.SneakyThrows; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
public class TestUtils { | ||
@NotNull | ||
@SneakyThrows | ||
public static String loadResourceAsString(String name) { | ||
return new String(Files.readAllBytes(Paths.get(TestUtils.class.getResource(name).toURI()))); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...s/src/test/java/de/sovity/edc/ext/wrapper/api/common/mappers/utils/UiAssetMapperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.sovity.edc.ext.wrapper.api.common.mappers.utils; | ||
|
||
import de.sovity.edc.ext.wrapper.api.common.model.UiAssetCreateRequest; | ||
import de.sovity.edc.utils.JsonUtils; | ||
import de.sovity.edc.utils.jsonld.vocab.Prop; | ||
import lombok.val; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static net.javacrumbs.jsonunit.assertj.JsonAssertions.assertThatJson; | ||
import static org.mockito.Mockito.mock; | ||
|
||
class UiAssetMapperTest { | ||
@Test | ||
void test_buildAssetJsonLdContainsCustomJson() { | ||
// Arrange | ||
val mapper = new UiAssetMapper( | ||
mock(EdcPropertyUtils.class), | ||
mock(AssetJsonLdUtils.class), | ||
mock(MarkdownToTextConverter.class), | ||
mock(TextUtils.class), | ||
mock(OwnConnectorEndpointService.class) | ||
); | ||
val createRequest = new UiAssetCreateRequest(); | ||
|
||
createRequest.setId("my-asset"); | ||
createRequest.setTitle("My Asset"); | ||
createRequest.setCustomJsonAsString("verbatim JSON string"); | ||
|
||
// Act | ||
val jsonLd = mapper.buildAssetJsonLd(createRequest, "my-organisation"); | ||
val serialized = JsonUtils.toJson(jsonLd); | ||
|
||
// Assert | ||
assertThatJson(serialized).isObject().containsKey(Prop.Edc.PROPERTIES); | ||
|
||
val properties = jsonLd.getJsonObject(Prop.Edc.PROPERTIES); | ||
val serializedProperties = JsonUtils.toJson(properties); | ||
assertThatJson(serializedProperties).isObject().containsEntry( | ||
"https://semantic.sovity.io/dcat-ext#customJson", | ||
"verbatim JSON string"); | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
extensions/wrapper/wrapper-common-mappers/src/test/resources/custom-json-as-string.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"array":[3,1,4,1,5],"boolean":false,"null":null,"number":116,"object":{"key":"value"},"string":"value"} |
Oops, something went wrong.