-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Olivier Perrin <olivier.perrin@rte-france.com>
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
open-reac/src/test/java/com/powsybl/openreac/parameters/output/ReactiveSlackOutputTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* Copyright (c) 2023, RTE (http://www.rte-france.com) | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
* SPDX-License-Identifier: MPL-2.0 | ||
*/ | ||
package com.powsybl.openreac.parameters.output; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
/** | ||
* @author Olivier Perrin {@literal <olivier.perrin at rte-france.com>} | ||
*/ | ||
class ReactiveSlackOutputTest { | ||
|
||
@Test | ||
void readTest() throws IOException { | ||
ReactiveSlackOutput output = new ReactiveSlackOutput(); | ||
try (InputStream input = getClass().getResourceAsStream("/mock_outputs/reactiveopf_results_reactive_slacks.csv"); | ||
InputStreamReader in = new InputStreamReader(input); | ||
BufferedReader reader = new BufferedReader(in)) { | ||
|
||
output.read(reader, null); | ||
assertEquals(2, output.getSlacks().size()); | ||
ReactiveSlackOutput.ReactiveSlack slack1 = output.getSlacks().get(0); | ||
ReactiveSlackOutput.ReactiveSlack slack2 = output.getSlacks().get(1); | ||
Assertions.assertAll( | ||
() -> assertEquals(1.6, slack1.getSlack(), 0.01), | ||
() -> assertEquals("slack1", slack1.getBusId()), | ||
() -> assertEquals("voltageLevel1", slack1.getVoltageLevelId()), | ||
() -> assertEquals(Double.NaN, slack2.getSlack()), | ||
() -> assertEquals("slack2", slack2.getBusId()), | ||
() -> assertEquals("voltageLevel2", slack2.getVoltageLevelId()) | ||
); | ||
} | ||
} | ||
|
||
} |
3 changes: 3 additions & 0 deletions
3
open-reac/src/test/resources/mock_outputs/reactiveopf_results_reactive_slacks.csv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
col1;col2;col3;col4;col5;col6; | ||
'a1';'b1';5.3;6.9;'slack1';'voltageLevel1'; | ||
'a2';'b2';1.2;-99999;'slack2';'voltageLevel2'; |