@Test public void checkNetworkTwts() throws IOException { Network network = Mockito.mock(Network.class); Mockito.when(network.getId()).thenReturn("network"); Mockito.when(network.getTwoWindingsTransformerStream()).thenAnswer(dummy -> Stream.of(transformer)); assertTrue(TransformersValidation.INSTANCE.checkTransformers(network, strictConfig, data)); assertTrue(ValidationType.TWTS.check(network, strictConfig, tmpDir)); ValidationWriter validationWriter = ValidationUtils.createValidationWriter(network.getId(), strictConfig, NullWriter.NULL_WRITER, ValidationType.TWTS); assertTrue(ValidationType.TWTS.check(network, strictConfig, validationWriter)); }
@Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking transformers of network {}", network.getId()); return network.getTwoWindingsTransformerStream() .filter(TransformersValidation::filterTwt) .sorted(Comparator.comparing(TwoWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); }
TransformersValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking transformers of network {}", network.getId()); return network.getTwoWindingsTransformerStream() .filter(TransformersValidation::filterTwt) .sorted(Comparator.comparing(TwoWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } }
TransformersValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking transformers of network {}", network.getId()); return network.getTwoWindingsTransformerStream() .filter(TransformersValidation::filterTwt) .sorted(Comparator.comparing(TwoWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  TransformersValidation(); }
TransformersValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking transformers of network {}", network.getId()); return network.getTwoWindingsTransformerStream() .filter(TransformersValidation::filterTwt) .sorted(Comparator.comparing(TwoWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  TransformersValidation(); @Override boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(TwoWindingsTransformer twt, ValidationConfig config, Writer writer); boolean checkTransformer(TwoWindingsTransformer twt, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(String id, double rho, double rhoPreviousStep, double rhoNextStep, int tapPosition,
                                           int lowTapPosition, int highTapPosition, double targetV, Side regulatedSide, double v,
                                           boolean connected, boolean mainComponent, ValidationConfig config, Writer writer); boolean checkTransformer(String id, double rho, double rhoPreviousStep, double rhoNextStep, int tapPosition,
                                           int lowTapPosition, int highTapPosition, double targetV, Side regulatedSide, double v,
                                           boolean connected, boolean mainComponent, ValidationConfig config, ValidationWriter twtsWriter); }
TransformersValidation extends AbstractTransformersValidation { @Override public boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter) { Objects.requireNonNull(network); Objects.requireNonNull(config); Objects.requireNonNull(twtsWriter); LOGGER.info("Checking transformers of network {}", network.getId()); return network.getTwoWindingsTransformerStream() .filter(TransformersValidation::filterTwt) .sorted(Comparator.comparing(TwoWindingsTransformer::getId)) .map(twt -> checkTransformer(twt, config, twtsWriter)) .reduce(Boolean::logicalAnd) .orElse(true); } private  TransformersValidation(); @Override boolean checkTransformers(Network network, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(TwoWindingsTransformer twt, ValidationConfig config, Writer writer); boolean checkTransformer(TwoWindingsTransformer twt, ValidationConfig config, ValidationWriter twtsWriter); boolean checkTransformer(String id, double rho, double rhoPreviousStep, double rhoNextStep, int tapPosition,
                                           int lowTapPosition, int highTapPosition, double targetV, Side regulatedSide, double v,
                                           boolean connected, boolean mainComponent, ValidationConfig config, Writer writer); boolean checkTransformer(String id, double rho, double rhoPreviousStep, double rhoNextStep, int tapPosition,
                                           int lowTapPosition, int highTapPosition, double targetV, Side regulatedSide, double v,
                                           boolean connected, boolean mainComponent, ValidationConfig config, ValidationWriter twtsWriter); static final TransformersValidation INSTANCE; }