Skip to content

Commit

Permalink
update : corrected limits adder test
Browse files Browse the repository at this point in the history
Signed-off-by: Naledi EL CHEIKH <[email protected]>
  • Loading branch information
Naledi EL CHEIKH committed Dec 10, 2024
1 parent b4e01c2 commit eccf723
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@
* </tr>
* </tbody>
* </table>
* @author Geoffroy Jamgotchian {@literal <geoffroy.jamgotchian at rte-france.com>}
*/
public interface Branch<I extends Branch<I>> extends Identifiable<I> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
*/
package com.powsybl.iidm.network.util;

import com.powsybl.commons.PowsyblException;
import com.powsybl.iidm.network.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Comparator;

Expand All @@ -22,6 +23,9 @@ public final class LoadingLimitsUtil {
private LoadingLimitsUtil() {
}

private static final Logger LOGGER = LoggerFactory.getLogger(LoadingLimitsUtil.class);


/**
* Interface for objects used to report the performed operation on limits when fixed by
* {@link #fixMissingPermanentLimit(LoadingLimitsAdder, double, String, LimitFixLogger)}.
Expand Down Expand Up @@ -97,7 +101,8 @@ public static <L extends LoadingLimits, A extends LoadingLimitsAdder<L, A>> void
*/
public static <L extends LoadingLimits, A extends LoadingLimitsAdder<L, A>> A initializeFromLoadingLimits(A adder, L limits) {
if (limits == null) {
throw new PowsyblException("Cannot initialize new limits from null limits");
LOGGER.warn("Created adder is empty");
return adder;
}
adder.setPermanentLimit(limits.getPermanentLimit());
limits.getTemporaryLimits().forEach(limit ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public LineAdder newLine() {

@Override
public LineAdder newLine(Line line) {
return getNetwork().newLine(line.getId());
return getNetwork().newLine(id, line);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ public void testAdderByCopy() {
adder.add();

assertTrue(areLimitsIdentical(limits1, limits2));
assertThrows(PowsyblException.class, () -> line.newCurrentLimits1(null));
assertFalse(line.newCurrentLimits1(null).hasTemporaryLimits());
}

@Test
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@
import org.mockito.Mockito;

import java.util.Collection;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Stream;

import static com.powsybl.iidm.network.VariantManagerConstants.INITIAL_VARIANT_ID;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;

public abstract class AbstractLineTest extends AbstractIdenticalLinesTest {
public abstract class AbstractLineTest {

private static final String INVALID = "invalid";

Expand All @@ -41,6 +42,22 @@ public abstract class AbstractLineTest extends AbstractIdenticalLinesTest {
private VoltageLevel voltageLevelA;
private VoltageLevel voltageLevelB;

public boolean areLinesIdentical(Line line1, Line line2) {
boolean areIdentical = false;

if (line1 != null && line2 != null) {
areIdentical = line1.getR() == line2.getR()
&& line1.getX() == line2.getX()
&& line1.getG1() == line2.getG1()
&& line1.getG2() == line2.getG2()
&& line1.getB1() == line2.getB1()
&& line1.getB2() == line2.getB2()
&& Objects.equals(line1.getTerminal1().getVoltageLevel().getId(), line2.getTerminal1().getVoltageLevel().getId())
&& Objects.equals(line1.getTerminal2().getVoltageLevel().getId(), line2.getTerminal2().getVoltageLevel().getId());
}
return areIdentical;
}

@BeforeEach
public void setUp() {
network = NoEquipmentNetworkFactory.create();
Expand Down

0 comments on commit eccf723

Please sign in to comment.