Skip to content

Commit

Permalink
Add unit test to cover bug
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Bouquet <thomas.bouquet@rte-france.com>
  • Loading branch information
bqth29 committed Apr 29, 2024
1 parent 993a2e5 commit 2397f81
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,31 @@ void testStrongestStateAndInstantUsageRule() {
AbstractRemedialAction<?> ra = new NetworkActionImpl("id", "name", "operator", usageRules, Collections.emptySet(), 0);
assertEquals(UsageMethod.FORCED, ra.getUsageMethod(state));
}

@Test
void testDifferentInstantsBetweenOnCOnstraintUsageRuleAndCnec() {
Instant autoInstant = Mockito.mock(Instant.class);
Mockito.when(autoInstant.isPreventive()).thenReturn(false);
Instant curativeInstant = Mockito.mock(Instant.class);
Mockito.when(curativeInstant.isPreventive()).thenReturn(false);

State autoState = Mockito.mock(State.class);
Mockito.when(autoState.getInstant()).thenReturn(autoInstant);
State curativeState = Mockito.mock(State.class);
Mockito.when(curativeState.getInstant()).thenReturn(curativeInstant);

FlowCnec autoFlowCnec = Mockito.mock(FlowCnec.class);
Mockito.when(autoFlowCnec.getState()).thenReturn(autoState);
FlowCnec curativeFlowCnec = Mockito.mock(FlowCnec.class);
Mockito.when(curativeFlowCnec.getState()).thenReturn(curativeState);

Set<UsageRule> usageRules = Set.of(
new OnFlowConstraintImpl(UsageMethod.FORCED, autoInstant, autoFlowCnec),
new OnFlowConstraintImpl(UsageMethod.FORCED, autoInstant, curativeFlowCnec)
);

AbstractRemedialAction<?> ra = new NetworkActionImpl("id", "name", "operator", usageRules, Collections.emptySet(), 0);
assertEquals(UsageMethod.FORCED, ra.getUsageMethod(autoState));
assertEquals(UsageMethod.UNDEFINED, ra.getUsageMethod(curativeState));
}
}

0 comments on commit 2397f81

Please sign in to comment.