From 2baceae99c28c80864c77e9eadca4d435bc9c636 Mon Sep 17 00:00:00 2001 From: Alexander Gordt Date: Mon, 19 Jun 2023 15:34:24 +0200 Subject: [PATCH 1/9] Added test for AAS with extension --- .../dataformat/json/JsonDeserializerTest.java | 12 ++++ ...setAdministrationShell-WithExtensions.json | 66 +++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java index 8f70a124a..5b9973336 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java @@ -30,6 +30,8 @@ import org.junit.Assert; import org.junit.Test; +import java.io.File; + public class JsonDeserializerTest { @Test @@ -66,6 +68,16 @@ public void testCustomImplementationClass() throws Exception { checkImplementationClasses(environment, CustomSubmodel2.class, CustomProperty.class); } + @Test + public void testDeserializationOfShellWithExtensions() throws Exception { + File testJson = new File("src/test/resources/AssetAdministrationShell-WithExtensions.json"); + Environment deserializedObjects = new JsonDeserializer().read(testJson); + + int size = deserializedObjects.getAssetAdministrationShells().get(0).getExtensions().size(); + Assert.assertEquals(1, size); + } + + private void checkImplementationClasses(Environment environment, Class submodelImpl, Class propertyImpl) { environment.getSubmodels().forEach(submodel -> { diff --git a/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json b/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json new file mode 100644 index 000000000..7d759afff --- /dev/null +++ b/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json @@ -0,0 +1,66 @@ +{ + "embeddedDataSpecifications": null, + "extensions": [ + { + "semanticId": { + "type": "ModelReference", + "keys": [ + { + "type": "ConceptDescription", + "value": "my_custom_id" + } + ], + "referredSemanticId": null + }, + "supplementalSemanticIds": null, + "name": "CustomId", + "valueType": "xs:string", + "value": "lore_ipsum_you_know...", + "refersTo": null + } + ], + "category": null, + "idShort": "ShellWithExtension", + "modelType": "AssetAdministrationShell", + "administration": { + "embeddedDataSpecifications": null, + "version": "1", + "revision": "1.0", + "creator": { + "type": "ExternalReference", + "keys": [ + { + "type": "GlobalReference", + "value": "https://example.com" + } + ], + "referredSemanticId": null + }, + "templateId": null + }, + "id": "https://example.com/ShellWithExtension:1", + "derivedFrom": null, + "assetInformation": { + "assetKind": "Type", + "globalAssetId": "https://example.com/ShellWithExtension", + "specificAssetIds": null, + "assetType": null, + "defaultThumbnail": null + }, + "submodels": [ + { + "type": "ModelReference", + "keys": [ + { + "type": "AssetAdministrationShell", + "value": "https://example.com/ShellWithExtension" + }, + { + "type": "Submodel", + "value": "https://example.com/Submodel1" + } + ], + "referredSemanticId": null + } + ] +} From 57df093122040a316d4f2acd68a7eeebe3d6bf6c Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Mon, 19 Jun 2023 16:12:35 +0200 Subject: [PATCH 2/9] fix HasExtension serialization for JSON --- .../json/mixins/HasExtensionsMixin.java | 4 +- .../dataformat/json/JsonDeserializerTest.java | 10 --- .../json/JsonReferableDeserializerTest.java | 22 +++-- .../json/JsonReferableSerializerTest.java | 13 ++- .../v3/dataformat/json/util/Examples.java | 89 ++++++++++++------- ...setAdministrationShell-WithExtensions.json | 86 +++++------------- 6 files changed, 106 insertions(+), 118 deletions(-) diff --git a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/HasExtensionsMixin.java b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/HasExtensionsMixin.java index d97c658e3..73ee6b923 100644 --- a/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/HasExtensionsMixin.java +++ b/dataformat-json/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/mixins/HasExtensionsMixin.java @@ -23,9 +23,9 @@ public interface HasExtensionsMixin { - @JsonProperty("extension") + @JsonProperty("extensions") public List getExtensions(); - @JsonProperty("extension") + @JsonProperty("extensions") public void setExtensions(List extensions); } diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java index 5b9973336..002f025e6 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java @@ -68,16 +68,6 @@ public void testCustomImplementationClass() throws Exception { checkImplementationClasses(environment, CustomSubmodel2.class, CustomProperty.class); } - @Test - public void testDeserializationOfShellWithExtensions() throws Exception { - File testJson = new File("src/test/resources/AssetAdministrationShell-WithExtensions.json"); - Environment deserializedObjects = new JsonDeserializer().read(testJson); - - int size = deserializedObjects.getAssetAdministrationShells().get(0).getExtensions().size(); - Assert.assertEquals(1, size); - } - - private void checkImplementationClasses(Environment environment, Class submodelImpl, Class propertyImpl) { environment.getSubmodels().forEach(submodel -> { diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java index 68ef1d473..580de3091 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java @@ -15,6 +15,7 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.json; +import java.io.File; import static org.junit.Assert.assertEquals; import java.io.IOException; @@ -31,6 +32,8 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.Examples; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.junit.Assert; public class JsonReferableDeserializerTest { @@ -91,10 +94,17 @@ public void testReadSubmodelElementCollection() throws IOException, Deserializat assertEquals(expected, actual); } - @Test - public void testReadEmptyReferableList() throws DeserializationException { - List emptyList = Collections.emptyList(); - List deserialized = new JsonDeserializer().readReferables("[]", Referable.class); - assertEquals(emptyList, deserialized); - } + @Test + public void testReadEmptyReferableList() throws DeserializationException { + List emptyList = Collections.emptyList(); + List deserialized = new JsonDeserializer().readReferables("[]", Referable.class); + assertEquals(emptyList, deserialized); + } + + @Test + public void testDeserializationOfShellWithExtensions() throws Exception { + AssetAdministrationShell expected = Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.getModel(); + AssetAdministrationShell actual = new JsonDeserializer().readReferable(Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.fileContentStream(), AssetAdministrationShell.class); + assertEquals(expected, actual); + } } diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java index 7df276487..c6a3e7eb9 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java @@ -37,10 +37,15 @@ public void testSerializeAAS() throws IOException, SerializationException, JSONE } @Test - public void testSerializeWithAssetInformation() throws SerializationException, JSONException, IOException { + public void testSerializeAASWithAssetInformation() throws SerializationException, JSONException, IOException { compare(Examples.ASSET_ADMINISTRATION_SHELL_WITH_ASSET_INFORMATION); } + @Test + public void testSerializeAASWithExtensions() throws SerializationException, JSONException, IOException { + compare(Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS); + } + @Test public void testSerializeAASs() throws IOException, SerializationException, JSONException { compare(Examples.ASSET_ADMINISTRATION_SHELL_LIST_OF); @@ -87,8 +92,8 @@ public void testSerializeSubmodelElementListEmpty() throws SerializationExceptio compare(Examples.SUBMODEL_ELEMENT_LIST_EMPTY); } - @SuppressWarnings("unchecked") - private void compare(ExampleData exampleData) throws IOException, SerializationException, JSONException { + @SuppressWarnings("unchecked") + private void compare(ExampleData exampleData) throws IOException, SerializationException, JSONException { String expected = exampleData.fileContent(); String actual = null; if (Environment.class.isAssignableFrom(exampleData.getModel().getClass())) { @@ -96,7 +101,7 @@ private void compare(ExampleData exampleData) throws IOException, Serializati } else if (Referable.class.isAssignableFrom(exampleData.getModel().getClass())) { actual = new JsonSerializer().write((Referable) exampleData.getModel()); } else if (Collection.class.isAssignableFrom(exampleData.getModel().getClass()) - && ((Collection) exampleData.getModel()).stream().allMatch(x -> x != null && Referable.class.isAssignableFrom(x.getClass()))) { + && ((Collection) exampleData.getModel()).stream().allMatch(x -> x != null && Referable.class.isAssignableFrom(x.getClass()))) { actual = new JsonSerializer().write((Collection) exampleData.getModel()); } JSONAssert.assertEquals(expected, actual, JSONCompareMode.NON_EXTENSIBLE); diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index 6297303af..87dbcfb33 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -22,6 +22,7 @@ import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXSD; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; @@ -34,9 +35,9 @@ public class Examples { - public static final ExampleData EXAMPLE_FULL = ExampleData.of(AASFull.createEnvironment(), "Example-Full.json"); + public static final ExampleData EXAMPLE_FULL = ExampleData.of(AASFull.createEnvironment(), "Example-Full.json"); - public static final ExampleData EXAMPLE_SIMPLE = ExampleData.of(AASSimple.createEnvironment(), "Example-Simple.json"); + public static final ExampleData EXAMPLE_SIMPLE = ExampleData.of(AASSimple.createEnvironment(), "Example-Simple.json"); public static final ExampleData ENVIRONMENT_EMPTY = ExampleData.of(new DefaultEnvironment.Builder().build(), "Environment-Empty.json"); @@ -70,8 +71,30 @@ public class Examples { .build(), "AssetAdministrationShell-WithAssetInformation.json"); - public static final ExampleData ASSET_ADMINISTRATION_SHELL = ExampleData.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), "AssetAdministrationShell.json"); - + public static final ExampleData ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS = ExampleData.of( + new DefaultAssetAdministrationShell.Builder() + .id("https://example.org/AssetAdministrationShell") + .extensions(new DefaultExtension.Builder() + .name("CustomId") + .valueType(DataTypeDefXSD.STRING) + .value("lore_ipsum_you_know...") + .semanticID(new DefaultReference.Builder() + .type(ReferenceTypes.MODEL_REFERENCE) + .keys(new DefaultKey.Builder() + .type(KeyTypes.CONCEPT_DESCRIPTION) + .value("my_custom_id") + .build()) + .build()) + .build()) + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .globalAssetID("https://acplt.org/Test_Asset") + .build()) + .build(), + "AssetAdministrationShell-WithExtensions.json"); + + public static final ExampleData ASSET_ADMINISTRATION_SHELL = ExampleData.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), "AssetAdministrationShell.json"); + public static final ExampleData CONCEPT_DESCRIPTION_DATA_SPECIFICATION_PHYSICAL_UNIT = ExampleData.of( new DefaultConceptDescription.Builder() .id("https://example.org/ConceptDescription") @@ -83,28 +106,28 @@ public class Examples { .value("https://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0/RC02") .build()) .build()) -// .dataSpecificationContent(new DefaultDataSpecificationPhysicalUnit.Builder() -// .conversionFactor("1.0") -// .eceCode("ece-code") -// .eceName("ece-name") -// .definition(new DefaultLangString.Builder() -// .language("en") -// .text("definition-en") -// .build()) -// .definition(new DefaultLangString.Builder() -// .language("de") -// .text("definition-de") -// .build()) -// .nistName("nist-name") -// .dinNotation("din-notation") -// .siName("si-name") -// .registrationAuthorityId("registration-authority-id") -// .siNotation("si-notation") -// .sourceOfDefinition("source-of-definition") -// .supplier("supplier") -// .unitName("unit-name") -// .unitSymbol("unit-symbol") -// .build()) + // .dataSpecificationContent(new DefaultDataSpecificationPhysicalUnit.Builder() + // .conversionFactor("1.0") + // .eceCode("ece-code") + // .eceName("ece-name") + // .definition(new DefaultLangString.Builder() + // .language("en") + // .text("definition-en") + // .build()) + // .definition(new DefaultLangString.Builder() + // .language("de") + // .text("definition-de") + // .build()) + // .nistName("nist-name") + // .dinNotation("din-notation") + // .siName("si-name") + // .registrationAuthorityId("registration-authority-id") + // .siNotation("si-notation") + // .sourceOfDefinition("source-of-definition") + // .supplier("supplier") + // .unitName("unit-name") + // .unitSymbol("unit-symbol") + // .build()) .build()) .build(), "ConceptDescription-DataSpecificationPhysicalUnit.json"); @@ -113,24 +136,24 @@ public class Examples { List.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(1)), "SubmodelElement-List.json"); - + public static final ExampleData> SUBMODEL_LIST_OF = ExampleData.of( List.of(AASFull.createEnvironment().getSubmodels().get(0), AASFull.createEnvironment().getSubmodels().get(1)), "Submodel-List.json"); - public static final ExampleData SUBMODEL = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0), "Submodel.json"); + public static final ExampleData SUBMODEL = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0), "Submodel.json"); - public static final ExampleData SUBMODEL_ELEMENT = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), "SubmodelElement.json"); + public static final ExampleData SUBMODEL_ELEMENT = ExampleData.of(AASFull.createEnvironment().getSubmodels().get(0).getSubmodelElements().get(0), "SubmodelElement.json"); - public static final ExampleData SUBMODEL_ELEMENT_COLLECTION = ExampleData.of((SubmodelElementCollection) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(6), - "SubmodelElementCollection.json"); + public static final ExampleData SUBMODEL_ELEMENT_COLLECTION = ExampleData.of((SubmodelElementCollection) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(6), + "SubmodelElementCollection.json"); public static final ExampleData SUBMODEL_ELEMENT_LIST_EMPTY = ExampleData.of( new DefaultSubmodelElementList.Builder() .idShort("submodelElementList") .orderRelevant(true) .build(), "SubmodelElementList-Empty.json"); - - public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); + + public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); } diff --git a/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json b/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json index 7d759afff..e10d5a71f 100644 --- a/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json +++ b/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json @@ -1,66 +1,26 @@ { - "embeddedDataSpecifications": null, - "extensions": [ - { - "semanticId": { - "type": "ModelReference", - "keys": [ - { - "type": "ConceptDescription", - "value": "my_custom_id" - } - ], - "referredSemanticId": null - }, - "supplementalSemanticIds": null, - "name": "CustomId", - "valueType": "xs:string", - "value": "lore_ipsum_you_know...", - "refersTo": null - } - ], - "category": null, - "idShort": "ShellWithExtension", - "modelType": "AssetAdministrationShell", - "administration": { - "embeddedDataSpecifications": null, - "version": "1", - "revision": "1.0", - "creator": { - "type": "ExternalReference", - "keys": [ + "modelType": "AssetAdministrationShell", + "id": "https://example.org/AssetAdministrationShell", + "extensions": [ { - "type": "GlobalReference", - "value": "https://example.com" + "semanticId": + { + "type": "ModelReference", + "keys": [ + { + "type": "ConceptDescription", + "value": "my_custom_id" + } + ] + }, + "name": "CustomId", + "valueType": "xs:string", + "value": "lore_ipsum_you_know..." } - ], - "referredSemanticId": null - }, - "templateId": null - }, - "id": "https://example.com/ShellWithExtension:1", - "derivedFrom": null, - "assetInformation": { - "assetKind": "Type", - "globalAssetId": "https://example.com/ShellWithExtension", - "specificAssetIds": null, - "assetType": null, - "defaultThumbnail": null - }, - "submodels": [ - { - "type": "ModelReference", - "keys": [ - { - "type": "AssetAdministrationShell", - "value": "https://example.com/ShellWithExtension" - }, - { - "type": "Submodel", - "value": "https://example.com/Submodel1" - } - ], - "referredSemanticId": null - } - ] -} + ], + "assetInformation": + { + "assetKind": "Instance", + "globalAssetId": "https://acplt.org/Test_Asset" + } +} \ No newline at end of file From 1ab0c5b4d5b14aa4f546c9e20a576603dc35c605 Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Fri, 7 Jul 2023 08:57:52 +0200 Subject: [PATCH 3/9] Add minimal and maximal example for extension * adds Java respresentation of test cases in core * adds corresponding unit tests in dataformat-json --- .../aas4j/v3/dataformat/core/Examples.java | 80 +++++++++++++++++++ .../json/JsonReferableDeserializerTest.java | 16 +++- .../json/JsonReferableSerializerTest.java | 10 +++ .../v3/dataformat/json/util/Examples.java | 5 ++ .../src/test/resources/Extension-Maximal.json | 50 ++++++++++++ .../src/test/resources/Extension-Minimal.json | 17 ++++ 6 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java create mode 100644 dataformat-json/src/test/resources/Extension-Maximal.json create mode 100644 dataformat-json/src/test/resources/Extension-Minimal.json diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java new file mode 100644 index 000000000..a5e789547 --- /dev/null +++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java @@ -0,0 +1,80 @@ +/* + * Copyright 2023 jab. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.eclipse.digitaltwin.aas4j.v3.dataformat.core; + +import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; +import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXSD; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; +import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; + +public class Examples { + + public static final Environment EXTENSION_MINIMAL = new DefaultEnvironment.Builder() + .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() + .id("something_142922d6") + .extensions(new DefaultExtension.Builder() + .name("something_aae6caf4") + .build()) + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .globalAssetID("something_eea66fa1") + .build()) + .build()) + .build(); + + public static final Environment EXTENSION_MAXIMAL = new DefaultEnvironment.Builder() + .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() + .id("something_142922d6") + .extensions(new DefaultExtension.Builder() + .name("something_aae6caf4") + .value("10233") + .valueType(DataTypeDefXSD.UNSIGNED_SHORT) + .refersTo(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.SUBMODEL) + .value("urn:another-example01:f7faa581") + .build()) + .type(ReferenceTypes.MODEL_REFERENCE) + .build()) + .semanticID(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("urn:another-company07:4d1bd2cb") + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .supplementalSemanticIds(new DefaultReference.Builder() + .keys(new DefaultKey.Builder() + .type(KeyTypes.GLOBAL_REFERENCE) + .value("urn:an-example13:be48ff29") + .build()) + .type(ReferenceTypes.EXTERNAL_REFERENCE) + .build()) + .build()) + .assetInformation(new DefaultAssetInformation.Builder() + .assetKind(AssetKind.INSTANCE) + .globalAssetID("something_eea66fa1") + .build()) + .build()) + .build(); +} diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java index 580de3091..4ea7c7558 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java @@ -102,9 +102,23 @@ public void testReadEmptyReferableList() throws DeserializationException { } @Test - public void testDeserializationOfShellWithExtensions() throws Exception { + public void testAASWithExtensions() throws Exception { AssetAdministrationShell expected = Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.getModel(); AssetAdministrationShell actual = new JsonDeserializer().readReferable(Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.fileContentStream(), AssetAdministrationShell.class); assertEquals(expected, actual); } + + @Test + public void testExtensionMinimal() throws Exception { + Environment expected = Examples.EXTENSION_MINIMAL.getModel(); + Environment actual = new JsonDeserializer().read(Examples.EXTENSION_MINIMAL.fileContentStream()); + assertEquals(expected, actual); + } + + @Test + public void testExtensionMaximal() throws Exception { + Environment expected = Examples.EXTENSION_MAXIMAL.getModel(); + Environment actual = new JsonDeserializer().read(Examples.EXTENSION_MAXIMAL.fileContentStream()); + assertEquals(expected, actual); + } } diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java index c6a3e7eb9..838d30f9f 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java @@ -92,6 +92,16 @@ public void testSerializeSubmodelElementListEmpty() throws SerializationExceptio compare(Examples.SUBMODEL_ELEMENT_LIST_EMPTY); } + @Test + public void testSerializeExtensionMinimal() throws SerializationException, JSONException, IOException { + compare(Examples.EXTENSION_MINIMAL); + } + + @Test + public void testSerializeExtensionMaximal() throws SerializationException, JSONException, IOException { + compare(Examples.EXTENSION_MAXIMAL); + } + @SuppressWarnings("unchecked") private void compare(ExampleData exampleData) throws IOException, SerializationException, JSONException { String expected = exampleData.fileContent(); diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index 87dbcfb33..b32e04b1e 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -19,6 +19,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; @@ -156,4 +157,8 @@ public class Examples { .build(), "SubmodelElementList-Empty.json"); public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); + + public static final ExampleData EXTENSION_MINIMAL = ExampleData.of((Environment) Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); + + public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of((Environment) Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); } diff --git a/dataformat-json/src/test/resources/Extension-Maximal.json b/dataformat-json/src/test/resources/Extension-Maximal.json new file mode 100644 index 000000000..f84d1a7e4 --- /dev/null +++ b/dataformat-json/src/test/resources/Extension-Maximal.json @@ -0,0 +1,50 @@ +{ + "assetAdministrationShells": [ + { + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "something_eea66fa1" + }, + "extensions": [ + { + "name": "something_aae6caf4", + "refersTo": [ + { + "keys": [ + { + "type": "Submodel", + "value": "urn:another-example01:f7faa581" + } + ], + "type": "ModelReference" + } + ], + "semanticId": { + "keys": [ + { + "type": "GlobalReference", + "value": "urn:another-company07:4d1bd2cb" + } + ], + "type": "ExternalReference" + }, + "supplementalSemanticIds": [ + { + "keys": [ + { + "type": "GlobalReference", + "value": "urn:an-example13:be48ff29" + } + ], + "type": "ExternalReference" + } + ], + "value": "10233", + "valueType": "xs:unsignedShort" + } + ], + "id": "something_142922d6", + "modelType": "AssetAdministrationShell" + } + ] +} \ No newline at end of file diff --git a/dataformat-json/src/test/resources/Extension-Minimal.json b/dataformat-json/src/test/resources/Extension-Minimal.json new file mode 100644 index 000000000..dd9c4a01d --- /dev/null +++ b/dataformat-json/src/test/resources/Extension-Minimal.json @@ -0,0 +1,17 @@ +{ + "assetAdministrationShells": [ + { + "assetInformation": { + "assetKind": "Instance", + "globalAssetId": "something_eea66fa1" + }, + "extensions": [ + { + "name": "something_aae6caf4" + } + ], + "id": "something_142922d6", + "modelType": "AssetAdministrationShell" + } + ] +} \ No newline at end of file From 9c6fb8e88a2e4e7d7999369c415d70d30329ab09 Mon Sep 17 00:00:00 2001 From: Michael Jacoby Date: Fri, 7 Jul 2023 11:47:23 +0200 Subject: [PATCH 4/9] fix imports --- .../aas4j/v3/dataformat/json/util/Examples.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index b32e04b1e..d9c941b59 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -19,7 +19,6 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; @@ -31,8 +30,17 @@ import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.*; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultAssetInformation; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultResource; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSpecificAssetID; +import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultSubmodelElementList; public class Examples { @@ -158,7 +166,7 @@ public class Examples { public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); - public static final ExampleData EXTENSION_MINIMAL = ExampleData.of((Environment) Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); + public static final ExampleData EXTENSION_MINIMAL = ExampleData.of((Environment) org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); - public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of((Environment) Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); + public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of((Environment) org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); } From 5d6ee5dbb3979553d7733584f94bab3f87193757 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Mon, 10 Jul 2023 11:51:38 +0200 Subject: [PATCH 5/9] Removes obsolete test case * Is superseded by Extension-Maximal.json Signed-off-by: Frank Schnicke --- .../dataformat/json/JsonDeserializerTest.java | 2 -- .../json/JsonReferableDeserializerTest.java | 18 +++--------- .../json/JsonReferableSerializerTest.java | 5 ---- .../v3/dataformat/json/util/Examples.java | 28 ++----------------- ...setAdministrationShell-WithExtensions.json | 26 ----------------- 5 files changed, 6 insertions(+), 73 deletions(-) delete mode 100644 dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java index 002f025e6..8f70a124a 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonDeserializerTest.java @@ -30,8 +30,6 @@ import org.junit.Assert; import org.junit.Test; -import java.io.File; - public class JsonDeserializerTest { @Test diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java index 4ea7c7558..4faef5194 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableDeserializerTest.java @@ -15,26 +15,23 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.json; -import java.io.File; import static org.junit.Assert.assertEquals; import java.io.IOException; import java.util.Collections; import java.util.List; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.Examples; import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Referable; import org.eclipse.digitaltwin.aas4j.v3.model.Submodel; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; -import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; +import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementList; import org.junit.Test; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; -import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.util.Examples; -import org.eclipse.digitaltwin.aas4j.v3.model.Environment; -import org.junit.Assert; - public class JsonReferableDeserializerTest { @Test @@ -101,13 +98,6 @@ public void testReadEmptyReferableList() throws DeserializationException { assertEquals(emptyList, deserialized); } - @Test - public void testAASWithExtensions() throws Exception { - AssetAdministrationShell expected = Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.getModel(); - AssetAdministrationShell actual = new JsonDeserializer().readReferable(Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS.fileContentStream(), AssetAdministrationShell.class); - assertEquals(expected, actual); - } - @Test public void testExtensionMinimal() throws Exception { Environment expected = Examples.EXTENSION_MINIMAL.getModel(); diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java index 838d30f9f..f6a1ff5e5 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/JsonReferableSerializerTest.java @@ -41,11 +41,6 @@ public void testSerializeAASWithAssetInformation() throws SerializationException compare(Examples.ASSET_ADMINISTRATION_SHELL_WITH_ASSET_INFORMATION); } - @Test - public void testSerializeAASWithExtensions() throws SerializationException, JSONException, IOException { - compare(Examples.ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS); - } - @Test public void testSerializeAASs() throws IOException, SerializationException, JSONException { compare(Examples.ASSET_ADMINISTRATION_SHELL_LIST_OF); diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index d9c941b59..08a66e640 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -22,7 +22,6 @@ import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; -import org.eclipse.digitaltwin.aas4j.v3.model.DataTypeDefXSD; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.KeyTypes; import org.eclipse.digitaltwin.aas4j.v3.model.ReferenceTypes; @@ -35,7 +34,6 @@ import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultConceptDescription; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEmbeddedDataSpecification; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultEnvironment; -import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultExtension; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultKey; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultReference; import org.eclipse.digitaltwin.aas4j.v3.model.impl.DefaultResource; @@ -80,28 +78,6 @@ public class Examples { .build(), "AssetAdministrationShell-WithAssetInformation.json"); - public static final ExampleData ASSET_ADMINISTRATION_SHELL_WITH_EXTENSIONS = ExampleData.of( - new DefaultAssetAdministrationShell.Builder() - .id("https://example.org/AssetAdministrationShell") - .extensions(new DefaultExtension.Builder() - .name("CustomId") - .valueType(DataTypeDefXSD.STRING) - .value("lore_ipsum_you_know...") - .semanticID(new DefaultReference.Builder() - .type(ReferenceTypes.MODEL_REFERENCE) - .keys(new DefaultKey.Builder() - .type(KeyTypes.CONCEPT_DESCRIPTION) - .value("my_custom_id") - .build()) - .build()) - .build()) - .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) - .globalAssetID("https://acplt.org/Test_Asset") - .build()) - .build(), - "AssetAdministrationShell-WithExtensions.json"); - public static final ExampleData ASSET_ADMINISTRATION_SHELL = ExampleData.of(AASFull.createEnvironment().getAssetAdministrationShells().get(0), "AssetAdministrationShell.json"); public static final ExampleData CONCEPT_DESCRIPTION_DATA_SPECIFICATION_PHYSICAL_UNIT = ExampleData.of( @@ -166,7 +142,7 @@ public class Examples { public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); - public static final ExampleData EXTENSION_MINIMAL = ExampleData.of((Environment) org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); + public static final ExampleData EXTENSION_MINIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); - public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of((Environment) org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); + public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); } diff --git a/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json b/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json deleted file mode 100644 index e10d5a71f..000000000 --- a/dataformat-json/src/test/resources/AssetAdministrationShell-WithExtensions.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "modelType": "AssetAdministrationShell", - "id": "https://example.org/AssetAdministrationShell", - "extensions": [ - { - "semanticId": - { - "type": "ModelReference", - "keys": [ - { - "type": "ConceptDescription", - "value": "my_custom_id" - } - ] - }, - "name": "CustomId", - "valueType": "xs:string", - "value": "lore_ipsum_you_know..." - } - ], - "assetInformation": - { - "assetKind": "Instance", - "globalAssetId": "https://acplt.org/Test_Asset" - } -} \ No newline at end of file From 6f55fb90b33107011eee48918c5f14be7101cfd5 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Mon, 10 Jul 2023 11:56:00 +0200 Subject: [PATCH 6/9] Adds license text for admin-shell-io examples & Moves files to separate folder * Allows copy & pasting from admin-shell-io repo Signed-off-by: Frank Schnicke --- .../digitaltwin/aas4j/v3/dataformat/json/util/Examples.java | 4 ++-- .../Extension/Maximal.json} | 0 .../Extension/Minimal.json} | 0 dataformat-json/src/test/resources/admin-shell-io/License.md | 1 + 4 files changed, 3 insertions(+), 2 deletions(-) rename dataformat-json/src/test/resources/{Extension-Maximal.json => admin-shell-io/Extension/Maximal.json} (100%) rename dataformat-json/src/test/resources/{Extension-Minimal.json => admin-shell-io/Extension/Minimal.json} (100%) create mode 100644 dataformat-json/src/test/resources/admin-shell-io/License.md diff --git a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java index 08a66e640..6d35239d7 100644 --- a/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java +++ b/dataformat-json/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/json/util/Examples.java @@ -142,7 +142,7 @@ public class Examples { public static final ExampleData SUBMODEL_ELEMENT_LIST = ExampleData.of((SubmodelElementList) AASFull.createEnvironment().getSubmodels().get(6).getSubmodelElements().get(5), "SubmodelElementList.json"); - public static final ExampleData EXTENSION_MINIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "Extension-Minimal.json"); + public static final ExampleData EXTENSION_MINIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MINIMAL, "admin-shell-io/Extension/Minimal.json"); - public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "Extension-Maximal.json"); + public static final ExampleData EXTENSION_MAXIMAL = ExampleData.of(org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples.EXTENSION_MAXIMAL, "admin-shell-io/Extension/Maximal.json"); } diff --git a/dataformat-json/src/test/resources/Extension-Maximal.json b/dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json similarity index 100% rename from dataformat-json/src/test/resources/Extension-Maximal.json rename to dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json diff --git a/dataformat-json/src/test/resources/Extension-Minimal.json b/dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json similarity index 100% rename from dataformat-json/src/test/resources/Extension-Minimal.json rename to dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json diff --git a/dataformat-json/src/test/resources/admin-shell-io/License.md b/dataformat-json/src/test/resources/admin-shell-io/License.md new file mode 100644 index 000000000..ad5bff5c6 --- /dev/null +++ b/dataformat-json/src/test/resources/admin-shell-io/License.md @@ -0,0 +1 @@ +The files contained in this directory are taken without any modification from https://github.com/admin-shell-io/aas-specs/ where they are made available under the CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/). \ No newline at end of file From ff2dfc8e9c91835d6bd9a745a515cd2a480cf760 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Mon, 10 Jul 2023 15:32:37 +0200 Subject: [PATCH 7/9] Extension serialization working Signed-off-by: Frank Schnicke --- .../aas4j/v3/dataformat/core/Examples.java | 8 +-- .../admin-shell-io/Extension/Maximal.json | 2 +- .../admin-shell-io/Extension/Minimal.json | 2 +- .../mixins/AssetAdministrationShellMixin.java | 6 +- .../dataformat/xml/mixins/ExtensionMixin.java | 10 ++- .../xml/serialization/RefersToSerializer.java | 71 +++++++++++++++++++ .../v3/dataformat/xml/XmlSerializerTest.java | 33 ++++++--- .../admin-shell-io/Extension/maximal.xml | 52 ++++++++++++++ .../admin-shell-io/Extension/minimal.xml | 19 +++++ .../test/resources/admin-shell-io/License.md | 5 ++ 10 files changed, 187 insertions(+), 21 deletions(-) create mode 100644 dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java create mode 100644 dataformat-xml/src/test/resources/admin-shell-io/Extension/maximal.xml create mode 100644 dataformat-xml/src/test/resources/admin-shell-io/Extension/minimal.xml create mode 100644 dataformat-xml/src/test/resources/admin-shell-io/License.md diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java index a5e789547..dcfef1c49 100644 --- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java +++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java @@ -36,7 +36,7 @@ public class Examples { .name("something_aae6caf4") .build()) .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) + .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetID("something_eea66fa1") .build()) .build()) @@ -49,13 +49,13 @@ public class Examples { .name("something_aae6caf4") .value("10233") .valueType(DataTypeDefXSD.UNSIGNED_SHORT) - .refersTo(new DefaultReference.Builder() + .refersTo(new DefaultReference.Builder() .keys(new DefaultKey.Builder() .type(KeyTypes.SUBMODEL) .value("urn:another-example01:f7faa581") .build()) .type(ReferenceTypes.MODEL_REFERENCE) - .build()) + .build()) .semanticID(new DefaultReference.Builder() .keys(new DefaultKey.Builder() .type(KeyTypes.GLOBAL_REFERENCE) @@ -72,7 +72,7 @@ public class Examples { .build()) .build()) .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.INSTANCE) + .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetID("something_eea66fa1") .build()) .build()) diff --git a/dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json b/dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json index f84d1a7e4..436f81fc9 100644 --- a/dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json +++ b/dataformat-json/src/test/resources/admin-shell-io/Extension/Maximal.json @@ -2,7 +2,7 @@ "assetAdministrationShells": [ { "assetInformation": { - "assetKind": "Instance", + "assetKind": "NotApplicable", "globalAssetId": "something_eea66fa1" }, "extensions": [ diff --git a/dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json b/dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json index dd9c4a01d..831658174 100644 --- a/dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json +++ b/dataformat-json/src/test/resources/admin-shell-io/Extension/Minimal.json @@ -2,7 +2,7 @@ "assetAdministrationShells": [ { "assetInformation": { - "assetKind": "Instance", + "assetKind": "NotApplicable", "globalAssetId": "something_eea66fa1" }, "extensions": [ diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java index 1e2728ed4..bc9398c41 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java @@ -24,7 +24,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; -@JsonPropertyOrder({ "hasExtension", "category", "idShort", "displayNames", "description", "checksum", "administration", "id", "dataSpecifications", "embeddedDataSpecifications", "derivedFrom", "assetInformation", "submodels"}) +@JsonPropertyOrder({ "extension", "category", "idShort", "displayNames", "description", "checksum", "administration", "id", "dataSpecifications", "embeddedDataSpecifications", "derivedFrom", "assetInformation", "submodels" }) public interface AssetAdministrationShellMixin { @@ -32,8 +32,8 @@ public interface AssetAdministrationShellMixin { public String getID(); - @JacksonXmlElementWrapper(namespace = AasXmlNamespaceContext.AAS_URI, localName = "submodels") - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "reference") + @JacksonXmlElementWrapper(namespace = AasXmlNamespaceContext.AAS_URI, localName = "submodels") + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "reference") public List getSubmodels(); } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java index 141b8aa9a..b51ace08d 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java @@ -15,8 +15,16 @@ */ package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins; +import java.util.List; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization.RefersToSerializer; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; -@JsonPropertyOrder({"semanticId", "name", "valueType", "value", "refersTo"}) +@JsonPropertyOrder({ "semanticId", "supplementalSemanticIds", "name", "valueType", "value", "refersTo" }) public interface ExtensionMixin { + @JsonSerialize(using = RefersToSerializer.class) + List getRefersTo(); } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java new file mode 100644 index 000000000..466f97d15 --- /dev/null +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.serialization; + +import java.io.IOException; +import java.util.List; + +import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.mixins.HasSemanticsMixin; +import org.eclipse.digitaltwin.aas4j.v3.model.Extension; +import org.eclipse.digitaltwin.aas4j.v3.model.Reference; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; + +/** + * Serializes the RefersTo value of {@link Extension}.
+ * This class is needed since using the same approach as used in + * {@link HasSemanticsMixin} leads to a conflict for XMLPropertyName "reference" + * + * @author schnicke + * + */ +public class RefersToSerializer extends JsonSerializer> { + + @Override + public void serialize(List value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + if (value.isEmpty()) + return; + + ToXmlGenerator xgen = (ToXmlGenerator) gen; + + xgen.writeStartObject(); + + for (Reference ref : value) { + writeReference(xgen, ref); + } + + xgen.writeEndObject(); + } + + private void writeReference(ToXmlGenerator xgen, Reference ref) throws IOException { + xgen.writeFieldName("reference"); + xgen.writeObject(ref); + } + +} diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java index 1e35f8981..a3e72b1c2 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java @@ -27,6 +27,7 @@ import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples; import org.eclipse.digitaltwin.aas4j.v3.dataformat.xml.internal.AasXmlNamespaceContext; import org.eclipse.digitaltwin.aas4j.v3.model.AssetKind; import org.eclipse.digitaltwin.aas4j.v3.model.ConceptDescription; @@ -61,6 +62,8 @@ public class XmlSerializerTest { public static final java.io.File AASFULL_FILE_WITH_ANNOTATED_RELATIONSHIP = new java.io.File("src/test/resources/annotated_relationship_example.xml"); public static final java.io.File AASFULL_FILE_WITH_QUALIFIERS = new java.io.File("src/test/resources/qualifier_example.xml"); public static final java.io.File AASFULL_FILE_WITH_OPERATIONS = new java.io.File("src/test/resources/operation_example.xml"); + public static final java.io.File AAS_WITH_EXTENSION_MINIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/minimal.xml"); + public static final java.io.File AAS_WITH_EXTENSION_MAXIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/maximal.xml"); private static final Logger logger = LoggerFactory.getLogger(XmlSerializerTest.class); @@ -68,14 +71,14 @@ public class XmlSerializerTest { public TemporaryFolder tempFolder = new TemporaryFolder(); @Test - public void testWriteToFile() throws IOException, SerializationException { + public void writeToFile() throws IOException, SerializationException { File file = tempFolder.newFile("output.xml"); new XmlSerializer().write(file, AASSimple.createEnvironment()); assertTrue(file.exists()); } @Test - public void testSerializeMinimal() throws SerializationException, SAXException { + public void serializeMinimal() throws SerializationException, SAXException { File file = new File("src/test/resources/minimum.xml"); Environment environment = new DefaultEnvironment.Builder() .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() @@ -89,7 +92,7 @@ public void testSerializeMinimal() throws SerializationException, SAXException { } @Test - public void testSerializeSimpleWithTestNamespacePrefix() throws SerializationException, SAXException { + public void serializeSimpleWithTestNamespacePrefix() throws SerializationException, SAXException { Map nsPrefixes = new HashMap<>(AasXmlNamespaceContext.PREFERRED_PREFIX_CONTEXT); nsPrefixes.put("test", nsPrefixes.get("aas")); nsPrefixes.remove("aas"); @@ -97,17 +100,17 @@ public void testSerializeSimpleWithTestNamespacePrefix() throws SerializationExc } @Test - public void testSerializeSimple() throws SerializationException, SAXException { + public void serializeSimple() throws SerializationException, SAXException { validateXmlSerializer(AASSIMPLE_FILE, AASSimple.createEnvironment()); } @Test - public void testSerializeFull() throws SerializationException, SAXException { + public void serializeFull() throws SerializationException, SAXException { validateXmlSerializer(AASFULL_FILE, AASFull.createEnvironment()); } @Test - public void testConceptDescriptionAgainstXsdSchema() throws SerializationException, SAXException { + public void validateConceptDescriptionAgainstXsdSchema() throws SerializationException, SAXException { ConceptDescription object = AASSimple.createConceptDescriptionMaxRotationSpeed(); Set errors = validateAgainstXsdSchema( new XmlSerializer().write(new DefaultEnvironment.Builder().conceptDescriptions(object).build())); assertTrue(errors.isEmpty()); @@ -115,7 +118,7 @@ public void testConceptDescriptionAgainstXsdSchema() throws SerializationExcepti @Test - public void testMinimalOperationAgainstXsdSchema() throws SerializationException, SAXException { + public void validateMinimalOperationAgainstXsdSchema() throws SerializationException, SAXException { Submodel object = new DefaultSubmodel.Builder() .id("testSubmodel") .idShort("testSubmodel") @@ -136,7 +139,7 @@ public void testMinimalOperationAgainstXsdSchema() throws SerializationException } @Test - public void testGYear() throws SerializationException, SAXException { + public void validateGYearAgainstXsdSchema() throws SerializationException, SAXException { Submodel submodel = new DefaultSubmodel.Builder().id("yearTestSm").submodelElements(new DefaultProperty.Builder().idShort("yearTestProp").valueType(DataTypeDefXSD.GYEAR).build()).build(); String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().submodels(submodel).build()); Set errors = validateAgainstXsdSchema(xml); @@ -145,7 +148,7 @@ public void testGYear() throws SerializationException, SAXException { @Test - public void testDocumentationSubmodelAgainstXsdSchema() throws SerializationException, SAXException { + public void validateDocumentationSubmodelAgainstXsdSchema() throws SerializationException, SAXException { Submodel object = AASSimple.createSubmodelDocumentation(); String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().submodels(object).build()); Set errors = validateAgainstXsdSchema( xml ); @@ -154,14 +157,22 @@ public void testDocumentationSubmodelAgainstXsdSchema() throws SerializationExce @Test - public void testIsCaseOfAgainstXsdSchema() throws SerializationException, SAXException { + public void validateIsCaseOfAgainstXsdSchema() throws SerializationException, SAXException { ConceptDescription object = AASFull.createEnvironment().getConceptDescriptions().get(0); String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().conceptDescriptions(object).build()); Set errors = validateAgainstXsdSchema( xml ); assertTrue(errors.isEmpty()); } + @Test + public void serializeAASWithExtensionMinimal() throws SerializationException, SAXException { + validateXmlSerializer(AAS_WITH_EXTENSION_MINIMAL, Examples.EXTENSION_MINIMAL, new XmlSerializer()); + } + @Test + public void serializeAASWithExtensionMaximal() throws SerializationException, SAXException { + validateXmlSerializer(AAS_WITH_EXTENSION_MAXIMAL, Examples.EXTENSION_MAXIMAL, new XmlSerializer()); + } private Set validateAgainstXsdSchema(String xml) throws SAXException { return new XmlSchemaValidator().validateSchema(xml); @@ -176,7 +187,7 @@ private void validateXmlSerializer(File expectedFile, Environment environment, X throws SerializationException, SAXException { String actual = xmlSerializer.write(environment); Set errors = validateAgainstXsdSchema(actual); - logger.debug(actual); + logger.info(actual); logErrors(expectedFile.getName(), errors); assertTrue(errors.isEmpty()); CompareMatcher xmlTestMatcher = CompareMatcher diff --git a/dataformat-xml/src/test/resources/admin-shell-io/Extension/maximal.xml b/dataformat-xml/src/test/resources/admin-shell-io/Extension/maximal.xml new file mode 100644 index 000000000..0283acaec --- /dev/null +++ b/dataformat-xml/src/test/resources/admin-shell-io/Extension/maximal.xml @@ -0,0 +1,52 @@ + + + + + + + + ExternalReference + + + GlobalReference + urn:another-company07:4d1bd2cb + + + + + + ExternalReference + + + GlobalReference + urn:an-example13:be48ff29 + + + + + something_aae6caf4 + xs:unsignedShort + 10233 + + + ModelReference + + + Submodel + urn:another-example01:f7faa581 + + + + + + + something_142922d6 + + NotApplicable + something_eea66fa1 + + + + diff --git a/dataformat-xml/src/test/resources/admin-shell-io/Extension/minimal.xml b/dataformat-xml/src/test/resources/admin-shell-io/Extension/minimal.xml new file mode 100644 index 000000000..cf753d6f1 --- /dev/null +++ b/dataformat-xml/src/test/resources/admin-shell-io/Extension/minimal.xml @@ -0,0 +1,19 @@ + + + + + + + something_aae6caf4 + + + something_142922d6 + + NotApplicable + something_eea66fa1 + + + + diff --git a/dataformat-xml/src/test/resources/admin-shell-io/License.md b/dataformat-xml/src/test/resources/admin-shell-io/License.md new file mode 100644 index 000000000..bc9888bb0 --- /dev/null +++ b/dataformat-xml/src/test/resources/admin-shell-io/License.md @@ -0,0 +1,5 @@ +The files contained in this directory are taken from https://github.com/admin-shell-io/aas-specs/ where they are made available under the CC BY 4.0 License (https://creativecommons.org/licenses/by/4.0/). + +They are modified in the following way: +- Added xml version tag +- Added namespaces \ No newline at end of file From 2b36604d69504ed7b69a6c968d64089633868113 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Mon, 10 Jul 2023 15:35:06 +0200 Subject: [PATCH 8/9] Extension deserialization working Signed-off-by: Frank Schnicke --- .../v3/dataformat/xml/XMLDeserializerTest.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java index 784f3f888..9c0e473fb 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java @@ -19,8 +19,10 @@ import java.util.List; import org.eclipse.digitaltwin.aas4j.v3.dataformat.DeserializationException; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.SerializationException; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASFull; import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.AASSimple; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.Examples; import org.eclipse.digitaltwin.aas4j.v3.model.Environment; import org.eclipse.digitaltwin.aas4j.v3.model.Operation; import org.eclipse.digitaltwin.aas4j.v3.model.OperationVariable; @@ -29,6 +31,7 @@ import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement; import org.junit.Assert; import org.junit.Test; +import org.xml.sax.SAXException; public class XMLDeserializerTest { @@ -116,4 +119,18 @@ public void deserializeAASFullConceptDescription() throws FileNotFoundException, Assert.assertEquals(AASFull.createEnvironment().getConceptDescriptions(), env.getConceptDescriptions()); } + + @Test + public void deserializeAASWithExtensionMinimal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MINIMAL); + + Assert.assertEquals(Examples.EXTENSION_MINIMAL, env); + } + + @Test + public void deserializeAASWithExtensionMaximal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MAXIMAL); + + Assert.assertEquals(Examples.EXTENSION_MAXIMAL, env); + } } From 3ffd81ec2ef8d4c178f9bd9f852f57b85bfbb340 Mon Sep 17 00:00:00 2001 From: Frank Schnicke Date: Tue, 11 Jul 2023 10:51:19 +0200 Subject: [PATCH 9/9] Replaces tabs with spaces --- .../aas4j/v3/dataformat/core/Examples.java | 8 +- .../mixins/AssetAdministrationShellMixin.java | 8 +- .../dataformat/xml/mixins/ExtensionMixin.java | 4 +- .../xml/serialization/RefersToSerializer.java | 30 +++--- .../dataformat/xml/XMLDeserializerTest.java | 92 +++++++++---------- .../v3/dataformat/xml/XmlSerializerTest.java | 86 ++++++++--------- .../v3/dataformat/xml/XmlValidationTest.java | 4 +- 7 files changed, 116 insertions(+), 116 deletions(-) diff --git a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java index dcfef1c49..72261ada7 100644 --- a/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java +++ b/dataformat-core/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/core/Examples.java @@ -36,7 +36,7 @@ public class Examples { .name("something_aae6caf4") .build()) .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.NOT_APPLICABLE) + .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetID("something_eea66fa1") .build()) .build()) @@ -49,13 +49,13 @@ public class Examples { .name("something_aae6caf4") .value("10233") .valueType(DataTypeDefXSD.UNSIGNED_SHORT) - .refersTo(new DefaultReference.Builder() + .refersTo(new DefaultReference.Builder() .keys(new DefaultKey.Builder() .type(KeyTypes.SUBMODEL) .value("urn:another-example01:f7faa581") .build()) .type(ReferenceTypes.MODEL_REFERENCE) - .build()) + .build()) .semanticID(new DefaultReference.Builder() .keys(new DefaultKey.Builder() .type(KeyTypes.GLOBAL_REFERENCE) @@ -72,7 +72,7 @@ public class Examples { .build()) .build()) .assetInformation(new DefaultAssetInformation.Builder() - .assetKind(AssetKind.NOT_APPLICABLE) + .assetKind(AssetKind.NOT_APPLICABLE) .globalAssetID("something_eea66fa1") .build()) .build()) diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java index bc9398c41..fd7579737 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/AssetAdministrationShellMixin.java @@ -28,12 +28,12 @@ public interface AssetAdministrationShellMixin { - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "id") - public String getID(); + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "id") + public String getID(); - @JacksonXmlElementWrapper(namespace = AasXmlNamespaceContext.AAS_URI, localName = "submodels") - @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "reference") + @JacksonXmlElementWrapper(namespace = AasXmlNamespaceContext.AAS_URI, localName = "submodels") + @JacksonXmlProperty(namespace = AasXmlNamespaceContext.AAS_URI, localName = "reference") public List getSubmodels(); } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java index b51ace08d..21e27d0cb 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/mixins/ExtensionMixin.java @@ -25,6 +25,6 @@ @JsonPropertyOrder({ "semanticId", "supplementalSemanticIds", "name", "valueType", "value", "refersTo" }) public interface ExtensionMixin { - @JsonSerialize(using = RefersToSerializer.class) - List getRefersTo(); + @JsonSerialize(using = RefersToSerializer.class) + List getRefersTo(); } diff --git a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java index 466f97d15..be0acf819 100644 --- a/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java +++ b/dataformat-xml/src/main/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/serialization/RefersToSerializer.java @@ -47,25 +47,25 @@ */ public class RefersToSerializer extends JsonSerializer> { - @Override - public void serialize(List value, JsonGenerator gen, SerializerProvider serializers) throws IOException { - if (value.isEmpty()) - return; + @Override + public void serialize(List value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + if (value.isEmpty()) + return; - ToXmlGenerator xgen = (ToXmlGenerator) gen; + ToXmlGenerator xgen = (ToXmlGenerator) gen; - xgen.writeStartObject(); + xgen.writeStartObject(); - for (Reference ref : value) { - writeReference(xgen, ref); - } + for (Reference ref : value) { + writeReference(xgen, ref); + } - xgen.writeEndObject(); - } + xgen.writeEndObject(); + } - private void writeReference(ToXmlGenerator xgen, Reference ref) throws IOException { - xgen.writeFieldName("reference"); - xgen.writeObject(ref); - } + private void writeReference(ToXmlGenerator xgen, Reference ref) throws IOException { + xgen.writeFieldName("reference"); + xgen.writeObject(ref); + } } diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java index 9c0e473fb..8da48bc62 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XMLDeserializerTest.java @@ -35,33 +35,33 @@ public class XMLDeserializerTest { - @Test - public void deserializeAASSimple() throws FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); + @Test + public void deserializeAASSimple() throws FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); - Assert.assertEquals(AASSimple.createEnvironment(), env); - } + Assert.assertEquals(AASSimple.createEnvironment(), env); + } @Test - public void deserializeAASSimpleAAS() throws Exception { + public void deserializeAASSimpleAAS() throws Exception { Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); - Assert.assertEquals(AASSimple.createEnvironment().getAssetAdministrationShells(), env.getAssetAdministrationShells()); - } + Assert.assertEquals(AASSimple.createEnvironment().getAssetAdministrationShells(), env.getAssetAdministrationShells()); + } - @Test - public void deserializeAASSimpleSubmodel() throws Exception { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); + @Test + public void deserializeAASSimpleSubmodel() throws Exception { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); - Assert.assertEquals(AASSimple.createEnvironment().getSubmodels(), env.getSubmodels()); - } + Assert.assertEquals(AASSimple.createEnvironment().getSubmodels(), env.getSubmodels()); + } - @Test - public void deserializeAASSimpleConceptDescription() throws Exception { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); - - Assert.assertEquals(AASSimple.createEnvironment().getConceptDescriptions(), env.getConceptDescriptions()); - } + @Test + public void deserializeAASSimpleConceptDescription() throws Exception { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASSIMPLE_FILE); + + Assert.assertEquals(AASSimple.createEnvironment().getConceptDescriptions(), env.getConceptDescriptions()); + } @Test public void deserializeAnnotedRelationshipElement() throws Exception { @@ -81,7 +81,7 @@ public void deserializeQualifier() throws Exception { @Test public void deserializeOperation() throws Exception { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE_WITH_OPERATIONS); + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE_WITH_OPERATIONS); Assert.assertNotNull(env); OperationVariable inputVariable = ((Operation) env.getSubmodels().get(0).getSubmodelElements().get(0)).getInputVariables().get(0); @@ -97,40 +97,40 @@ public void deserializeOperation() throws Exception { @Test public void deserializeAASFull() throws FileNotFoundException, DeserializationException { Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); - Assert.assertEquals(AASFull.createEnvironment(), env); + Assert.assertEquals(AASFull.createEnvironment(), env); } - @Test - public void deserializeAASFullAAS() throws FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); - Assert.assertEquals(AASFull.createEnvironment().getAssetAdministrationShells(), env.getAssetAdministrationShells()); - } + @Test + public void deserializeAASFullAAS() throws FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); + Assert.assertEquals(AASFull.createEnvironment().getAssetAdministrationShells(), env.getAssetAdministrationShells()); + } - @Test - public void deserializeAASFullSubmodel() throws FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); + @Test + public void deserializeAASFullSubmodel() throws FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); - Assert.assertEquals(AASFull.createEnvironment().getSubmodels(), env.getSubmodels()); - } + Assert.assertEquals(AASFull.createEnvironment().getSubmodels(), env.getSubmodels()); + } - @Test - public void deserializeAASFullConceptDescription() throws FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); + @Test + public void deserializeAASFullConceptDescription() throws FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AASFULL_FILE); - Assert.assertEquals(AASFull.createEnvironment().getConceptDescriptions(), env.getConceptDescriptions()); - } + Assert.assertEquals(AASFull.createEnvironment().getConceptDescriptions(), env.getConceptDescriptions()); + } - @Test - public void deserializeAASWithExtensionMinimal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MINIMAL); + @Test + public void deserializeAASWithExtensionMinimal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MINIMAL); - Assert.assertEquals(Examples.EXTENSION_MINIMAL, env); - } + Assert.assertEquals(Examples.EXTENSION_MINIMAL, env); + } - @Test - public void deserializeAASWithExtensionMaximal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { - Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MAXIMAL); + @Test + public void deserializeAASWithExtensionMaximal() throws SerializationException, SAXException, FileNotFoundException, DeserializationException { + Environment env = new XmlDeserializer().read(XmlSerializerTest.AAS_WITH_EXTENSION_MAXIMAL); - Assert.assertEquals(Examples.EXTENSION_MAXIMAL, env); - } + Assert.assertEquals(Examples.EXTENSION_MAXIMAL, env); + } } diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java index a3e72b1c2..c50574d3e 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlSerializerTest.java @@ -62,8 +62,8 @@ public class XmlSerializerTest { public static final java.io.File AASFULL_FILE_WITH_ANNOTATED_RELATIONSHIP = new java.io.File("src/test/resources/annotated_relationship_example.xml"); public static final java.io.File AASFULL_FILE_WITH_QUALIFIERS = new java.io.File("src/test/resources/qualifier_example.xml"); public static final java.io.File AASFULL_FILE_WITH_OPERATIONS = new java.io.File("src/test/resources/operation_example.xml"); - public static final java.io.File AAS_WITH_EXTENSION_MINIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/minimal.xml"); - public static final java.io.File AAS_WITH_EXTENSION_MAXIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/maximal.xml"); + public static final java.io.File AAS_WITH_EXTENSION_MINIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/minimal.xml"); + public static final java.io.File AAS_WITH_EXTENSION_MAXIMAL = new java.io.File("src/test/resources/admin-shell-io/Extension/maximal.xml"); private static final Logger logger = LoggerFactory.getLogger(XmlSerializerTest.class); @@ -71,14 +71,14 @@ public class XmlSerializerTest { public TemporaryFolder tempFolder = new TemporaryFolder(); @Test - public void writeToFile() throws IOException, SerializationException { + public void writeToFile() throws IOException, SerializationException { File file = tempFolder.newFile("output.xml"); - new XmlSerializer().write(file, AASSimple.createEnvironment()); + new XmlSerializer().write(file, AASSimple.createEnvironment()); assertTrue(file.exists()); } @Test - public void serializeMinimal() throws SerializationException, SAXException { + public void serializeMinimal() throws SerializationException, SAXException { File file = new File("src/test/resources/minimum.xml"); Environment environment = new DefaultEnvironment.Builder() .assetAdministrationShells(new DefaultAssetAdministrationShell.Builder() @@ -92,25 +92,25 @@ public void serializeMinimal() throws SerializationException, SAXException { } @Test - public void serializeSimpleWithTestNamespacePrefix() throws SerializationException, SAXException { + public void serializeSimpleWithTestNamespacePrefix() throws SerializationException, SAXException { Map nsPrefixes = new HashMap<>(AasXmlNamespaceContext.PREFERRED_PREFIX_CONTEXT); nsPrefixes.put("test", nsPrefixes.get("aas")); nsPrefixes.remove("aas"); - validateXmlSerializer(AASSIMPLE_FILE_WITH_TEST_NAMESPACE, AASSimple.createEnvironment(), new XmlSerializer(nsPrefixes)); + validateXmlSerializer(AASSIMPLE_FILE_WITH_TEST_NAMESPACE, AASSimple.createEnvironment(), new XmlSerializer(nsPrefixes)); } @Test - public void serializeSimple() throws SerializationException, SAXException { - validateXmlSerializer(AASSIMPLE_FILE, AASSimple.createEnvironment()); + public void serializeSimple() throws SerializationException, SAXException { + validateXmlSerializer(AASSIMPLE_FILE, AASSimple.createEnvironment()); } @Test - public void serializeFull() throws SerializationException, SAXException { - validateXmlSerializer(AASFULL_FILE, AASFull.createEnvironment()); + public void serializeFull() throws SerializationException, SAXException { + validateXmlSerializer(AASFULL_FILE, AASFull.createEnvironment()); } @Test - public void validateConceptDescriptionAgainstXsdSchema() throws SerializationException, SAXException { + public void validateConceptDescriptionAgainstXsdSchema() throws SerializationException, SAXException { ConceptDescription object = AASSimple.createConceptDescriptionMaxRotationSpeed(); Set errors = validateAgainstXsdSchema( new XmlSerializer().write(new DefaultEnvironment.Builder().conceptDescriptions(object).build())); assertTrue(errors.isEmpty()); @@ -118,7 +118,7 @@ public void validateConceptDescriptionAgainstXsdSchema() throws SerializationExc @Test - public void validateMinimalOperationAgainstXsdSchema() throws SerializationException, SAXException { + public void validateMinimalOperationAgainstXsdSchema() throws SerializationException, SAXException { Submodel object = new DefaultSubmodel.Builder() .id("testSubmodel") .idShort("testSubmodel") @@ -138,17 +138,17 @@ public void validateMinimalOperationAgainstXsdSchema() throws SerializationExcep assertTrue(errors.isEmpty()); } - @Test - public void validateGYearAgainstXsdSchema() throws SerializationException, SAXException { - Submodel submodel = new DefaultSubmodel.Builder().id("yearTestSm").submodelElements(new DefaultProperty.Builder().idShort("yearTestProp").valueType(DataTypeDefXSD.GYEAR).build()).build(); - String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().submodels(submodel).build()); - Set errors = validateAgainstXsdSchema(xml); - assertTrue(errors.isEmpty()); - } + @Test + public void validateGYearAgainstXsdSchema() throws SerializationException, SAXException { + Submodel submodel = new DefaultSubmodel.Builder().id("yearTestSm").submodelElements(new DefaultProperty.Builder().idShort("yearTestProp").valueType(DataTypeDefXSD.GYEAR).build()).build(); + String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().submodels(submodel).build()); + Set errors = validateAgainstXsdSchema(xml); + assertTrue(errors.isEmpty()); + } @Test - public void validateDocumentationSubmodelAgainstXsdSchema() throws SerializationException, SAXException { + public void validateDocumentationSubmodelAgainstXsdSchema() throws SerializationException, SAXException { Submodel object = AASSimple.createSubmodelDocumentation(); String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().submodels(object).build()); Set errors = validateAgainstXsdSchema( xml ); @@ -157,22 +157,22 @@ public void validateDocumentationSubmodelAgainstXsdSchema() throws Serialization @Test - public void validateIsCaseOfAgainstXsdSchema() throws SerializationException, SAXException { - ConceptDescription object = AASFull.createEnvironment().getConceptDescriptions().get(0); + public void validateIsCaseOfAgainstXsdSchema() throws SerializationException, SAXException { + ConceptDescription object = AASFull.createEnvironment().getConceptDescriptions().get(0); String xml = new XmlSerializer().write(new DefaultEnvironment.Builder().conceptDescriptions(object).build()); Set errors = validateAgainstXsdSchema( xml ); assertTrue(errors.isEmpty()); } - @Test - public void serializeAASWithExtensionMinimal() throws SerializationException, SAXException { - validateXmlSerializer(AAS_WITH_EXTENSION_MINIMAL, Examples.EXTENSION_MINIMAL, new XmlSerializer()); + @Test + public void serializeAASWithExtensionMinimal() throws SerializationException, SAXException { + validateXmlSerializer(AAS_WITH_EXTENSION_MINIMAL, Examples.EXTENSION_MINIMAL, new XmlSerializer()); } - @Test - public void serializeAASWithExtensionMaximal() throws SerializationException, SAXException { - validateXmlSerializer(AAS_WITH_EXTENSION_MAXIMAL, Examples.EXTENSION_MAXIMAL, new XmlSerializer()); - } + @Test + public void serializeAASWithExtensionMaximal() throws SerializationException, SAXException { + validateXmlSerializer(AAS_WITH_EXTENSION_MAXIMAL, Examples.EXTENSION_MAXIMAL, new XmlSerializer()); + } private Set validateAgainstXsdSchema(String xml) throws SAXException { return new XmlSchemaValidator().validateSchema(xml); @@ -187,7 +187,7 @@ private void validateXmlSerializer(File expectedFile, Environment environment, X throws SerializationException, SAXException { String actual = xmlSerializer.write(environment); Set errors = validateAgainstXsdSchema(actual); - logger.info(actual); + logger.info(actual); logErrors(expectedFile.getName(), errors); assertTrue(errors.isEmpty()); CompareMatcher xmlTestMatcher = CompareMatcher @@ -229,18 +229,18 @@ private boolean ignoreDefaults(Node node) { return false; } - if (node.getLocalName() != null - && node.getLocalName().equals("category") - && node.getFirstChild().getNodeValue().equals("PROPERTY")) { // TODO: only for ConceptDescriptions - return false; - } - - if (node.getLocalName() != null - && node.getLocalName().equals("orderRelevant") - && node.getFirstChild().getNodeValue().equals("true")) { - return false; - } - + if (node.getLocalName() != null + && node.getLocalName().equals("category") + && node.getFirstChild().getNodeValue().equals("PROPERTY")) { // TODO: only for ConceptDescriptions + return false; + } + + if (node.getLocalName() != null + && node.getLocalName().equals("orderRelevant") + && node.getFirstChild().getNodeValue().equals("true")) { + return false; + } + return true; } diff --git a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java index eff9fa49c..6db0f8f26 100644 --- a/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java +++ b/dataformat-xml/src/test/java/org/eclipse/digitaltwin/aas4j/v3/dataformat/xml/XmlValidationTest.java @@ -46,7 +46,7 @@ public static void prepareValidator() throws SAXException { } @Test - @Parameters({ "src/test/resources/minimum.xml", "src/test/resources/Example_AAS_ServoDCMotor - Simplified.xml", "src/test/resources/test_demo_full_example.xml" }) + @Parameters({ "src/test/resources/minimum.xml", "src/test/resources/Example_AAS_ServoDCMotor - Simplified.xml", "src/test/resources/test_demo_full_example.xml" }) // import from admin-shell.io -> is actually V3 // -> fix name, as soon as it is fixed externally public void validateValidXml(String file) throws IOException { @@ -56,7 +56,7 @@ public void validateValidXml(String file) throws IOException { } @Test - @Parameters({ "src/test/resources/invalidXmlExample.xml", "src/test/resources/ServoDCMotor_invalid.xml" }) + @Parameters({ "src/test/resources/invalidXmlExample.xml", "src/test/resources/ServoDCMotor_invalid.xml" }) public void validateInvalidXml(String file) throws IOException { Set errors = validateXmlFile(file); logErrors(file, errors);