@Test public void setRateDoesCreatesUndoItemIfRateEqual() throws InvalidRateException { String oldRate = "5"; String newRate = "5"; when(rateParameter.getExpression()).thenReturn(oldRate); rateParameterController.setRate(newRate); verify(listener, never()).undoableEditHappened(any(UndoableEditEvent.class)); }
public void setRate(String expression) throws InvalidRateException { String oldRate = component.getExpression(); if (!oldRate.equals(expression)) { FunctionalResults<Double> results = petriNet.parseExpression(expression); if (results.hasErrors()) { throw new InvalidRateException(results.getErrorString("\n")); } component.setExpression(expression); UndoableEdit rateAction = new ChangeRateParameterRate(component, oldRate, expression); registerUndoableEdit(rateAction); } }
RateParameterController extends AbstractPetriNetComponentController<RateParameter> { public void setRate(String expression) throws InvalidRateException { String oldRate = component.getExpression(); if (!oldRate.equals(expression)) { FunctionalResults<Double> results = petriNet.parseExpression(expression); if (results.hasErrors()) { throw new InvalidRateException(results.getErrorString("\n")); } component.setExpression(expression); UndoableEdit rateAction = new ChangeRateParameterRate(component, oldRate, expression); registerUndoableEdit(rateAction); } } }
RateParameterController extends AbstractPetriNetComponentController<RateParameter> { public void setRate(String expression) throws InvalidRateException { String oldRate = component.getExpression(); if (!oldRate.equals(expression)) { FunctionalResults<Double> results = petriNet.parseExpression(expression); if (results.hasErrors()) { throw new InvalidRateException(results.getErrorString("\n")); } component.setExpression(expression); UndoableEdit rateAction = new ChangeRateParameterRate(component, oldRate, expression); registerUndoableEdit(rateAction); } } protected  RateParameterController(RateParameter component, PetriNet petriNet, UndoableEditListener listener); }
RateParameterController extends AbstractPetriNetComponentController<RateParameter> { public void setRate(String expression) throws InvalidRateException { String oldRate = component.getExpression(); if (!oldRate.equals(expression)) { FunctionalResults<Double> results = petriNet.parseExpression(expression); if (results.hasErrors()) { throw new InvalidRateException(results.getErrorString("\n")); } component.setExpression(expression); UndoableEdit rateAction = new ChangeRateParameterRate(component, oldRate, expression); registerUndoableEdit(rateAction); } } protected  RateParameterController(RateParameter component, PetriNet petriNet, UndoableEditListener listener); void setRate(String expression); }
RateParameterController extends AbstractPetriNetComponentController<RateParameter> { public void setRate(String expression) throws InvalidRateException { String oldRate = component.getExpression(); if (!oldRate.equals(expression)) { FunctionalResults<Double> results = petriNet.parseExpression(expression); if (results.hasErrors()) { throw new InvalidRateException(results.getErrorString("\n")); } component.setExpression(expression); UndoableEdit rateAction = new ChangeRateParameterRate(component, oldRate, expression); registerUndoableEdit(rateAction); } } protected  RateParameterController(RateParameter component, PetriNet petriNet, UndoableEditListener listener); void setRate(String expression);  }