Skip to content

Commit

Permalink
fix a copy-paste issue on a dead element
Browse files Browse the repository at this point in the history
  • Loading branch information
dbraquart committed Feb 22, 2024
1 parent 3b9d35a commit 6fe2244
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,12 @@ public void createNetworkModifications(List<ElementAttributes> modificationAttri
// create all corresponding directory elements
modificationAttributesList.forEach(m -> {
final UUID newId = newModificationsUuids.get(m.getElementUuid());
ElementAttributes elementAttributes = new ElementAttributes(newId, m.getElementName(), MODIFICATION,
null, userId, 0L, m.getDescription());
directoryService.createElementWithNewName(elementAttributes, parentDirectoryUuid, userId, true);
if (newId != null) {
// an Id may be null if a duplication could not succeed (ex: we provide a bad uuid)
ElementAttributes elementAttributes = new ElementAttributes(newId, m.getElementName(), MODIFICATION,
null, userId, 0L, m.getDescription());
directoryService.createElementWithNewName(elementAttributes, parentDirectoryUuid, userId, true);
}
});
}
}
6 changes: 5 additions & 1 deletion src/test/java/org/gridsuite/explore/server/ExploreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,11 @@ public void testGetMetadata() throws Exception {
@Test
@SneakyThrows
public void testcreateNetworkModifications() {
final String body = mapper.writeValueAsString(List.of(new ElementAttributes(MODIFICATION_UUID, "one modif", "", null, USER1, 0L, "a description")));
final String body = mapper.writeValueAsString(List.of(
new ElementAttributes(MODIFICATION_UUID, "one modif", "", null, USER1, 0L, "a description"),
new ElementAttributes(UUID.randomUUID(), "2nd modif", "", null, USER1, 0L, "a description")
)
);
mockMvc.perform(post("/v1/explore/modifications?parentDirectoryUuid={parentDirectoryUuid}", PARENT_DIRECTORY_UUID)
.header("userId", USER1)
.contentType(MediaType.APPLICATION_JSON)
Expand Down

0 comments on commit 6fe2244

Please sign in to comment.