AbstractField extends Component implements HasValueAndElement<ComponentValueChangeEvent<C, T>, T> { @Override public T getValue() { return fieldSupport.getValue(); } AbstractField(T defaultValue);  AbstractField(Element element, T defaultValue); @Override Registration addValueChangeListener(
            HasValue.ValueChangeListener<? super ComponentValueChangeEvent<C, T>> listener); @Override void setValue(T value); @Override boolean isEmpty(); @Override T getValue(); @Override T getEmptyValue();  }
@Test public void initialValue_used() { TestAbstractField<String> field = new TestAbstractField<>("foo"); Assert.assertEquals("foo", field.getValue()); }
@Test public void getValue_changesAfterUpdatedFromClient() { TestAbstractField<String> field = new TestAbstractField<>(); Assert.assertNull(field.getValue()); field.presentationValue = "foo"; Assert.assertNull(field.getValue()); field.valueUpdatedFromClient(false); Assert.assertEquals("foo", field.getValue()); }
@Test public void updatePresentation_doesntCallSetPresentation() { TestAbstractField<String> field = new TestAbstractField<>(); field.setPresentationValue = value -> Assert .fail("setPresentationValue should not run"); field.updatePresentationValue("foo", true); Assert.assertEquals("foo", field.getValue()); }
@Test public void readonly_presentationFromClient_reverted() { TestAbstractField<String> field = new TestAbstractField<>(); ValueChangeMonitor<String> eventMonitor = new ValueChangeMonitor<>( field); field.setReadOnly(true); field.updatePresentationValue("foo", true); eventMonitor.assertNoEvent(); Assert.assertEquals(null, field.getValue()); Assert.assertEquals(null, field.presentationValue); }
@Test public void readonly_presentationFromServer_accepted() { TestAbstractField<String> field = new TestAbstractField<>(); ValueChangeMonitor<String> eventMonitor = new ValueChangeMonitor<>( field); field.setReadOnly(true); field.updatePresentationValue("foo", false); eventMonitor.discard(); Assert.assertEquals("foo", field.presentationValue); Assert.assertEquals("foo", field.getValue()); }