DefaultLimitViolationDetector extends AbstractContingencyBlindDetector { @Override public void checkCurrent(Branch branch, Branch.Side side, double value, Consumer<LimitViolation> consumer) { Branch.Overload overload = LimitViolationUtils.checkTemporaryLimits(branch, side, limitReduction, value); if (currentLimitTypes.contains(Security.CurrentLimitType.TATL) && (overload != null)) { consumer.accept(new LimitViolation(branch.getId(), ((Branch<?>) branch).getOptionalName().orElse(null), LimitViolationType.CURRENT, overload.getPreviousLimitName(), overload.getTemporaryLimit().getAcceptableDuration(), overload.getPreviousLimit(), limitReduction, value, side)); } else if (currentLimitTypes.contains(Security.CurrentLimitType.PATL)) { checkPermanentLimit(branch, side, value, consumer); } } DefaultLimitViolationDetector(float limitReduction, Collection<Security.CurrentLimitType> currentLimitTypes);  DefaultLimitViolationDetector(Collection<Security.CurrentLimitType> currentLimitTypes);  DefaultLimitViolationDetector(); @Override void checkCurrent(Branch branch, Branch.Side side, double value, Consumer<LimitViolation> consumer); @Override void checkVoltage(Bus bus, double value, Consumer<LimitViolation> consumer);  }
@Test public void detectTemporaryLimitOverloadOnSide2OfLine1() { detector.checkCurrent(line1, Branch.Side.TWO, 1201, violationsCollector::add); Assertions.assertThat(violationsCollector) .hasSize(1) .allSatisfy(l -> { assertEquals(1200, l.getLimit(), 0d); assertEquals(1201, l.getValue(), 0d); assertSame(Branch.Side.TWO, l.getSide()); assertEquals(60, l.getAcceptableDuration()); }); }
@Test public void detectHighestTemporaryLimitOverloadOnSide1OfLine2() { detector.checkCurrent(line2, Branch.Side.ONE, 1250, violationsCollector::add); Assertions.assertThat(violationsCollector) .hasSize(1) .allSatisfy(l -> { assertEquals(1200, l.getLimit(), 0d); assertEquals(1250, l.getValue(), 0d); assertSame(Branch.Side.ONE, l.getSide()); assertEquals(60, l.getAcceptableDuration()); }); }
@Test public void detectPermanentLimitOverloadOnSide2OfLine1() { detector.checkCurrent(line1, Branch.Side.TWO, 1101, violationsCollector::add); Assertions.assertThat(violationsCollector) .hasSize(1) .allSatisfy(l -> { assertEquals(1100, l.getLimit(), 0d); assertEquals(1101, l.getValue(), 0d); assertSame(Branch.Side.TWO, l.getSide()); assertEquals(600, l.getAcceptableDuration()); }); }