-
Notifications
You must be signed in to change notification settings - Fork 47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add tests for submodel methods #360
feat: add tests for submodel methods #360
Conversation
…a + patchSubmodelElements
…com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into add-test-cases-for-submodel-methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check if https://github.com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk/blob/cef93d3d458ab88a2fea898bea48e020db5c7d0d/basyx.submodelrepository/basyx.submodelrepository-http/src/main/java/org/eclipse/digitaltwin/basyx/submodelrepository/http/SubmodelRepositoryApiHTTPController.java#L204 is being tested
@@ -625,10 +625,9 @@ public void deleteNonExistingFile() throws IOException { | |||
|
|||
submodelService.deleteFileValue(SubmodelServiceHelper.SUBMODEL_TECHNICAL_DATA_FILE_ID_SHORT); | |||
} | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove these changes
return repoApi.getSubmodelById(submodelId, null, null); | ||
} catch (ApiException e) { | ||
if (e.getCode() == HttpStatus.NOT_FOUND.value()) { | ||
throw new ElementDoesNotExistException(submodelId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use mapExceptionSubmodelAccess(...) instead of the conditional
@@ -47,4 +47,12 @@ public PropertyValue(String value) { | |||
public String getValue() { | |||
return value; | |||
} | |||
|
|||
@Override | |||
public boolean equals(Object obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to override equals here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In getSubmodelByIdValueOnlyExistingSubmodel, I need to compare the objects of type SubmodelValueOnly which have a Map of items where the value is of type SubmodelElementValue.
PropertyValue implements the interface SubmodelElementValue, hence, when i compare the SubmodelValueOnly objects, I'm actually comparing their map of items to check if they are equal.
Given that PropertyValue isn't a primitive data type, I had to add the equals method so that the comparison can be made between the items. The test fails otherwise.
Yes, it is being tested. SubmodelRepositoryApiHTTPController uses SubmodelRepository and basyx.submodelrepository-core contains the test for getSubmodelByIdValueOnly in SubmodelRepositorySuite.java. |
…com/ShehriyarShariq-Fraunhofer/basyx-java-server-sdk into add-test-cases-for-submodel-methods
@@ -207,7 +207,11 @@ public SubmodelValueOnly getSubmodelByIdValueOnly(String submodelId) throws Elem | |||
|
|||
@Override | |||
public Submodel getSubmodelByIdMetadata(String submodelId) throws ElementDoesNotExistException { | |||
return repoApi.getSubmodelById(submodelId, null, null); | |||
try { | |||
return repoApi.getSubmodelById(submodelId, null, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be getSubmodelByIdMetadata
Pull Request Template
Description of Changes
Added test cases for SubmodelRepository(getSubmodelByIdValueOnly and getSubmodelByIdMetadata) and SubmodelService(patchSubmodelElements).