-
Notifications
You must be signed in to change notification settings - Fork 1
refactor: move modificationUuids from ProcessConfig to ModifyingProcessConfig interface #43
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
Changes from all commits
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 |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /** | ||
| * Copyright (c) 2026, RTE (http://www.rte-france.com) | ||
| * This Source Code Form is subject to the terms of the Mozilla Public | ||
| * License, v. 2.0. If a copy of the MPL was not distributed with this | ||
| * file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
| */ | ||
| package org.gridsuite.monitor.commons; | ||
|
|
||
| import java.util.List; | ||
| import java.util.UUID; | ||
|
|
||
| /** | ||
| * @author Kamil MARUT {@literal <kamil.marut at rte-france.com>} | ||
| */ | ||
| public interface ModifyingProcessConfig extends ProcessConfig { | ||
|
|
||
| List<UUID> modificationUuids(); | ||
|
|
||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -13,7 +13,7 @@ | |||||||||||||||||||
| import org.gridsuite.modification.dto.LoadModificationInfos; | ||||||||||||||||||||
| import org.gridsuite.modification.dto.ModificationInfos; | ||||||||||||||||||||
| import org.gridsuite.modification.dto.OperationType; | ||||||||||||||||||||
| import org.gridsuite.monitor.commons.ProcessConfig; | ||||||||||||||||||||
| import org.gridsuite.monitor.commons.ModifyingProcessConfig; | ||||||||||||||||||||
| import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext; | ||||||||||||||||||||
| import org.gridsuite.monitor.worker.server.dto.ReportInfos; | ||||||||||||||||||||
| import org.gridsuite.monitor.worker.server.services.*; | ||||||||||||||||||||
|
|
@@ -27,6 +27,7 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| import java.io.IOException; | ||||||||||||||||||||
| import java.nio.file.Path; | ||||||||||||||||||||
| import java.util.Collections; | ||||||||||||||||||||
| import java.util.List; | ||||||||||||||||||||
| import java.util.UUID; | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -54,30 +55,27 @@ class ApplyModificationsStepTest { | |||||||||||||||||||
| private S3Service s3Service; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Mock | ||||||||||||||||||||
| private ProcessConfig config; | ||||||||||||||||||||
| private ModifyingProcessConfig config; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private ApplyModificationsStep<ProcessConfig> applyModificationsStep; | ||||||||||||||||||||
| private ApplyModificationsStep<ModifyingProcessConfig> applyModificationsStep; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Mock | ||||||||||||||||||||
| private ProcessStepExecutionContext<ProcessConfig> stepContext; | ||||||||||||||||||||
| private ProcessStepExecutionContext<ModifyingProcessConfig> stepContext; | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private static final UUID MODIFICATION_UUID = UUID.randomUUID(); | ||||||||||||||||||||
| private static final UUID REPORT_UUID = UUID.randomUUID(); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @BeforeEach | ||||||||||||||||||||
| void setUp() { | ||||||||||||||||||||
| applyModificationsStep = new ApplyModificationsStep<>(networkModificationService, networkModificationRestService, s3Service, filterService); | ||||||||||||||||||||
| when(config.modificationUuids()).thenReturn(List.of(MODIFICATION_UUID)); | ||||||||||||||||||||
| when(stepContext.getConfig()).thenReturn(config); | ||||||||||||||||||||
| ReportInfos reportInfos = new ReportInfos(REPORT_UUID, ReportNode.newRootReportNode() | ||||||||||||||||||||
| .withResourceBundles("i18n.reports") | ||||||||||||||||||||
| .withMessageTemplate("test") | ||||||||||||||||||||
| .build()); | ||||||||||||||||||||
| when(stepContext.getReportInfos()).thenReturn(reportInfos); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| applyModificationsStep = new ApplyModificationsStep<>(networkModificationService, networkModificationRestService, s3Service, filterService); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| void executeApplyModifications() { | ||||||||||||||||||||
| void executeApplyModificationsWhenModificationUuidsNotEmpty() { | ||||||||||||||||||||
| setUpReportInfos(); | ||||||||||||||||||||
| when(config.modificationUuids()).thenReturn(List.of(MODIFICATION_UUID)); | ||||||||||||||||||||
| String stepType = applyModificationsStep.getType().getName(); | ||||||||||||||||||||
| assertEquals("APPLY_MODIFICATIONS", stepType); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -93,8 +91,22 @@ void executeApplyModifications() { | |||||||||||||||||||
| verify(networkModificationService).applyModifications(any(Network.class), any(List.class), any(ReportNode.class), any(FilterService.class)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| void executeDoesNothingWhenModificationUuidsEmpty() { | ||||||||||||||||||||
| when(config.modificationUuids()).thenReturn(Collections.emptyList()); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| applyModificationsStep.execute(stepContext); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| verifyNoInteractions(networkModificationService); | ||||||||||||||||||||
| verifyNoInteractions(networkModificationRestService); | ||||||||||||||||||||
| verifyNoInteractions(filterService); | ||||||||||||||||||||
| verifyNoInteractions(s3Service); | ||||||||||||||||||||
| } | ||||||||||||||||||||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+100
to
+104
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.
The test says “does nothing”, but it currently does not guard Suggested patch verifyNoInteractions(networkModificationService);
verifyNoInteractions(networkModificationRestService);
verifyNoInteractions(filterService);
+ verifyNoInteractions(s3Service);📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||
|
|
||||||||||||||||||||
| @Test | ||||||||||||||||||||
| void executeApplyModificationsDebugOn() throws IOException { | ||||||||||||||||||||
| setUpReportInfos(); | ||||||||||||||||||||
| when(config.modificationUuids()).thenReturn(List.of(MODIFICATION_UUID)); | ||||||||||||||||||||
| String stepType = applyModificationsStep.getType().getName(); | ||||||||||||||||||||
| assertEquals("APPLY_MODIFICATIONS", stepType); | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
@@ -135,4 +147,12 @@ void executeApplyModificationsDebugOn() throws IOException { | |||||||||||||||||||
|
|
||||||||||||||||||||
| verify(network).write("XIIDM", null, mockedPath); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| private void setUpReportInfos() { | ||||||||||||||||||||
| ReportInfos reportInfos = new ReportInfos(REPORT_UUID, ReportNode.newRootReportNode() | ||||||||||||||||||||
| .withResourceBundles("i18n.reports") | ||||||||||||||||||||
| .withMessageTemplate("test") | ||||||||||||||||||||
| .build()); | ||||||||||||||||||||
| when(stepContext.getReportInfos()).thenReturn(reportInfos); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
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.
Missing license
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.
Added