From 2aa37f296b48595d364a55402ef12fcdf965f7a6 Mon Sep 17 00:00:00 2001 From: Jannik Fried Date: Wed, 31 Jul 2024 11:53:25 +0200 Subject: [PATCH] Makes Value Only of SubmodelElementCollection conform standard (#357) * Makes Value Only of SubmodelElementCollection conform standard * Changes internal use to HashMap for better Performance * Adapts JSON --- .../http/TestAasEnvironmentHTTP.java | 4 +- .../resources/AASEnvironmentValueOnly.json | 38 +++++++++++++ .../test/resources/BasicEventValueOnly.json | 53 ------------------- .../client/TestConnectedSubmodelElements.java | 6 ++- ...CollectionValueDeserializationFactory.java | 12 ++++- ...delElementValueDeserializationFactory.java | 4 +- ...bmodelElementValueDeserializationUtil.java | 11 ++-- ...modelElementCollectionValueSerializer.java | 10 ++-- .../value/SubmodelElementCollectionValue.java | 7 +-- .../SubmodelElementCollectionValueMapper.java | 5 +- .../value/mapper/ValueMapperUtil.java | 4 ++ .../value/TestMappedSubmodelElementValue.java | 21 +++----- .../value/expectedNewSubmodelValue.json | 24 ++++----- ...xpectedSubmodelElementCollectionValue.json | 16 +++--- ...ectedValueOnlySerializationOfSubmodel.json | 26 ++++----- .../setSubmodelElementCollectionValue.json | 16 +++--- 16 files changed, 121 insertions(+), 136 deletions(-) create mode 100644 basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/AASEnvironmentValueOnly.json delete mode 100644 basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/BasicEventValueOnly.json diff --git a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java index 6d050b3b7..26f6a42da 100644 --- a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java +++ b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/java/org/eclipse/basyx/digitaltwin/aasenvironment/http/TestAasEnvironmentHTTP.java @@ -74,7 +74,7 @@ public class TestAasEnvironmentHTTP { private static final String XML_ENV_PATH = "testEnvironment.xml"; private static final String WRONGEXT_ENV_PATH = "testEnvironment.txt"; private static final String JSON_OPERATIONALDATA_ENV_PATH = "operationalDataEnvironment.json"; - private static final String BASIC_EVENT_VALUE_ONLY = "BasicEventValueOnly.json"; + private static final String AASENVIRONMENT_VALUE_ONLY_JSON = "AASEnvironmentValueOnly.json"; private static ConfigurableApplicationContext appContext; private static SubmodelRepository submodelRepo; @@ -114,7 +114,7 @@ public void testAASEnvironmentSerialization_ValueOnly() throws FileNotFoundExcep response = executeGetOnURL(getOperationalDataValueOnlyURL(), JSON_MIMETYPE); assertEquals(HttpStatus.OK.value(), response.getCode()); - BaSyxHttpTestUtils.assertSameJSONContent(BaSyxHttpTestUtils.readJSONStringFromClasspath(BASIC_EVENT_VALUE_ONLY), BaSyxHttpTestUtils.getResponseAsString(response)); + BaSyxHttpTestUtils.assertSameJSONContent(BaSyxHttpTestUtils.readJSONStringFromClasspath(AASENVIRONMENT_VALUE_ONLY_JSON), BaSyxHttpTestUtils.getResponseAsString(response)); } @Test diff --git a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/AASEnvironmentValueOnly.json b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/AASEnvironmentValueOnly.json new file mode 100644 index 000000000..924987836 --- /dev/null +++ b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/AASEnvironmentValueOnly.json @@ -0,0 +1,38 @@ +{ + "ObserveValueUpdates": { + "observed": { + "type": "ExternalReference", + "keys": [ + { + "type": "Submodel", + "value": "www.example.com/ids/sm/2222_8041_1042_8057" + } + ] + } + }, + "ViaMqtt": { + "L1": "290.6217782649107", + "L2": "282.4599521889145", + "L3": "272.2067133660983", + "Active_Power_All": "104308.59396737856" + }, + "AnnotationBottom": "", + "ViaOpcUa": { + "L1": "299.53634421194454", + "L2": "296.55226321871635", + "L3": "290.9149535087691", + "Active_Power_All": "109456.23941992565" + }, + "ViaModbus": { + "L1": "160.26637", + "L2": "160.44434", + "L3": "163.39528", + "Active_Power_All": "59738.68" + }, + "ViaHTTP": { + "L1": "291.4213289500366", + "L2": "296.869547091201", + "L3": "299.65015492058336", + "Active_Power_All": "109572.7967447997" + } +} \ No newline at end of file diff --git a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/BasicEventValueOnly.json b/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/BasicEventValueOnly.json deleted file mode 100644 index 9fe23308b..000000000 --- a/basyx.aasenvironment/basyx.aasenvironment-http/src/test/resources/BasicEventValueOnly.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "AnnotationBottom": "", - "ObserveValueUpdates": { - "observed": { - "keys": [{ - "type": "Submodel", - "value": "www.example.com/ids/sm/2222_8041_1042_8057" - } - ], - "type": "ExternalReference" - } - }, - "ViaHTTP": [{ - "L1": "291.4213289500366" - }, { - "L2": "296.869547091201" - }, { - "L3": "299.65015492058336" - }, { - "Active_Power_All": "109572.7967447997" - } - ], - "ViaModbus": [{ - "L1": "160.26637" - }, { - "L2": "160.44434" - }, { - "L3": "163.39528" - }, { - "Active_Power_All": "59738.68" - } - ], - "ViaMqtt": [{ - "L1": "290.6217782649107" - }, { - "L2": "282.4599521889145" - }, { - "L3": "272.2067133660983" - }, { - "Active_Power_All": "104308.59396737856" - } - ], - "ViaOpcUa": [{ - "L1": "299.53634421194454" - }, { - "L2": "296.55226321871635" - }, { - "L3": "290.9149535087691" - }, { - "Active_Power_All": "109456.23941992565" - } - ] -} diff --git a/basyx.submodelservice/basyx.submodelservice-client/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/client/TestConnectedSubmodelElements.java b/basyx.submodelservice/basyx.submodelservice-client/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/client/TestConnectedSubmodelElements.java index 6713d1ef8..153d9fc33 100644 --- a/basyx.submodelservice/basyx.submodelservice-client/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/client/TestConnectedSubmodelElements.java +++ b/basyx.submodelservice/basyx.submodelservice-client/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/client/TestConnectedSubmodelElements.java @@ -369,7 +369,7 @@ public void getSubmodelElementCollectionValue() { public void setSubmodelElementCollectionValue() { DefaultSubmodelElementCollection submodelElementCollection = getDefaultSubmodelElementCollection(); ConnectedSubmodelElementCollection connectedSubmodelElementCollection = getConnectedSubmodelElementCollection(submodelElementCollection); - submodelElementCollection.getValue().add(getDefaultMultiLanguageProperty()); + submodelElementCollection.getValue().add(getDefaultMultiLanguageProperty("newMLP")); SubmodelElementCollectionValueMapper valueMapper = new SubmodelElementCollectionValueMapper(submodelElementCollection); connectedSubmodelElementCollection.setValue(valueMapper.getValue()); assertEquals(2, connectedSubmodelElementCollection.getValue().getValue().size()); @@ -445,6 +445,10 @@ private DefaultMultiLanguageProperty getDefaultMultiLanguageProperty() { return new DefaultMultiLanguageProperty.Builder().idShort(SUBMODEL_ELEMENT_ID_SHORT).value(Arrays.asList(new DefaultLangStringTextType.Builder().text(EXPECTED_STRING).language("de").build())).build(); } + private DefaultMultiLanguageProperty getDefaultMultiLanguageProperty(String idShort) { + return new DefaultMultiLanguageProperty.Builder().idShort(idShort).value(Arrays.asList(new DefaultLangStringTextType.Builder().text(EXPECTED_STRING).language("de").build())).build(); + } + private ConnectedMultiLanguageProperty getConnectedMultiLanguageProperty(DefaultMultiLanguageProperty property) { Submodel sm = createSubmodel(property); return new ConnectedMultiLanguageProperty(getSubmodelServiceUrl(Base64UrlEncodedIdentifier.encodeIdentifier(sm.getId())), SUBMODEL_ELEMENT_ID_SHORT); diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementCollectionValueDeserializationFactory.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementCollectionValueDeserializationFactory.java index a216c6e0d..74cc2ce0a 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementCollectionValueDeserializationFactory.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementCollectionValueDeserializationFactory.java @@ -26,9 +26,13 @@ package org.eclipse.digitaltwin.basyx.deserialization.factory; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementCollectionValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.ValueOnly; import com.fasterxml.jackson.core.JsonProcessingException; @@ -61,7 +65,13 @@ public SubmodelElementCollectionValueDeserializationFactory(ObjectMapper objectM * */ public SubmodelElementCollectionValue create() throws JsonProcessingException { - List valueOnlies = objectMapper.readValue(node.toString(), new TypeReference>() {}); + Map map = objectMapper.readValue(node.toString(), new TypeReference>() {}); + Map valueOnlies = new HashMap<>(); + + for (Map.Entry entry : map.entrySet()) { + SubmodelElementValue submodelElementValue = objectMapper.convertValue(entry.getValue(), SubmodelElementValue.class); + valueOnlies.put(entry.getKey(), submodelElementValue); + } return new SubmodelElementCollectionValue(valueOnlies); } diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementValueDeserializationFactory.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementValueDeserializationFactory.java index 2a233113f..27b304beb 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementValueDeserializationFactory.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/factory/SubmodelElementValueDeserializationFactory.java @@ -88,12 +88,12 @@ public SubmodelElementValue create(ObjectMapper mapper, JsonNode node) throws Js return mapper.convertValue(node, RelationshipElementValue.class); } else if (isTypeOfAnnotatedRelationshipElementValue(node)) { return mapper.convertValue(node, AnnotatedRelationshipElementValue.class); + } else if (isTypeOfBasicEventValue(node)) { + return mapper.convertValue(node, BasicEventValue.class); } else if (isTypeOfSubmodelElementListValue(node)) { return new SubmodelElementListValueDeserializationFactory(mapper, node).create(); } else if (isTypeOfSubmodelElementCollectionValue(node)) { return new SubmodelElementCollectionValueDeserializationFactory(mapper, node).create(); - } else if (isTypeOfBasicEventValue(node)) { - return mapper.convertValue(node, BasicEventValue.class); } throw new SubmodelElementValueDeserializationException(); diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/util/SubmodelElementValueDeserializationUtil.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/util/SubmodelElementValueDeserializationUtil.java index 80ac7959e..d8d95d38d 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/util/SubmodelElementValueDeserializationUtil.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/deserialization/util/SubmodelElementValueDeserializationUtil.java @@ -27,6 +27,8 @@ import java.lang.reflect.Array; import java.lang.reflect.Field; +import java.util.Iterator; +import java.util.Map; import java.util.Optional; import java.util.stream.Stream; @@ -90,7 +92,7 @@ public static boolean isTypeOfAnnotatedRelationshipElementValue(JsonNode node) { } public static boolean isTypeOfSubmodelElementCollectionValue(JsonNode node) { - return node.isArray() && hasStructureOfSubmodelElementCollectionValue(node); + return node.isObject() && hasStructureOfSubmodelElementCollectionValue(node); } public static boolean isTypeOfSubmodelElementListValue(JsonNode node) { @@ -161,9 +163,12 @@ private static boolean hasStructureOfMultiLanguagePropertyValue(JsonNode node) { } private static boolean hasStructureOfSubmodelElementCollectionValue(JsonNode node) { - for (JsonNode element : node) { - if (!isValidValueOnly(element)) + Iterator> fields = node.fields(); + while (fields.hasNext()) { + Map.Entry field = fields.next(); + if (!isInstanceOfSubmodelElementValue(field.getValue())) { return false; + } } return true; diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SubmodelElementCollectionValueSerializer.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SubmodelElementCollectionValueSerializer.java index 0448bd130..e1b876805 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SubmodelElementCollectionValueSerializer.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/serialization/SubmodelElementCollectionValueSerializer.java @@ -27,8 +27,10 @@ package org.eclipse.digitaltwin.basyx.serialization; import java.io.IOException; +import java.util.Map; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementCollectionValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementValue; import org.eclipse.digitaltwin.basyx.submodelservice.value.ValueOnly; import com.fasterxml.jackson.core.JsonGenerator; @@ -45,13 +47,13 @@ public class SubmodelElementCollectionValueSerializer extends JsonSerializer valueOnly : value.getValue().entrySet()) { + gen.writeObjectField(valueOnly.getKey(),valueOnly.getValue()); } - gen.writeEndArray(); + gen.writeEndObject(); } } diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/SubmodelElementCollectionValue.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/SubmodelElementCollectionValue.java index 3f63000a3..73e075af2 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/SubmodelElementCollectionValue.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/SubmodelElementCollectionValue.java @@ -25,6 +25,7 @@ package org.eclipse.digitaltwin.basyx.submodelservice.value; import java.util.List; +import java.util.Map; import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; @@ -35,18 +36,18 @@ * */ public class SubmodelElementCollectionValue implements SubmodelElementValue { - private List value; + private Map value; @SuppressWarnings("unused") private SubmodelElementCollectionValue() { super(); } - public SubmodelElementCollectionValue(List value) { + public SubmodelElementCollectionValue(Map value) { this.value = value; } - public List getValue() { + public Map getValue() { return value; } diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/SubmodelElementCollectionValueMapper.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/SubmodelElementCollectionValueMapper.java index fbf0f2845..b5f2e4458 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/SubmodelElementCollectionValueMapper.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/SubmodelElementCollectionValueMapper.java @@ -28,6 +28,9 @@ import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElementCollection; import org.eclipse.digitaltwin.basyx.submodelservice.value.SubmodelElementCollectionValue; +import org.eclipse.digitaltwin.basyx.submodelservice.value.ValueOnly; + +import java.util.stream.Collectors; /** * Maps {@link SubmodelElementCollection} value to {@link SubmodelElementCollectionValue} @@ -44,7 +47,7 @@ public SubmodelElementCollectionValueMapper(SubmodelElementCollection submodelEl @Override public SubmodelElementCollectionValue getValue() { - return new SubmodelElementCollectionValue(ValueMapperUtil.createValueOnlyCollection(submodelElementCollection.getValue())); + return new SubmodelElementCollectionValue(ValueMapperUtil.createValueOnlyCollection(submodelElementCollection.getValue()).stream().collect(Collectors.toMap(ValueOnly::getIdShort, ValueOnly::getSubmodelElementValue))); } @Override diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/ValueMapperUtil.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/ValueMapperUtil.java index 4a59c2690..5d53ecda0 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/ValueMapperUtil.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/value/mapper/ValueMapperUtil.java @@ -145,6 +145,10 @@ public static List createValueOnlyCollection(Collection submodelElements, List valueOnlies) { submodelElements.stream().forEach(submodelElement -> setValue(submodelElement, ValueMapperUtil.getSubmodelElementValue(submodelElement, valueOnlies))); } + + public static void setValueOfSubmodelElementWithValueOnly(Collection submodelElements, Map valueOnlies) { + submodelElements.stream().forEach(submodelElement -> setValue(submodelElement, valueOnlies.get(submodelElement.getIdShort()))); + } /** * Updates the value of {@link SubmodelElement} with its corresponding {@link SubmodelElementValue} diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/value/TestMappedSubmodelElementValue.java b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/value/TestMappedSubmodelElementValue.java index 5c8ca2262..805a60411 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/value/TestMappedSubmodelElementValue.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/value/TestMappedSubmodelElementValue.java @@ -25,10 +25,12 @@ package org.eclipse.digitaltwin.basyx.submodelservice.value; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.stream.Collectors; import org.eclipse.digitaltwin.aas4j.v3.model.AnnotatedRelationshipElement; @@ -349,8 +351,9 @@ public void mappedGetSubmodelElementCollectionValue() { @Test public void mappedSetSubmodelElementCollectionValue() { SubmodelElementCollection submodelElementCollection = SubmodelServiceHelper.createSubmodelElementCollection(); - - SubmodelElementCollectionValue submodelElementCollectionValue = new SubmodelElementCollectionValue(submodelElementCollectionValueOnlies); + Map map = submodelElementCollectionValueOnlies.stream() + .collect(Collectors.toMap(ValueOnly::getIdShort, ValueOnly::getSubmodelElementValue)); + SubmodelElementCollectionValue submodelElementCollectionValue = new SubmodelElementCollectionValue(map); setSubmodelElementCollectionValue(submodelElementCollection, submodelElementCollectionValue); @@ -546,14 +549,7 @@ private static void assertValuesAreEqual(Entity expected, EntityValueMapper file } private void assertValuesAreEqual(SubmodelElementCollection expected, SubmodelElementCollectionValue actual) { - - assertEquals(getSubmodelElementAtIndex(expected, 0).getIdShort(), getValueOnlyAtIndex(actual, 0).getIdShort()); - assertEquals(getSubmodelElementAtIndex(expected, 1).getIdShort(), getValueOnlyAtIndex(actual, 1).getIdShort()); - - assertEquals(((File) getSubmodelElementAtIndex(expected, 0)).getContentType(), ((FileBlobValue) getValueOnlyAtIndex(actual, 0).getSubmodelElementValue()).getContentType()); - assertEquals(((File) getSubmodelElementAtIndex(expected, 0)).getValue(), ((FileBlobValue) getValueOnlyAtIndex(actual, 0).getSubmodelElementValue()).getValue()); - - assertEquals(((Property) getSubmodelElementAtIndex(expected, 1)).getValue(), ((PropertyValue) getValueOnlyAtIndex(actual, 1).getSubmodelElementValue()).getValue()); + assertTrue(expected.getValue().stream().allMatch(sme -> actual.getValue().containsKey(sme.getIdShort()))); } private void assertValuesAreEqual(SubmodelElementList expected, SubmodelElementListValue actual) { @@ -662,11 +658,6 @@ private SubmodelElement getSubmodelElementAtIndex(SubmodelElementList submodelEl .get(index); } - private ValueOnly getValueOnlyAtIndex(SubmodelElementCollectionValue submodelElementCollectionValue, int index) { - return submodelElementCollectionValue.getValue() - .get(index); - } - private SubmodelElementValue getSubmodelElementValueAtIndex(SubmodelElementListValue submodelElementListValue, int index) { return submodelElementListValue.getSubmodelElementValues() .get(index); diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedNewSubmodelValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedNewSubmodelValue.json index f5e5cf213..4d358b375 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedNewSubmodelValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedNewSubmodelValue.json @@ -10,17 +10,13 @@ "new_SimpleList": [ "new_4370" ], - "new_SubmodelElementCollection": [ - { - "new_FileData": { - "contentType": "application/json", - "value": "new_testFile.json" - } + "new_SubmodelElementCollection": { + "new_FileData": { + "contentType": "application/json", + "value": "new_testFile.json" }, - { - "new_MaxRotationSpeed": "new_5000" - } - ], + "new_MaxRotationSpeed": "new_5000" + }, "new_BlobData": { "contentType": "application/xml", "value": "Test content of XML file" @@ -62,11 +58,9 @@ } ] }, - "new_SimpleCollection": [ - { - "new_MyFirstSubmodelElement": "new_4370" - } - ], + "new_SimpleCollection": { + "new_MyFirstSubmodelElement": "new_4370" + }, "new_FileData": { "contentType": "application/json", "value": "new_testFile.json" diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedSubmodelElementCollectionValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedSubmodelElementCollectionValue.json index a88064cdc..6a25dbd17 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedSubmodelElementCollectionValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedSubmodelElementCollectionValue.json @@ -1,11 +1,7 @@ -[ - { - "FileData": { - "contentType": "application/json", - "value": "testFile.json" - } +{ + "FileData": { + "contentType": "application/json", + "value": "testFile.json" }, - { - "MaxRotationSpeed": "5000" - } -] \ No newline at end of file + "MaxRotationSpeed": "5000" +} \ No newline at end of file diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json index c2fff9f68..caade8d42 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/expectedValueOnlySerializationOfSubmodel.json @@ -21,20 +21,16 @@ ] }, "RotationSpeed": "4370", - "SubmodelElementCollection": [ - { - "FileData": { - "contentType": "application/json", - "value": "testFile.json" - } - }, - { - "MaxRotationSpeed": "5000" - } - ], "SimpleList": [ "4370" ], + "SubmodelElementCollection": { + "FileData": { + "contentType": "application/json", + "value": "testFile.json" + }, + "MaxRotationSpeed": "5000" + }, "MultiLanguage": [ { "en": "Hello" @@ -74,11 +70,9 @@ } ] }, - "SimpleCollection": [ - { - "MyFirstSubmodelElement": "4370" - } - ], + "SimpleCollection": { + "MyFirstSubmodelElement": "4370" + }, "SubmodelElementList": [ { "min": 200, diff --git a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setSubmodelElementCollectionValue.json b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setSubmodelElementCollectionValue.json index 64259ac24..d0dacd1e9 100644 --- a/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setSubmodelElementCollectionValue.json +++ b/basyx.submodelservice/basyx.submodelservice-http/src/test/resources/value/setSubmodelElementCollectionValue.json @@ -1,11 +1,7 @@ -[ - { - "FileData": { - "contentType": "application/txt", - "value": "someRandomTestFile.txt" - } +{ + "FileData": { + "contentType": "application/txt", + "value": "someRandomTestFile.txt" }, - { - "MaxRotationSpeed": "4200" - } -] \ No newline at end of file + "MaxRotationSpeed": "4200" +}