diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelService.java b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelService.java index a9e713572..bb372047c 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelService.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/main/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelService.java @@ -90,7 +90,6 @@ public interface SubmodelService { /** * Creates a Submodel Element - * @return * */ public SubmodelElement createSubmodelElement(SubmodelElement submodelElement); @@ -102,7 +101,7 @@ public interface SubmodelService { * the SubmodelElement IdShortPath * @param submodelElement * the submodel element to be created - * @return + * @return the SubmodelElement * @throws ElementDoesNotExistException * If the submodel element defined in the path does not exist */ @@ -113,6 +112,7 @@ public interface SubmodelService { * * @param idShortPath * @param submodelElement + * @return the SubmodelElement * @throws ElementDoesNotExistException * If the submodel element defined in the path does not exist */ diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceHelper.java b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceHelper.java index 8c6ef3f31..542f85816 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceHelper.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceHelper.java @@ -358,6 +358,14 @@ public static Property createDummyProperty(String idShort, String value, DataTyp .build(); } + public static SubmodelElement createDummySME(String idShort, String value, DataTypeDefXsd dataType) { + return new DefaultProperty.Builder().idShort(idShort) + .category("cat1") + .value(value) + .valueType(dataType) + .build(); + } + public static File createDummyFile(String idShort, String contentType, String value) { return new DefaultFile.Builder().idShort(idShort) .category("file") diff --git a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceSuite.java b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceSuite.java index df0da52b5..8a2d9c878 100644 --- a/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceSuite.java +++ b/basyx.submodelservice/basyx.submodelservice-core/src/test/java/org/eclipse/digitaltwin/basyx/submodelservice/SubmodelServiceSuite.java @@ -305,11 +305,9 @@ public void createSubmodelElement() { property.setValue("205"); SubmodelService submodelService = getSubmodelService(technicalData); - SubmodelElement responseSubmodelElement = submodelService.createSubmodelElement(property); + submodelService.createSubmodelElement(property); SubmodelElement submodelEl = submodelService.getSubmodelElement("test123"); - - assertEquals(submodelEl, responseSubmodelElement); assertEquals("test123", submodelEl.getIdShort()); } @@ -336,20 +334,18 @@ public void createNestedSubmodelElement() { Property propertyInSmeList = new DefaultProperty.Builder().idShort("test456").category("cat1").value("305").valueType(DataTypeDefXsd.INTEGER).build(); String idShortPathPropertyInSmeCol = DummySubmodelFactory.SUBMODEL_OPERATIONAL_DATA_ELEMENT_COLLECTION_ID_SHORT; - SubmodelElement responseSubmodelElementCol = submodelService.createSubmodelElement(idShortPathPropertyInSmeCol, propertyInSmeCol); + submodelService.createSubmodelElement(idShortPathPropertyInSmeCol, propertyInSmeCol); String idShortPathPropertyInSmeList = DummySubmodelFactory.SUBMODEL_OPERATIONAL_DATA_ELEMENT_COLLECTION_ID_SHORT + "." + DummySubmodelFactory.SUBMODEL_OPERATIONAL_DATA_ELEMENT_LIST_ID_SHORT; - SubmodelElement responseSubmodelElementList = submodelService.createSubmodelElement(idShortPathPropertyInSmeList, propertyInSmeList); + submodelService.createSubmodelElement(idShortPathPropertyInSmeList, propertyInSmeList); idShortPathPropertyInSmeCol = idShortPathPropertyInSmeCol.concat(".test123"); SubmodelElement propertyInCollectionCreated = submodelService.getSubmodelElement(idShortPathPropertyInSmeCol); assertEquals("test123", propertyInCollectionCreated.getIdShort()); - assertEquals(propertyInCollectionCreated, responseSubmodelElementCol); idShortPathPropertyInSmeList = idShortPathPropertyInSmeList.concat("[1]"); SubmodelElement propertyInSmeListCreated = submodelService.getSubmodelElement(idShortPathPropertyInSmeList); assertEquals("test456", propertyInSmeListCreated.getIdShort()); - assertEquals(propertyInSmeListCreated, responseSubmodelElementList); } @Test @@ -376,14 +372,13 @@ public void updateNonNestedSME() { String idShortPath = "dummyProperty"; Property property = createDummyProperty(idShortPath); - SubmodelElement responseSubmodelElement = submodelService.createSubmodelElement(property); + submodelService.createSubmodelElement(property); Property expectedUpdatedProperty = SubmodelServiceHelper.createDummyProperty(idShortPath, "arbitraryValue", DataTypeDefXsd.STRING); submodelService.updateSubmodelElement(idShortPath, expectedUpdatedProperty); Property actualUpdatedProperty = (Property) submodelService.getSubmodelElement(idShortPath); assertEquals(expectedUpdatedProperty, actualUpdatedProperty); - assertEquals(submodelService.getSubmodelElement(idShortPath), responseSubmodelElement); } @Test @@ -723,6 +718,10 @@ private DefaultEntity createDummyEntityWithStatement(SubmodelElement submodelEle private DefaultProperty createDummyProperty(String idShort) { return new DefaultProperty.Builder().idShort(idShort).category("cat1").value("123").valueType(DataTypeDefXsd.INTEGER).build(); } + + private SubmodelElement createDummySME(String idShort) { + return new DefaultProperty.Builder().idShort(idShort).value("123").build(); + } private InputStream getInputStreamOfDummyFile(String fileContent) throws FileNotFoundException, IOException { return new ByteArrayInputStream(fileContent.getBytes());