BusesValidation { public boolean checkBuses(Network network, ValidationConfig config, Path file) throws IOException { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(file); try (Writer writer = Files.newBufferedWriter(file, StandardCharsets.UTF_8)) { return checkBuses(network, config, writer); } } private  BusesValidation(); boolean checkBuses(Network network, ValidationConfig config, Path file); boolean checkBuses(Network network, ValidationConfig config, Writer writer); boolean checkBuses(Network network, ValidationConfig config, ValidationWriter busesWriter); boolean checkBuses(Bus bus, ValidationConfig config, Writer writer); boolean checkBuses(Bus bus, ValidationConfig config, ValidationWriter busesWriter); boolean checkBuses(String id, double loadP, double loadQ, double genP, double genQ, double batP, double batQ,
                                     double shuntP, double shuntQ, double svcP, double svcQ, double vscCSP, double vscCSQ,
                                     double lineP, double lineQ, double danglingLineP, double danglingLineQ,
                                     double twtP, double twtQ, double tltP, double tltQ, boolean mainComponent, ValidationConfig config, Writer writer); boolean checkBuses(String id, double loadP, double loadQ, double genP, double genQ, double batP, double batQ, double shuntP,
                                     double shuntQ, double svcP, double svcQ, double vscCSP, double vscCSQ, double lineP, double lineQ,
                                     double danglingLineP, double danglingLineQ, double twtP, double twtQ, double tltP, double tltQ,
                                     boolean mainComponent, ValidationConfig config, ValidationWriter busesWriter); static final BusesValidation INSTANCE; }
@Test public void checkBusesValues() { assertTrue(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); assertFalse(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, strictConfig, NullWriter.NULL_WRITER)); assertFalse(BusesValidation.INSTANCE.checkBuses("test", loadP, 174.4932, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); assertFalse(BusesValidation.INSTANCE.checkBuses("test", Double.NaN, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); assertFalse(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, Double.NaN, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); looseConfig.setOkMissingValues(true); assertTrue(BusesValidation.INSTANCE.checkBuses("test", Double.NaN, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); assertTrue(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, Double.NaN, tltP, tltQ, mainComponent, looseConfig, NullWriter.NULL_WRITER)); looseConfig.setOkMissingValues(false); assertFalse(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, strictConfig, NullWriter.NULL_WRITER)); mainComponent = false; assertTrue(BusesValidation.INSTANCE.checkBuses("test", loadP, loadQ, genP, genQ, batP, batQ, shuntP, shuntQ, svcP, svcQ, vscCSP, vscCSQ, lineP, lineQ, danglingLineP, danglingLineQ, twtP, twtQ, tltP, tltQ, mainComponent, strictConfig, NullWriter.NULL_WRITER)); }
@Test public void checkBuses() { assertTrue(BusesValidation.INSTANCE.checkBuses(bus, looseConfig, NullWriter.NULL_WRITER)); assertFalse(BusesValidation.INSTANCE.checkBuses(bus, strictConfig, NullWriter.NULL_WRITER)); }
@Test public void checkNetworkBuses() throws IOException { Network.BusView networkBusView = Mockito.mock(Network.BusView.class); Mockito.when(networkBusView.getBusStream()).thenAnswer(dummy -> Stream.of(bus)); Network network = Mockito.mock(Network.class); Mockito.when(network.getId()).thenReturn("network"); Mockito.when(network.getBusView()).thenReturn(networkBusView); assertTrue(BusesValidation.INSTANCE.checkBuses(network, looseConfig, data)); assertFalse(BusesValidation.INSTANCE.checkBuses(network, strictConfig, data)); assertTrue(ValidationType.BUSES.check(network, looseConfig, tmpDir)); assertFalse(ValidationType.BUSES.check(network, strictConfig, tmpDir)); ValidationWriter validationWriter = ValidationUtils.createValidationWriter(network.getId(), looseConfig, NullWriter.NULL_WRITER, ValidationType.BUSES); assertTrue(ValidationType.BUSES.check(network, looseConfig, validationWriter)); }