EditAttributeWidgetFactory { protected void initTextBoxByRuleAttribute(final TextBox textBox, final RuleAttribute ruleAttribute) { textBox.setEnabled(!isReadOnly); if (!isReadOnly) { textBox.addValueChangeHandler(event -> ruleAttribute.setValue(textBox.getValue())); } textBox.setValue(ruleAttribute.getValue()); } EditAttributeWidgetFactory(final boolean isReadOnly); TextBox textBox(final RuleAttribute ruleAttribute, final String dataType); DatePicker datePicker(final RuleAttribute ruleAttribute, final boolean allowEmptyValues);  }
@Test public void testInitTextBoxByRuleAttribute() { final TextBox textBox = mock(TextBox.class); final String attributeValue = "123"; doReturn(attributeValue).when(ruleAttribute).getValue(); factory.initTextBoxByRuleAttribute(textBox, ruleAttribute); verify(textBox).setEnabled(!isReadOnly); verify(textBox).setValue(attributeValue); }
@Test public void testTextBoxValueChangeHandler() { final TextBox textBox = mock(TextBox.class); final String textBoxValue = "123"; doReturn(textBoxValue).when(textBox).getValue(); factory.initTextBoxByRuleAttribute(textBox, ruleAttribute); verify(textBox).addValueChangeHandler(valueChangeHandlerArgumentCaptor.capture()); valueChangeHandlerArgumentCaptor.getValue().onValueChange(null); verify(ruleAttribute).setValue(textBoxValue); }