Skip to content

Commit

Permalink
add UT
Browse files Browse the repository at this point in the history
Signed-off-by: Godelaine de Montmorillon <godelaine.demontmorillon@rte-france.com>
  • Loading branch information
Godelaine committed Dec 17, 2024
1 parent ece6c70 commit 43c67ba
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public SystematicSensitivityResult completeDataWithFailingPerimeter(int instantO
this.status = SensitivityComputationStatus.PARTIAL_FAILURE;
StateResult contingencyStateResult = new StateResult();
contingencyStateResult.status = SensitivityComputationStatus.FAILURE;
postContingencyResults.putIfAbsent(instantOrder, new HashMap<>());
postContingencyResults.get(instantOrder).put(contingencyId, contingencyStateResult);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,20 @@
*/
@AutoService(SensitivityAnalysisProvider.class)
public final class MockSensiProvider implements SensitivityAnalysisProvider {
int counter = 0;

@Override
public CompletableFuture<Void> run(Network network, String s, SensitivityFactorReader sensitivityFactorReader, SensitivityResultWriter sensitivityResultWriter, List<Contingency> contingencies, List<SensitivityVariableSet> glsks, SensitivityAnalysisParameters sensitivityAnalysisParameters, ComputationManager computationManager, ReportNode reportNode) {
return CompletableFuture.runAsync(() -> {
if (network.getNameOrId().equals("Mock_Exception")) {
throw new OpenRaoException("Mocked exception");
}
if (network.getNameOrId().equals("Second_Run_Exception")) {
counter++;
if (counter == 2) {
throw new OpenRaoException("Mocked exception on second round");
}
}
TwoWindingsTransformer pst = network.getTwoWindingsTransformer("BBE2AA1 BBE3AA1 1");
if (pst == null || pst.getPhaseTapChanger().getTapPosition() == 0) {
// used for most of the tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void testCatchInRunSensitivity() {
@Test
void testCatchInRunSensitivityWithAppliedRa() {
Network network = NetworkImportsUtil.import12NodesNetwork();
network.setName("Mock_Exception");
network.setName("Second_Run_Exception");
Crac crac = CommonCracCreation.createWithPreventivePstRange(Set.of(ONE, TWO));
Instant curativeInstant = crac.getInstant(CURATIVE_INSTANT_ID);
crac.newFlowCnec()
Expand All @@ -199,6 +199,6 @@ void testCatchInRunSensitivityWithAppliedRa() {
appliedRemedialActions.addAppliedRangeAction(crac.getState("Contingency FR1 FR3", curativeInstant), crac.getPstRangeAction("pst"), -3.1);

SystematicSensitivityResult result = SystematicSensitivityAdapter.runSensitivity(network, factorProvider, appliedRemedialActions, new SensitivityAnalysisParameters(), "MockSensi", crac.getOutageInstant());
assertEquals(SystematicSensitivityResult.SensitivityComputationStatus.FAILURE, result.getStatus());
assertEquals(SystematicSensitivityResult.SensitivityComputationStatus.PARTIAL_FAILURE, result.getStatus());
}
}

0 comments on commit 43c67ba

Please sign in to comment.