From e108db039a7eeac2bc72dea5d9c54453d1e14240 Mon Sep 17 00:00:00 2001 From: p-arvy Date: Thu, 27 Jun 2024 11:45:42 +0200 Subject: [PATCH] Add TU. Signed-off-by: p-arvy --- .../ShuntCompensatorNetworkOutputTest.java | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 open-reac/src/test/java/com/powsybl/openreac/parameters/output/ShuntCompensatorNetworkOutputTest.java diff --git a/open-reac/src/test/java/com/powsybl/openreac/parameters/output/ShuntCompensatorNetworkOutputTest.java b/open-reac/src/test/java/com/powsybl/openreac/parameters/output/ShuntCompensatorNetworkOutputTest.java new file mode 100644 index 00000000..269d8442 --- /dev/null +++ b/open-reac/src/test/java/com/powsybl/openreac/parameters/output/ShuntCompensatorNetworkOutputTest.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2024, 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 com.powsybl.ampl.converter.AmplSubset; +import com.powsybl.commons.util.StringToIntMapper; +import com.powsybl.iidm.network.Network; +import com.powsybl.openreac.parameters.output.network.ShuntCompensatorNetworkOutput; +import org.junit.jupiter.api.Test; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; + +import static com.powsybl.openreac.network.ShuntNetworkFactory.create; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +/** + * @author Pierre Arvy {@literal } + */ +public class ShuntCompensatorNetworkOutputTest { + + @Test + void readTestNullShunt() throws IOException { + Network network = create(); + ShuntCompensatorNetworkOutput output = new ShuntCompensatorNetworkOutput(network, 0); + StringToIntMapper mapper = new StringToIntMapper<>(AmplSubset.class); + mapper.newInt(AmplSubset.SHUNT, "shuntId"); + try (InputStream input = getClass().getResourceAsStream("/mock_outputs/reactiveopf_results_shunts.csv"); + InputStreamReader in = new InputStreamReader(input); + BufferedReader reader = new BufferedReader(in)) { + output.read(reader, mapper); + assertEquals(1, output.getModifications().size()); + assertEquals("shuntId", output.getModifications().get(0).getShuntCompensatorId()); + assertNull(output.getModifications().get(0).getConnect()); + assertNull(output.getModifications().get(0).getSectionCount()); + } + } + +}