Repository navigation
unsharing of all the references in a study #1145
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
Merged
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
cf98b2f
unsharing of all the references in a study
Mathieu-Deharbe 25d5ad6
Merge branch 'main' into unshare-study
Mathieu-Deharbe e7d6cc8
improvements
Mathieu-Deharbe e689eaa
activity handling
Mathieu-Deharbe bb6849d
activity handling
Mathieu-Deharbe 440cad0
Merge branch 'main' into unshare-study
Mathieu-Deharbe 0a7b8c4
corrects TUs
Mathieu-Deharbe 8ddcc25
Merge remote-tracking branch 'origin/unshare-study' into unshare-study
Mathieu-Deharbe 9192c8f
more TUs
Mathieu-Deharbe 21586c4
sonar
Mathieu-Deharbe d225625
Merge branch 'main' into unshare-study
Mathieu-Deharbe ef18bf5
post merge conflicts / refactos
Mathieu-Deharbe 4a1e592
cleaning
Mathieu-Deharbe 788fa04
ignore read only nodes
Mathieu-Deharbe 3422e4f
various
Mathieu-Deharbe 37c3a7e
various cleanings
Mathieu-Deharbe 82104f2
Maissa patch (quite)
Mathieu-Deharbe 5f027d3
Maissa patch (Arename unshareAllModificationReferencesquite)
Mathieu-Deharbe 526e9b3
Merge branch 'main' into unshare-study
souissimai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,13 +7,15 @@ | |
| package org.gridsuite.study.server; | ||
|
|
||
| import org.gridsuite.study.server.dto.ComputationType; | ||
| import org.gridsuite.study.server.dto.ModificationReference; | ||
| import org.gridsuite.study.server.dto.QuotaState; | ||
| import org.gridsuite.study.server.dto.QuotaType; | ||
| import org.gridsuite.study.server.error.StudyException; | ||
| import org.gridsuite.study.server.networkmodificationtree.dto.BuildStatus; | ||
| import org.gridsuite.study.server.networkmodificationtree.dto.NodeBuildStatus; | ||
| import org.gridsuite.study.server.networkmodificationtree.entities.NodeEntity; | ||
| import org.gridsuite.study.server.networkmodificationtree.entities.NodeType; | ||
| import org.gridsuite.study.server.nodeactivity.NodeActivityRunnerService; | ||
| import org.gridsuite.study.server.notification.NotificationService; | ||
| import org.gridsuite.study.server.repository.networkmodificationtree.NodeRepository; | ||
| import org.gridsuite.study.server.service.NetworkModificationTreeService; | ||
|
|
@@ -33,10 +35,10 @@ | |
|
|
||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.UUID; | ||
|
|
||
| import static org.gridsuite.study.server.error.StudyBusinessErrorCode.MAX_OPERATION_TYPE_EXCEEDED; | ||
| import static org.gridsuite.study.server.nodeactivity.NodeActivityType.UNSHARE_MODIFICATIONS; | ||
| import static org.junit.jupiter.api.Assertions.*; | ||
| import static org.mockito.ArgumentMatchers.isNull; | ||
| import static org.mockito.Mockito.*; | ||
|
|
@@ -61,6 +63,8 @@ | |
| private NotificationService notificationService; | ||
| @MockitoBean | ||
| private RootNetworkService rootNetworkService; | ||
| @MockitoBean | ||
| private NodeActivityRunnerService nodeActivityRunnerService; | ||
|
|
||
| @AfterEach | ||
| void resetOperationQuotasFlag() { | ||
|
|
@@ -278,11 +282,67 @@ | |
| UUID modificationUuid = UUID.randomUUID(); | ||
| String userId = "userId"; | ||
|
|
||
| networkModificationService.unshareModificationReference(studyUuid, nodeUuid, modificationUuid, userId); | ||
| networkModificationService.unshareModificationReferences(studyUuid, Map.of(nodeUuid, List.of(modificationUuid)), userId); | ||
|
|
||
| // the reference is replaced remotely by a copy of the shared composite, then the front is notified | ||
| verify(networkModificationRestService, times(1)).unshareModificationReference(modificationUuid, userId); | ||
| verify(notificationService, times(1)).emitModificationsUpdated(studyUuid, nodeUuid, Optional.empty(), List.of(modificationUuid)); | ||
| verify(networkModificationRestService, times(1)).unshareModificationReferences(List.of(modificationUuid), userId); | ||
| verify(notificationService, times(1)).emitModificationsUpdated(studyUuid, nodeUuid, List.of(modificationUuid)); | ||
| } | ||
|
|
||
| @Test | ||
| void testUnshareAllReferencesInStudy() { | ||
| UUID studyUuid = UUID.randomUUID(); | ||
| String userId = "userId"; | ||
|
|
||
| doReturn(List.of()).when(networkModificationTreeService).getAllNotStashedNetworkModificationNodes(studyUuid); | ||
|
|
||
| networkModificationService.unshareAllReferencesInStudy(studyUuid, userId); | ||
|
|
||
| verify(networkModificationTreeService, times(1)).getAllNotStashedNetworkModificationNodes(studyUuid); | ||
| verify(nodeActivityRunnerService, never()).runWith(any(), any(), any(), (Runnable) any()); | ||
| verify(networkModificationRestService, never()).unshareModificationReferences(any(), any()); | ||
| verify(notificationService, never()).emitModificationsUpdated(any(), any(), any()); | ||
| } | ||
|
|
||
| @Test | ||
| void testUnshareAllReferencesInStudyWithReferences() { | ||
| UUID studyUuid = UUID.randomUUID(); | ||
| UUID nodeUuid = UUID.randomUUID(); | ||
| UUID modificationUuid = UUID.randomUUID(); | ||
| String userId = "userId"; | ||
|
|
||
| UUID nodeWithoutReferenceUuid = UUID.randomUUID(); | ||
| doReturn(List.of( | ||
| new NodeEntity(nodeUuid, null, NodeType.NETWORK_MODIFICATION, null, false, null, List.of()), | ||
| new NodeEntity(nodeWithoutReferenceUuid, null, NodeType.NETWORK_MODIFICATION, null, false, null, List.of()) | ||
| )).when(networkModificationTreeService).getAllNotStashedNetworkModificationNodes(studyUuid); | ||
|
|
||
| UUID groupUuid = UUID.randomUUID(); | ||
| doReturn(groupUuid).when(networkModificationTreeService).getModificationGroupUuid(nodeUuid); | ||
| UUID groupWithoutReferenceUuid = UUID.randomUUID(); | ||
| doReturn(groupWithoutReferenceUuid).when(networkModificationTreeService).getModificationGroupUuid(nodeWithoutReferenceUuid); | ||
| doReturn(List.of()).when(networkModificationRestService).getModificationReferences(groupWithoutReferenceUuid); | ||
|
|
||
| ModificationReference modificationReference = new ModificationReference(modificationUuid, UUID.randomUUID(), null); | ||
| doReturn(List.of(modificationReference)).when(networkModificationRestService).getModificationReferences(groupUuid); | ||
|
|
||
| // Mock nodeActivityRunnerService to bypass database checks | ||
| doAnswer(invocation -> { | ||
| Runnable runnable = invocation.getArgument(3); | ||
| runnable.run(); | ||
| return null; | ||
| }).when(nodeActivityRunnerService).runWith(any(), any(), any(), (Runnable) any()); | ||
|
|
||
| networkModificationService.unshareAllReferencesInStudy(studyUuid, userId); | ||
|
|
||
| verify(networkModificationTreeService, times(1)).getAllNotStashedNetworkModificationNodes(studyUuid); | ||
| verify(networkModificationTreeService, times(1)).getModificationGroupUuid(nodeUuid); | ||
| verify(networkModificationRestService, times(1)).getModificationReferences(groupUuid); | ||
| // only the node having references is held by the activity | ||
| verify(nodeActivityRunnerService, times(1)).runWith(eq(UNSHARE_MODIFICATIONS), eq(studyUuid), eq(List.of(nodeUuid)), (Runnable) any()); | ||
| verify(networkModificationRestService, times(1)).unshareModificationReferences(List.of(modificationUuid), userId); | ||
| verify(notificationService, times(1)).emitModificationsUpdated(studyUuid, nodeUuid, List.of(modificationUuid)); | ||
| verify(notificationService, never()).emitModificationsUpdated(eq(studyUuid), eq(nodeWithoutReferenceUuid), any()); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -293,12 +353,11 @@ | |
| String userId = "userId"; | ||
|
|
||
| doThrow(new RuntimeException("network modification server error")) | ||
| .when(networkModificationRestService).unshareModificationReference(modificationUuid, userId); | ||
| .when(networkModificationRestService).unshareModificationReferences(List.of(modificationUuid), userId); | ||
|
|
||
| assertThrows(RuntimeException.class, | ||
|
Check warning on line 358 in src/test/java/org/gridsuite/study/server/StudyServiceTest.java
|
||
|
Contributor
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. issue |
||
| () -> networkModificationService.unshareModificationReference(studyUuid, nodeUuid, modificationUuid, userId)); | ||
| () -> networkModificationService.unshareModificationReferences(studyUuid, Map.of(nodeUuid, List.of(modificationUuid)), userId)); | ||
|
|
||
| verify(notificationService, never()).emitModificationsUpdated(any(), any(), any(), any()); | ||
| verify(notificationService, never()).emitModificationsUpdated(any(), any(), any()); | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.