From 7deb9fb8f8ff9097f470e8e2e7f07f1c1c386023 Mon Sep 17 00:00:00 2001 From: Maissa SOUISSI Date: Wed, 6 Sep 2023 14:29:18 +0200 Subject: [PATCH 1/3] copy node and duplicate not stashed modifications Signed-off-by: Maissa SOUISSI --- .../server/repositories/NetworkModificationRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java b/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java index eb2f06e16..da481c520 100644 --- a/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java +++ b/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java @@ -206,7 +206,7 @@ public List getModificationsEntities(@NonNull List uui @Transactional(readOnly = true) public List copyModificationsEntities(@NonNull UUID groupUuid) { - return getModificationEntityStream(groupUuid).map(ModificationEntity::copy).collect(Collectors.toList()); + return getModificationEntityStream(groupUuid).filter(m -> !m.getStashed()).map(ModificationEntity::copy).collect(Collectors.toList()); } @Transactional From 66cbe6e521a95c503df71af4270b7c23e7cf2ab1 Mon Sep 17 00:00:00 2001 From: Maissa SOUISSI Date: Wed, 6 Sep 2023 16:46:35 +0200 Subject: [PATCH 2/3] test duplicate modifications Group with stashed modif Signed-off-by: Maissa SOUISSI --- .../NetworkModificationRepository.java | 2 +- .../server/ModificationControllerTest.java | 24 ++++++++++++++++--- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java b/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java index da481c520..f64ce4575 100644 --- a/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java +++ b/src/main/java/org/gridsuite/modification/server/repositories/NetworkModificationRepository.java @@ -128,7 +128,7 @@ public List getModifications(UUID groupUuid, boolean onlyMeta } } - private List getModificationsMetadata(UUID groupUuid, boolean stashedModifications) { + public List getModificationsMetadata(UUID groupUuid, boolean stashedModifications) { return modificationRepository .findAllBaseByGroupId(getModificationGroup(groupUuid).getId()) .stream() diff --git a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java index c982ae761..30eb0d3c8 100644 --- a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java +++ b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java @@ -756,12 +756,30 @@ public void testDuplicateModificationGroup() throws Exception { assertApplicationStatusOK(mvcResult); testNetworkModificationsCount(TEST_GROUP_ID, 5); - //test copy group + // get list of modifications + List modifications = modificationRepository.getModifications(TEST_GROUP_ID, true, true, false); + assertEquals(5, modifications.size()); + //stash the first modification + String uuidString = modifications.get(0).getUuid().toString(); + + mockMvc.perform(post(URI_NETWORK_MODIF_BASE + "/stash") + .queryParam("groupUuid", TEST_GROUP_ID.toString()) + .queryParam("uuids", uuidString)) + .andExpect(status().isOk()); + List stashedModifications = modificationRepository.getModificationsMetadata(TEST_GROUP_ID,true); + List modificationAfterStash = modificationRepository.getModificationsMetadata(TEST_GROUP_ID,false); + assertEquals(1, stashedModifications.size()); + assertEquals(4, modificationAfterStash.size()); + + //test copy group with stashed modification UUID newGroupUuid = UUID.randomUUID(); String uriStringGroups = "/v1/groups?groupUuid=" + newGroupUuid + "&duplicateFrom=" + TEST_GROUP_ID + "&reportUuid=" + UUID.randomUUID(); mockMvc.perform(post(uriStringGroups)).andExpect(status().isOk()); - - testNetworkModificationsCount(newGroupUuid, 5); + List stashedCopiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid,true); + List copiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid,false); + assertEquals(0, stashedCopiedModifications.size()); + assertEquals(4, copiedModifications.size()); + testNetworkModificationsCount(newGroupUuid, 4); } @Test From 2083718edbeb81d31f15ef04afa741fc8fc3ec9e Mon Sep 17 00:00:00 2001 From: Maissa SOUISSI Date: Thu, 7 Sep 2023 09:27:39 +0200 Subject: [PATCH 3/3] fix prettiers Signed-off-by: Maissa SOUISSI --- .../modification/server/ModificationControllerTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java index 30eb0d3c8..1e800d2c8 100644 --- a/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java +++ b/src/test/java/org/gridsuite/modification/server/ModificationControllerTest.java @@ -766,8 +766,8 @@ public void testDuplicateModificationGroup() throws Exception { .queryParam("groupUuid", TEST_GROUP_ID.toString()) .queryParam("uuids", uuidString)) .andExpect(status().isOk()); - List stashedModifications = modificationRepository.getModificationsMetadata(TEST_GROUP_ID,true); - List modificationAfterStash = modificationRepository.getModificationsMetadata(TEST_GROUP_ID,false); + List stashedModifications = modificationRepository.getModificationsMetadata(TEST_GROUP_ID, true); + List modificationAfterStash = modificationRepository.getModificationsMetadata(TEST_GROUP_ID, false); assertEquals(1, stashedModifications.size()); assertEquals(4, modificationAfterStash.size()); @@ -775,8 +775,8 @@ public void testDuplicateModificationGroup() throws Exception { UUID newGroupUuid = UUID.randomUUID(); String uriStringGroups = "/v1/groups?groupUuid=" + newGroupUuid + "&duplicateFrom=" + TEST_GROUP_ID + "&reportUuid=" + UUID.randomUUID(); mockMvc.perform(post(uriStringGroups)).andExpect(status().isOk()); - List stashedCopiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid,true); - List copiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid,false); + List stashedCopiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid, true); + List copiedModifications = modificationRepository.getModificationsMetadata(newGroupUuid, false); assertEquals(0, stashedCopiedModifications.size()); assertEquals(4, copiedModifications.size()); testNetworkModificationsCount(newGroupUuid, 4);