Skip to content

Commit

Permalink
Fix logs for scaling modification (#328)
Browse files Browse the repository at this point in the history
*Fix logs for scaling modification
---------

Signed-off-by: Maissa SOUISSI <[email protected]>
  • Loading branch information
souissimai authored Sep 14, 2023
1 parent 755fc4b commit 68f6a21
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,16 @@ public void apply(Network network, Reporter subReporter) {
.allMatch(filterEquipments -> filterEquipments.getIdentifiableAttributes().isEmpty());

if (noValidEquipmentId) {
String errorMsg = "There is no valid equipment ID among the provided filter(s)";
String errorMsg = scalingInfos.getErrorType() + ": There is no valid equipment ID among the provided filter(s)";
createReport(subReporter, "invalidFilters", errorMsg, TypedValue.ERROR_SEVERITY);
throw new NetworkModificationException(scalingInfos.getErrorType(), errorMsg);
return;
}

// create report for each wrong filter
filterWithWrongEquipmentsIds.values().forEach(f -> {
var equipmentIds = String.join(", ", f.getNotFoundEquipments());

createReport(subReporter,
"filterEquipmentsNotFound",
"filterEquipmentsNotFound_" + f.getFilterName(),
String.format("Cannot find the following equipments %s in filter %s", equipmentIds, filters.get(f.getFilterId())),
TypedValue.WARN_SEVERITY);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.powsybl.iidm.network.IdentifiableType;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import org.gridsuite.modification.server.NetworkModificationException;
import org.gridsuite.modification.server.VariationMode;
import org.gridsuite.modification.server.VariationType;
import org.gridsuite.modification.server.dto.*;
Expand All @@ -30,7 +29,6 @@
import java.util.UUID;
import java.util.stream.Collectors;

import static org.gridsuite.modification.server.NetworkModificationException.Type.GENERATOR_SCALING_ERROR;
import static org.gridsuite.modification.server.utils.NetworkUtil.createGenerator;
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -206,8 +204,8 @@ public void testFilterWithWrongIds() throws Exception {

mockMvc.perform(post(getNetworkModificationUri()).content(mapper.writeValueAsString(generatorScalingInfo)).contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
assertLogMessage(new NetworkModificationException(GENERATOR_SCALING_ERROR, "There is no valid equipment ID among the provided filter(s)").getMessage(),
generatorScalingInfo.getErrorType().name(), reportService);
assertLogMessage(generatorScalingInfo.getErrorType().name() + ": There is no valid equipment ID among the provided filter(s)",
"invalidFilters", reportService);
wireMockUtils.verifyGetRequest(subWrongId, PATH, handleQueryParams(getNetworkUuid(), FILTER_WRONG_ID_1), false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import com.powsybl.iidm.network.IdentifiableType;
import com.powsybl.iidm.network.Network;
import com.powsybl.iidm.network.extensions.ConnectablePosition;
import org.gridsuite.modification.server.NetworkModificationException;
import org.gridsuite.modification.server.ReactiveVariationMode;
import org.gridsuite.modification.server.VariationMode;
import org.gridsuite.modification.server.VariationType;
Expand All @@ -32,7 +31,6 @@
import java.util.UUID;
import java.util.stream.Collectors;

import static org.gridsuite.modification.server.NetworkModificationException.Type.LOAD_SCALING_ERROR;
import static org.gridsuite.modification.server.utils.NetworkUtil.createLoad;
import static org.gridsuite.modification.server.utils.TestUtils.assertLogMessage;
import static org.junit.Assert.assertEquals;
Expand Down Expand Up @@ -225,8 +223,8 @@ public void testFilterWithWrongIds() throws Exception {
.content(mapper.writeValueAsString(loadScalingInfo))
.contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk());
assertLogMessage(new NetworkModificationException(LOAD_SCALING_ERROR, "There is no valid equipment ID among the provided filter(s)").getMessage(),
loadScalingInfo.getErrorType().name(), reportService);
assertLogMessage(loadScalingInfo.getErrorType().name() + ": There is no valid equipment ID among the provided filter(s)",
"invalidFilters", reportService);
wireMockUtils.verifyGetRequest(stubWithWrongId, PATH, handleQueryParams(getNetworkUuid(), FILTER_WRONG_ID_1), false);
}

Expand Down

0 comments on commit 68f6a21

Please sign in to comment.