@Test public void apply() throws Exception { Network network = TestingNetworkFactory.create(); LimitViolation line1Violation = new LimitViolation("LINE1", LimitViolationType.CURRENT, "", Integer.MAX_VALUE, 1000.0, 1, 1100.0, Branch.Side.ONE); LimitViolation line2Violation = new LimitViolation("LINE2", LimitViolationType.CURRENT, "", Integer.MAX_VALUE, 900.0, 1, 950.0, Branch.Side.TWO); LimitViolation vl1Violation = new LimitViolation("VL1", LimitViolationType.HIGH_VOLTAGE, 200.0, 1, 250.0); LimitViolationFilter filter = new LimitViolationFilter(); List<LimitViolation> filteredViolations = filter.apply(Arrays.asList(line1Violation, line2Violation, vl1Violation), network); assertEquals(3, filteredViolations.size()); filter = new LimitViolationFilter(); filter.setViolationTypes(EnumSet.of(LimitViolationType.HIGH_VOLTAGE)); filteredViolations = filter.apply(Arrays.asList(line1Violation, line2Violation, vl1Violation), network); checkFilteredViolations(filteredViolations, network, "VL1", LimitViolationType.HIGH_VOLTAGE, 220.0, Country.FR, "VL1"); filter = new LimitViolationFilter(); filter.setMinBaseVoltage(300.0); filteredViolations = filter.apply(Arrays.asList(line1Violation, line2Violation, vl1Violation), network); checkFilteredViolations(filteredViolations, network, "LINE1", LimitViolationType.CURRENT, 380.0, Country.FR, "VL2"); filter = new LimitViolationFilter(); filter.setCountries(EnumSet.of(Country.BE)); filteredViolations = filter.apply(Arrays.asList(line1Violation, line2Violation, vl1Violation), network); checkFilteredViolations(filteredViolations, network, "LINE2", LimitViolationType.CURRENT, 220.0, Country.BE, "VL3"); filter = new LimitViolationFilter(EnumSet.of(LimitViolationType.CURRENT), 300.0, EnumSet.of(Country.FR)); filteredViolations = filter.apply(Arrays.asList(line1Violation, line2Violation, vl1Violation), network); checkFilteredViolations(filteredViolations, network, "LINE1", LimitViolationType.CURRENT, 380.0, Country.FR, "VL2"); }
public List<LimitViolation> apply(List<LimitViolation> violations, Network network) { Objects.requireNonNull(violations); Objects.requireNonNull(network); return violations.stream() .filter(violation -> accept(violation.getLimitType())) .filter(violation -> accept(LimitViolationHelper.getNominalVoltage(violation, network))) .filter(violation -> accept(LimitViolationHelper.getCountry(violation, network).orElse(null))) .collect(Collectors.toList()); }
LimitViolationFilter { public List<LimitViolation> apply(List<LimitViolation> violations, Network network) { Objects.requireNonNull(violations); Objects.requireNonNull(network); return violations.stream() .filter(violation -> accept(violation.getLimitType())) .filter(violation -> accept(LimitViolationHelper.getNominalVoltage(violation, network))) .filter(violation -> accept(LimitViolationHelper.getCountry(violation, network).orElse(null))) .collect(Collectors.toList()); } }
LimitViolationFilter { public List<LimitViolation> apply(List<LimitViolation> violations, Network network) { Objects.requireNonNull(violations); Objects.requireNonNull(network); return violations.stream() .filter(violation -> accept(violation.getLimitType())) .filter(violation -> accept(LimitViolationHelper.getNominalVoltage(violation, network))) .filter(violation -> accept(LimitViolationHelper.getCountry(violation, network).orElse(null))) .collect(Collectors.toList()); } LimitViolationFilter(Set<LimitViolationType> violationTypes);  LimitViolationFilter();  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage);  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage, Set<Country> countries); }
LimitViolationFilter { public List<LimitViolation> apply(List<LimitViolation> violations, Network network) { Objects.requireNonNull(violations); Objects.requireNonNull(network); return violations.stream() .filter(violation -> accept(violation.getLimitType())) .filter(violation -> accept(LimitViolationHelper.getNominalVoltage(violation, network))) .filter(violation -> accept(LimitViolationHelper.getCountry(violation, network).orElse(null))) .collect(Collectors.toList()); } LimitViolationFilter(Set<LimitViolationType> violationTypes);  LimitViolationFilter();  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage);  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage, Set<Country> countries); static LimitViolationFilter load(); static LimitViolationFilter load(PlatformConfig platformConfig); Set<LimitViolationType> getViolationTypes(); LimitViolationFilter setViolationTypes(Set<LimitViolationType> violationTypes); double getMinBaseVoltage(); LimitViolationFilter setMinBaseVoltage(double minBaseVoltage); Set<Country> getCountries(); LimitViolationFilter setCountries(Set<Country> countries); List<LimitViolation> apply(List<LimitViolation> violations, Network network); }
LimitViolationFilter { public List<LimitViolation> apply(List<LimitViolation> violations, Network network) { Objects.requireNonNull(violations); Objects.requireNonNull(network); return violations.stream() .filter(violation -> accept(violation.getLimitType())) .filter(violation -> accept(LimitViolationHelper.getNominalVoltage(violation, network))) .filter(violation -> accept(LimitViolationHelper.getCountry(violation, network).orElse(null))) .collect(Collectors.toList()); } LimitViolationFilter(Set<LimitViolationType> violationTypes);  LimitViolationFilter();  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage);  LimitViolationFilter(Set<LimitViolationType> violationTypes, double minBaseVoltage, Set<Country> countries); static LimitViolationFilter load(); static LimitViolationFilter load(PlatformConfig platformConfig); Set<LimitViolationType> getViolationTypes(); LimitViolationFilter setViolationTypes(Set<LimitViolationType> violationTypes); double getMinBaseVoltage(); LimitViolationFilter setMinBaseVoltage(double minBaseVoltage); Set<Country> getCountries(); LimitViolationFilter setCountries(Set<Country> countries); List<LimitViolation> apply(List<LimitViolation> violations, Network network);  }