Skip to content

Commit

Permalink
Merge pull request eclipse-basyx#297 from ahoimariew/main
Browse files Browse the repository at this point in the history
provides tests for updating a submodel element in root
  • Loading branch information
aaronzi authored Jul 5, 2024
2 parents 312b3a2 + 1f30acb commit 77fff90
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,22 @@ public void updateNonFileSME() throws FileNotFoundException, IOException, ParseE
BaSyxHttpTestUtils.assertSameJSONContent(element, BaSyxHttpTestUtils.getResponseAsString(fetchedResponse));
}

@Test
public void updateNonNestedSME() throws FileNotFoundException, IOException, ParseException {
String submodelJSON = getJSONValueAsString("SingleSubmodelNew.json");
String element = getJSONValueAsString("PropertySubmodelElementUpdate.json");
String idShortPath = "MaxRotationSpeed";

CloseableHttpResponse creationResponse = BaSyxSubmodelHttpTestUtils.createSubmodel(getURL(), submodelJSON);
assertSubmodelCreationReponse(submodelJSON, creationResponse);

CloseableHttpResponse updatedResponse = updateElement(createSpecificSubmodelElementURL(DummySubmodelFactory.SUBMODEL_TECHNICAL_DATA_ID,idShortPath), element);
assertEquals(HttpStatus.NO_CONTENT.value(), updatedResponse.getCode());

CloseableHttpResponse fetchedResponse = BaSyxHttpTestUtils.executeGetOnURL(createSpecificSubmodelElementURL(DummySubmodelFactory.SUBMODEL_TECHNICAL_DATA_ID,idShortPath));
BaSyxHttpTestUtils.assertSameJSONContent(element, BaSyxHttpTestUtils.getResponseAsString(fetchedResponse));
}

@Test
public void updateNonFileSMEWithFileSME() throws FileNotFoundException, IOException, ParseException {
String element = getJSONValueAsString("FileSubmodelElementUpdate.json");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,23 @@ public void updateNonFileSME() {
assertEquals(newProperty, updatedProperty);
}

@Test
public void updateNonNestedSME() {
Submodel technicalSubmodel = DummySubmodelFactory.createTechnicalDataSubmodel();
SubmodelService submodelService = getSubmodelService(technicalSubmodel);

String idShortPath = "dummyProperty";

Property property = createDummyProperty(idShortPath);
submodelService.createSubmodelElement(property);

Property expectedUpdatedProperty = SubmodelServiceHelper.createDummyProperty(idShortPath, "arbitraryValue", DataTypeDefXsd.STRING);
submodelService.updateSubmodelElement(idShortPath, expectedUpdatedProperty);

Property actualUpdatedProperty = (Property) submodelService.getSubmodelElement(idShortPath);
assertEquals(expectedUpdatedProperty, actualUpdatedProperty);
}

@Test
public void updateNonFileSMEWithFileSME() {
Submodel technicalSubmodel = DummySubmodelFactory.createTechnicalDataSubmodel();
Expand Down

0 comments on commit 77fff90

Please sign in to comment.