Skip to content

Commit

Permalink
Coverage
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 2397f81 commit bd8f467
Showing 1 changed file with 57 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
import com.powsybl.iidm.network.Country;
import com.powsybl.openrao.data.cracapi.Instant;
import com.powsybl.openrao.data.cracapi.State;
import com.powsybl.openrao.data.cracapi.cnec.AngleCnec;
import com.powsybl.openrao.data.cracapi.cnec.FlowCnec;
import com.powsybl.openrao.data.cracapi.cnec.VoltageCnec;
import com.powsybl.openrao.data.cracapi.usagerule.UsageMethod;
import com.powsybl.openrao.data.cracapi.usagerule.UsageRule;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -98,7 +100,7 @@ void testStrongestStateAndInstantUsageRule() {
}

@Test
void testDifferentInstantsBetweenOnCOnstraintUsageRuleAndCnec() {
void testDifferentInstantsBetweenOnFlowConstraintUsageRuleAndCnec() {
Instant autoInstant = Mockito.mock(Instant.class);
Mockito.when(autoInstant.isPreventive()).thenReturn(false);
Instant curativeInstant = Mockito.mock(Instant.class);
Expand All @@ -123,4 +125,58 @@ void testDifferentInstantsBetweenOnCOnstraintUsageRuleAndCnec() {
assertEquals(UsageMethod.FORCED, ra.getUsageMethod(autoState));
assertEquals(UsageMethod.UNDEFINED, ra.getUsageMethod(curativeState));
}

@Test
void testDifferentInstantsBetweenOnAngleConstraintUsageRuleAndCnec() {
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);

AngleCnec autoAngleCnec = Mockito.mock(AngleCnec.class);
Mockito.when(autoAngleCnec.getState()).thenReturn(autoState);
AngleCnec curativeAngleCnec = Mockito.mock(AngleCnec.class);
Mockito.when(curativeAngleCnec.getState()).thenReturn(curativeState);

Set<UsageRule> usageRules = Set.of(
new OnAngleConstraintImpl(UsageMethod.FORCED, autoInstant, autoAngleCnec),
new OnAngleConstraintImpl(UsageMethod.FORCED, autoInstant, curativeAngleCnec)
);

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

@Test
void testDifferentInstantsBetweenOnVoltageConstraintUsageRuleAndCnec() {
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);

VoltageCnec autoVoltageCnec = Mockito.mock(VoltageCnec.class);
Mockito.when(autoVoltageCnec.getState()).thenReturn(autoState);
VoltageCnec curativeVoltageCnec = Mockito.mock(VoltageCnec.class);
Mockito.when(curativeVoltageCnec.getState()).thenReturn(curativeState);

Set<UsageRule> usageRules = Set.of(
new OnVoltageConstraintImpl(UsageMethod.FORCED, autoInstant, autoVoltageCnec),
new OnVoltageConstraintImpl(UsageMethod.FORCED, autoInstant, curativeVoltageCnec)
);

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 bd8f467

Please sign in to comment.