-
Notifications
You must be signed in to change notification settings - Fork 48
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
fix: Response body for post #484
base: main
Are you sure you want to change the base?
Changes from 5 commits
7a0b4d2
52e3ab5
28160ca
33cf443
b160d85
947ed6c
3ba2774
b08c21b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -197,21 +197,23 @@ public void setSubmodelElementValue(String submodelId, String smeIdShort, Submod | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||
public void createSubmodelElement(String submodelId, SubmodelElement smElement) { | ||||||||||||||||||||||||||||||||||
public SubmodelElement createSubmodelElement(String submodelId, SubmodelElement smElement) { | ||||||||||||||||||||||||||||||||||
SubmodelService submodelService = getSubmodelServiceOrThrow(submodelId); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
submodelService.createSubmodelElement(smElement); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
updateSubmodel(submodelId, submodelService.getSubmodel()); | ||||||||||||||||||||||||||||||||||
return smElement; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||
public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement smElement) throws ElementDoesNotExistException { | ||||||||||||||||||||||||||||||||||
public SubmodelElement createSubmodelElement(String submodelId, String idShortPath, SubmodelElement smElement) throws ElementDoesNotExistException { | ||||||||||||||||||||||||||||||||||
SubmodelService submodelService = getSubmodelServiceOrThrow(submodelId); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
submodelService.createSubmodelElement(idShortPath, smElement); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
updateSubmodel(submodelId, submodelService.getSubmodel()); | ||||||||||||||||||||||||||||||||||
return smElement; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
@Override | ||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -99,17 +99,19 @@ public void setSubmodelElementValue(String submodelId, String idShortPath, Submo | |||||
} | ||||||
|
||||||
@Override | ||||||
public void createSubmodelElement(String submodelId, SubmodelElement smElement) { | ||||||
public SubmodelElement createSubmodelElement(String submodelId, SubmodelElement smElement) { | ||||||
decorated.createSubmodelElement(submodelId, smElement); | ||||||
SubmodelElement submodelElement = decorated.getSubmodelElement(submodelId, smElement.getIdShort()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally, we can get rid of this getSME operation and use the createSME return.
Suggested change
|
||||||
submodelElementCreated(submodelElement, getName(), submodelId, smElement.getIdShort()); | ||||||
return submodelElement; | ||||||
} | ||||||
|
||||||
@Override | ||||||
public void createSubmodelElement(String submodelId, String idShortPath, SubmodelElement smElement) throws ElementDoesNotExistException { | ||||||
public SubmodelElement createSubmodelElement(String submodelId, String idShortPath, SubmodelElement smElement) throws ElementDoesNotExistException { | ||||||
decorated.createSubmodelElement(submodelId, idShortPath, smElement); | ||||||
SubmodelElement submodelElement = decorated.getSubmodelElement(submodelId, idShortPath); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||||||
submodelElementCreated(submodelElement, getName(), submodelId, idShortPath); | ||||||
return submodelElement; | ||||||
} | ||||||
|
||||||
@Override | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -127,8 +127,9 @@ public void createSubmodelElementEvent() throws DeserializationException { | |||||
Submodel submodel = createSubmodelDummy("createSubmodelForElementEventId"); | ||||||
submodelRepository.createSubmodel(submodel); | ||||||
SubmodelElement submodelElement = createSubmodelElementDummy("createSubmodelElementEventId"); | ||||||
submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
SubmodelElement responseSubmodelElement = submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
|
||||||
assertEquals(responseSubmodelElement, submodelElement); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Expected should be first parameter.
Suggested change
|
||||||
assertEquals(topicFactory.createCreateSubmodelElementTopic(submodelRepository.getName(), submodel.getId(), submodelElement.getIdShort()), listener.lastTopic); | ||||||
assertEquals(submodelElement, deserializeSubmodelElementPayload(listener.lastPayload)); | ||||||
} | ||||||
|
@@ -138,10 +139,11 @@ public void updateSubmodelElementEvent() throws DeserializationException { | |||||
Submodel submodel = createSubmodelDummy("updateSubmodelForElementEventId"); | ||||||
submodelRepository.createSubmodel(submodel); | ||||||
SubmodelElement submodelElement = createSubmodelElementDummy("updateSubmodelElementEventId"); | ||||||
submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
SubmodelElement responseSubmodelElement = submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
SubmodelElementValue value = new PropertyValue("updatedValue"); | ||||||
submodelRepository.setSubmodelElementValue(submodel.getId(), submodelElement.getIdShort(), value); | ||||||
|
||||||
assertEquals(responseSubmodelElement, submodelElement); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above, and please move this state to line 143. |
||||||
assertEquals(topicFactory.createUpdateSubmodelElementTopic(submodelRepository.getName(), submodel.getId(), submodelElement.getIdShort()), listener.lastTopic); | ||||||
assertEquals(submodelElement, deserializeSubmodelElementPayload(listener.lastPayload)); | ||||||
} | ||||||
|
@@ -151,9 +153,10 @@ public void deleteSubmodelElementEvent() throws DeserializationException { | |||||
Submodel submodel = createSubmodelDummy("deleteSubmodelForElementEventId"); | ||||||
submodelRepository.createSubmodel(submodel); | ||||||
SubmodelElement submodelElement = createSubmodelElementDummy("deleteSubmodelElementEventId"); | ||||||
submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
SubmodelElement responseSubmodelElement = submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
submodelRepository.deleteSubmodelElement(submodel.getId(), submodelElement.getIdShort()); | ||||||
|
||||||
assertEquals(responseSubmodelElement, submodelElement); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above |
||||||
assertEquals(topicFactory.createDeleteSubmodelElementTopic(submodelRepository.getName(), submodel.getId(), submodelElement.getIdShort()), listener.lastTopic); | ||||||
assertEquals(submodelElement, deserializeSubmodelElementPayload(listener.lastPayload)); | ||||||
} | ||||||
|
@@ -165,8 +168,9 @@ public void createSubmodelElementWithoutValueEvent() throws DeserializationExcep | |||||
SubmodelElement submodelElement = createSubmodelElementDummy("noValueSubmodelElementEventId"); | ||||||
List<Qualifier> qualifierList = createNoValueQualifierList(); | ||||||
submodelElement.setQualifiers(qualifierList); | ||||||
submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
SubmodelElement responseSubmodelElement = submodelRepository.createSubmodelElement(submodel.getId(), submodelElement); | ||||||
|
||||||
assertEquals(responseSubmodelElement, submodelElement); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||||||
assertEquals(topicFactory.createCreateSubmodelElementTopic(submodelRepository.getName(), submodel.getId(), submodelElement.getIdShort()), listener.lastTopic); | ||||||
assertNotEquals(submodelElement, deserializeSubmodelElementPayload(listener.lastPayload)); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,19 +103,21 @@ public void setSubmodelElementValue(String idShortPath, SubmodelElementValue val | |
} | ||
|
||
@Override | ||
public void createSubmodelElement(SubmodelElement submodelElement) { | ||
public SubmodelElement createSubmodelElement(SubmodelElement submodelElement) { | ||
InMemorySubmodelService inMemorySubmodelService = getInMemorySubmodelService(); | ||
inMemorySubmodelService.createSubmodelElement(submodelElement); | ||
Submodel submodel = inMemorySubmodelService.getSubmodel(); | ||
crudRepository.save(submodel); | ||
return submodelElement; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the returned SME from line 108 and not return the SME received as a parameter. |
||
} | ||
|
||
@Override | ||
public void createSubmodelElement(String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { | ||
public SubmodelElement createSubmodelElement(String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { | ||
InMemorySubmodelService inMemorySubmodelService = getInMemorySubmodelService(); | ||
inMemorySubmodelService.createSubmodelElement(idShortPath, submodelElement); | ||
Submodel submodel = inMemorySubmodelService.getSubmodel(); | ||
crudRepository.save(submodel); | ||
return submodelElement; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
|
||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -718,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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you please explain the need of this? Because I can't find any reference to this private method in this class. |
||
return new DefaultProperty.Builder().idShort(idShort).value("123").build(); | ||
} | ||
|
||
private InputStream getInputStreamOfDummyFile(String fileContent) throws FileNotFoundException, IOException { | ||
return new ByteArrayInputStream(fileContent.getBytes()); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,19 +93,21 @@ public void setSubmodelElementValue(String idShortPath, SubmodelElementValue val | |
} | ||
|
||
@Override | ||
public void createSubmodelElement(SubmodelElement submodelElement) { | ||
public SubmodelElement createSubmodelElement(SubmodelElement submodelElement) { | ||
decorated.createSubmodelElement(submodelElement); | ||
SubmodelElement smElement = decorated.getSubmodelElement(submodelElement.getIdShort()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can get rid of this method and use the returned SME from line 97 |
||
submodelElementCreated(submodelElement, smElement.getIdShort()); | ||
return smElement; | ||
} | ||
|
||
@Override | ||
public void createSubmodelElement(String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { | ||
public SubmodelElement createSubmodelElement(String idShortPath, SubmodelElement submodelElement) throws ElementDoesNotExistException { | ||
|
||
decorated.createSubmodelElement(idShortPath, submodelElement); | ||
|
||
SubmodelElement smElement = decorated.getSubmodelElement(submodelElement.getIdShort()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above. |
||
submodelElementCreated(smElement, idShortPath); | ||
return smElement; | ||
} | ||
|
||
@Override | ||
|
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.