ConstraintsModifier { public void looseConstraints(String stateId) { looseConstraints(stateId, 0f, false); } ConstraintsModifier(Network network);  ConstraintsModifier(Network network, ConstraintsModifierConfig config); void looseConstraints(String stateId); void looseConstraints(String stateId, float margin); void looseConstraints(String stateId, float margin, boolean applyToBaseCase); void looseConstraints(String stateId, List<LimitViolation> violations); void looseConstraints(String stateId, List<LimitViolation> violations, float margin); void looseConstraints(String stateId, List<LimitViolation> violations, float margin, boolean applyToBaseCase);  }
@Test public void testWithNullValues() throws Exception { ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); try { constraintsModifier.looseConstraints(null, violations); fail(); } catch (Throwable e) { } try { constraintsModifier.looseConstraints(StateManagerConstants.INITIAL_STATE_ID, null); fail(); } catch (Throwable e) { } }
@Test public void testWithWrongState() throws Exception { ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); try { constraintsModifier.looseConstraints("wrongState", violations); fail(); } catch (Throwable e) { } }
@Test public void testNoMargin() throws Exception { checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(StateManagerConstants.INITIAL_STATE_ID); checkModifiedNetworkLimits(0); }
@Test public void testWithMargin() throws Exception { float margin = 3.0f; checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(StateManagerConstants.INITIAL_STATE_ID, margin); checkModifiedNetworkLimits(margin); }
@Test public void testWithViolationsNoMargin() throws Exception { checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(StateManagerConstants.INITIAL_STATE_ID, violations); checkModifiedNetworkLimits(0); }
@Test public void testWithViolationsAndMargin() throws Exception { float margin = 3.0f; checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(StateManagerConstants.INITIAL_STATE_ID, violations, margin); checkModifiedNetworkLimits(margin); }
@Test public void testWithViolationsAndMarginApplyBasecase() throws Exception { float margin = 3; checkOriginalNetworkLimits(); String stateId = "0"; network.getStateManager().cloneState(StateManagerConstants.INITIAL_STATE_ID, stateId); network.getStateManager().setWorkingState(stateId); checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(stateId, violations, margin, true); checkModifiedNetworkLimits(margin); network.getStateManager().setWorkingState(StateManagerConstants.INITIAL_STATE_ID); checkModifiedNetworkLimits(margin); network.getStateManager().removeState(stateId); }
@Test public void testWithMarginApplyBasecase() throws Exception { float margin = 3; checkOriginalNetworkLimits(); String stateId = "0"; network.getStateManager().cloneState(StateManagerConstants.INITIAL_STATE_ID, stateId); network.getStateManager().setWorkingState(stateId); checkOriginalNetworkLimits(); ConstraintsModifier constraintsModifier = new ConstraintsModifier(network, config); constraintsModifier.looseConstraints(stateId, margin, true); checkModifiedNetworkLimits(margin); network.getStateManager().setWorkingState(StateManagerConstants.INITIAL_STATE_ID); checkModifiedNetworkLimits(margin); network.getStateManager().removeState(stateId); }