Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing license

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added


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
Expand Up @@ -9,9 +9,6 @@
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

import java.util.List;
import java.util.UUID;

/**
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
*/
Expand All @@ -25,5 +22,4 @@
public interface ProcessConfig {
ProcessType processType();

List<UUID> modificationUuids();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public record SecurityAnalysisConfig(
UUID parametersUuid,
List<String> contingencies,
List<UUID> modificationUuids
) implements ProcessConfig {
) implements ModifyingProcessConfig {

@Override
public ProcessType processType() {
return ProcessType.SECURITY_ANALYSIS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import com.powsybl.iidm.network.Network;
import org.apache.commons.collections4.CollectionUtils;
import org.gridsuite.modification.dto.ModificationInfos;
import org.gridsuite.monitor.commons.ProcessConfig;
import org.gridsuite.monitor.commons.ModifyingProcessConfig;
import org.gridsuite.monitor.worker.server.core.AbstractProcessStep;
import org.gridsuite.monitor.worker.server.core.ProcessStepExecutionContext;
import org.gridsuite.monitor.worker.server.services.*;
Expand All @@ -29,7 +29,7 @@
* @author Antoine Bouhours <antoine.bouhours at rte-france.com>
*/
@Component
public class ApplyModificationsStep<C extends ProcessConfig> extends AbstractProcessStep<C> {
public class ApplyModificationsStep<C extends ModifyingProcessConfig> extends AbstractProcessStep<C> {

private final NetworkModificationService networkModificationService;
private final NetworkModificationRestService networkModificationRestService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.*;
Expand All @@ -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;

Expand Down Expand Up @@ -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);

Expand All @@ -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);
}
Comment on lines +100 to +104
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

executeDoesNothingWhenModificationUuidsEmpty should also assert no S3 side effects.

The test says “does nothing”, but it currently does not guard s3Service. Add a no-interaction assertion to fully lock the contract.

Suggested patch
         verifyNoInteractions(networkModificationService);
         verifyNoInteractions(networkModificationRestService);
         verifyNoInteractions(filterService);
+        verifyNoInteractions(s3Service);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
verifyNoInteractions(networkModificationService);
verifyNoInteractions(networkModificationRestService);
verifyNoInteractions(filterService);
}
verifyNoInteractions(networkModificationService);
verifyNoInteractions(networkModificationRestService);
verifyNoInteractions(filterService);
verifyNoInteractions(s3Service);
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@monitor-worker-server/src/test/java/org/gridsuite/monitor/worker/server/processes/commons/steps/ApplyModificationsStepTest.java`
around lines 100 - 103, The test executeDoesNothingWhenModificationUuidsEmpty is
missing an assertion that S3 is untouched; add a no-interaction verification for
the s3Service mock (e.g., verifyNoInteractions(s3Service) or equivalent)
alongside the existing verifyNoInteractions(networkModificationService),
verifyNoInteractions(networkModificationRestService), and
verifyNoInteractions(filterService) to ensure the test fully asserts there are
no S3 side effects.


@Test
void executeApplyModificationsDebugOn() throws IOException {
setUpReportInfos();
when(config.modificationUuids()).thenReturn(List.of(MODIFICATION_UUID));
String stepType = applyModificationsStep.getType().getName();
assertEquals("APPLY_MODIFICATIONS", stepType);

Expand Down Expand Up @@ -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);
}
}