ShuntCompensatorsValidation { public boolean checkShunts(Network network, ValidationConfig config, Path file) throws IOException { Objects.requireNonNull(file); Objects.requireNonNull(config); Objects.requireNonNull(file); try (Writer writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { return checkShunts(network, config, writer); } } private  ShuntCompensatorsValidation(); boolean checkShunts(Network network, ValidationConfig config, Path file); boolean checkShunts(Network network, ValidationConfig config, Writer writer); boolean checkShunts(Network network, ValidationConfig config, ValidationWriter shuntsWriter); boolean checkShunts(ShuntCompensator shunt, ValidationConfig config, Writer writer); boolean checkShunts(ShuntCompensator shunt, ValidationConfig config, ValidationWriter shuntsWriter); boolean checkShunts(String id, double p, double q, int currentSectionCount, int maximumSectionCount, double bPerSection,
                               double v, double qMax, double nominalV, boolean connected, boolean mainComponent, ValidationConfig config,
                               Writer writer); boolean checkShunts(String id, double p, double q, int currentSectionCount, int maximumSectionCount, double bPerSection,
                               double v, double qMax, double nominalV, boolean connected, boolean mainComponent, ValidationConfig config,
                               ValidationWriter shuntsWriter); static final ShuntCompensatorsValidation INSTANCE; }
@Test public void checkShuntsValues() { assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); p = 1; assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); p = Float.NaN; assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); q = 170.52; assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, looseConfig, NullWriter.NULL_WRITER)); q = 171.52; assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, looseConfig, NullWriter.NULL_WRITER)); mainComponent = false; assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, v, qMax, nominalV, connected, mainComponent, looseConfig, NullWriter.NULL_WRITER)); mainComponent = true; q = 170.50537; assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, Float.NaN, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, Float.NaN, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); strictConfig.setOkMissingValues(true); assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, Float.NaN, v, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts("test", p, q, currentSectionCount, maximumSectionCount, bPerSection, Float.NaN, qMax, nominalV, connected, mainComponent, strictConfig, NullWriter.NULL_WRITER)); }
@Test public void checkShunts() { assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER)); Mockito.when(shuntTerminal.getQ()).thenReturn(171.52); assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER)); Mockito.when(shuntBusView.getBus()).thenReturn(null); assertFalse(ShuntCompensatorsValidation.INSTANCE.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER)); Mockito.when(shuntTerminal.getQ()).thenReturn(Double.NaN); assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts(shunt, strictConfig, NullWriter.NULL_WRITER)); }
@Test public void checkNetworkShunts() throws IOException { Network network = Mockito.mock(Network.class); Mockito.when(network.getId()).thenReturn("network"); Mockito.when(network.getShuntCompensatorStream()).thenAnswer(dummy -> Stream.of(shunt)); assertTrue(ShuntCompensatorsValidation.INSTANCE.checkShunts(network, strictConfig, data)); assertTrue(ValidationType.SHUNTS.check(network, strictConfig, tmpDir)); ValidationWriter validationWriter = ValidationUtils.createValidationWriter(network.getId(), strictConfig, NullWriter.NULL_WRITER, ValidationType.SHUNTS); assertTrue(ValidationType.SHUNTS.check(network, strictConfig, validationWriter)); }