@Test public void checkNetworkTwts() throws IOException { Network network = Mockito.mock(Network.class); Mockito.when(network.getId()).thenReturn("network"); Mockito.when(network.getThreeWindingsTransformerStream()).thenAnswer(dummy -> Stream.of(twtValidationData.get3WTransformer())); assertFalse(Transformers3WValidation.INSTANCE.checkTransformers(network, strictConfig, data)); assertFalse(ValidationType.TWTS3W.check(network, strictConfig, tmpDir)); ValidationWriter validationWriter = ValidationUtils.createValidationWriter(network.getId(), strictConfig, NullWriter.NULL_WRITER, ValidationType.TWTS); assertFalse(ValidationType.TWTS3W.check(network, strictConfig, validationWriter)); strictConfig.setThreshold(.3); assertTrue(Transformers3WValidation.INSTANCE.checkTransformers(network, strictConfig, NullWriter.NULL_WRITER)); }
@Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking 3W transformers of network {}", network.getId()); return network.getThreeWindingsTransformerStream() .sorted(Comparator.comparing(ThreeWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); }
Transformers3WValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking 3W transformers of network {}", network.getId()); return network.getThreeWindingsTransformerStream() .sorted(Comparator.comparing(ThreeWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } }
Transformers3WValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking 3W transformers of network {}", network.getId()); return network.getThreeWindingsTransformerStream() .sorted(Comparator.comparing(ThreeWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  Transformers3WValidation(); }
Transformers3WValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking 3W transformers of network {}", network.getId()); return network.getThreeWindingsTransformerStream() .sorted(Comparator.comparing(ThreeWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  Transformers3WValidation(); @Override boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(ThreeWindingsTransformer twt, ValidationConfig config, Writer writer); boolean checkTransformer(ThreeWindingsTransformer twt, ValidationConfig config, ValidationWriter twtsWriter); }
Transformers3WValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking 3W transformers of network {}", network.getId()); return network.getThreeWindingsTransformerStream() .sorted(Comparator.comparing(ThreeWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  Transformers3WValidation(); @Override boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(ThreeWindingsTransformer twt, ValidationConfig config, Writer writer); boolean checkTransformer(ThreeWindingsTransformer twt, ValidationConfig config, ValidationWriter twtsWriter); static final Transformers3WValidation INSTANCE; }