Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
Signed-off-by: CHEN Roxane <[email protected]>
  • Loading branch information
CHEN Roxane committed Feb 10, 2025
1 parent b92abb6 commit 27475b0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,15 @@ void testImportCracWithUnknownVersion() {
@Test
void testNonNullOffsetDateTime() {
Network network = NetworkImportsUtil.createNetworkForJsonRetrocompatibilityTest();
CracCreationContext context = new JsonImport().importData(getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json"), new CracCreationParameters(), network, Mockito.mock(OffsetDateTime.class));
CracCreationContext context = new JsonImport().importData(getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json"), new CracCreationParameters(), network);
assertTrue(context.isCreationSuccessful());
assertEquals(List.of("[WARN] OffsetDateTime was ignored by the JSON CRAC importer"), context.getCreationReport().getReport());
assertNull(context.getTimeStamp());
assertEquals("test", context.getNetworkName());
}

@Test
void testImportFailure() {
CracCreationContext context = new JsonImport().importData(getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json"), new CracCreationParameters(), Mockito.mock(Network.class), Mockito.mock(OffsetDateTime.class));
CracCreationContext context = new JsonImport().importData(getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json"), new CracCreationParameters(), Mockito.mock(Network.class));
assertNotNull(context);
assertFalse(context.isCreationSuccessful());
assertNull(context.getCrac());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void testNoNetworkProvided() {
OpenRaoException exception;
try (InputStream inputStream = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json")) {
CracCreationParameters cracCreationParameters = CracCreationParameters.load();
exception = assertThrows(OpenRaoException.class, () -> jsonImport.importData(inputStream, cracCreationParameters, null, null));
exception = assertThrows(OpenRaoException.class, () -> jsonImport.importData(inputStream, cracCreationParameters, null));
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -104,7 +104,7 @@ void importV1Point0Test() {
// JSON file of open-rao v3.4.3
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.0.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -121,7 +121,7 @@ void importV1Point1Test() {
// addition of switch pairs
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.1.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -138,7 +138,7 @@ void importV1Point2Test() {
// addition of injection range action
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.2.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -156,7 +156,7 @@ void importV1Point3Test() {
// addition of initial setpoints for InjectionRangeActions and HvdcRangeActions
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.3.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -174,7 +174,7 @@ void importV1Point4Test() {
// addition of angle cnecs
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.4.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -193,7 +193,7 @@ void importV1Point5Test() {
// addition of voltage cnecs
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.5.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -214,7 +214,7 @@ void importV1Point6Test() {

InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.6.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -235,7 +235,7 @@ void importV1Point7Test() {

InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.7.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -256,7 +256,7 @@ void importV1Point8Test() {

InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.8.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -274,7 +274,7 @@ void importV1Point9Test() {
// Add support for CounterTrade remedial actions
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v1/crac-v1.9.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();

assertEquals(2, crac.getContingencies().size());
assertEquals(7, crac.getFlowCnecs().size());
Expand All @@ -293,7 +293,7 @@ void importV2Point0Test() {
// Add support for user-defined Instants
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.0.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(4, crac.getNetworkActions().size());
testContentOfV2Point0Crac(crac);
}
Expand All @@ -303,7 +303,7 @@ void importV2Point1Test() {
// Add support for CNECs' borders and relative-to-previous-time-step ranges for PSTs
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.1.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
testContentOfV2Point1Crac(crac);
}

Expand All @@ -312,7 +312,7 @@ void importV2Point2Test() {
// Add support for CNECs' borders and relative-to-previous-time-step ranges for PSTs
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.2.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(6, crac.getNetworkActions().size());
testContentOfV2Point2Crac(crac);
}
Expand All @@ -322,7 +322,7 @@ void importV2Point3Test() {
// Add support for unified onConstraint usage rules
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.3.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(6, crac.getNetworkActions().size());
testContentOfV2Point3Crac(crac);
}
Expand All @@ -333,7 +333,7 @@ void importV2Point4Test() {
// Side left/right replaced by one/two (from powsybl-core)
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.4.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(7, crac.getNetworkActions().size());
testContentOfV2Point4Crac(crac);
}
Expand All @@ -343,7 +343,7 @@ void importV2Point5Test() {
// ElementaryAction are now Action from powsybl-core (more different types and fields name changes)
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.5.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(7, crac.getNetworkActions().size());
testContentOfV2Point5Crac(crac);
}
Expand All @@ -352,7 +352,7 @@ void importV2Point5Test() {
void importV2Point6Test() {
InputStream cracFile = getClass().getResourceAsStream("/retrocompatibility/v2/crac-v2.6.json");

Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network, null).getCrac();
Crac crac = new JsonImport().importData(cracFile, CracCreationParameters.load(), network).getCrac();
assertEquals(7, crac.getNetworkActions().size());
testContentOfV2Point6Crac(crac);
}
Expand Down

0 comments on commit 27475b0

Please sign in to comment.