ConstraintValueChangeHandler implements com.google.gwt.event.logical.shared.ValueChangeHandler<String> { @Override public void onValueChange(final ValueChangeEvent<String> event) { if (Arrays.asList(OperatorsOracle.EXPLICIT_LIST_OPERATORS).contains(constraint.getOperator())) { constraint.setValue(replaceQuotes(event.getValue())); } else { constraint.setValue(event.getValue()); } if (onChangeCommand != null) { onChangeCommand.execute(); } } ConstraintValueChangeHandler(final BaseSingleFieldConstraint constraint,
                                        final Command onChangeCommand); @Override void onValueChange(final ValueChangeEvent<String> event);  }
@Test public void alterValueForLists() { doReturn("in").when(constraint).getOperator(); doReturn("a,\\\"b,c\\\",d").when(valueChangeEvent).getValue(); handler.onValueChange(valueChangeEvent); verify(onChangeCommand).execute(); verify(constraint).setValue("a,\"b,c\",d"); }
@Test public void doNotAlterValue() { doReturn("==").when(constraint).getOperator(); doReturn("\"hello\"").when(valueChangeEvent).getValue(); handler.onValueChange(valueChangeEvent); verify(onChangeCommand).execute(); verify(constraint).setValue("\"hello\""); }
@Test public void nullCommand() { handler = new ConstraintValueChangeHandler(constraint, null); handler.onValueChange(valueChangeEvent); verify(onChangeCommand, never()).execute(); }