### Question:
DefaultStringEditor extends PropertyEditorSupport { @Override public void setAsText(String text) { if(emptyAsNull && "".equals(text)){ setValue(null); } else { setValue(text); } } DefaultStringEditor(boolean emptyAsNull); @Override void setAsText(String text); @Override String getAsText();  }### Answer:
@Test public void emptyValueWithOptionEmptyAsNullShouldBeTransformedToNull() { editor = new DefaultStringEditor(true); editor.setAsText(""); assertNull(editor.getValue(), "String value should be correctly transformed to null."); }
@Test public void notEmptyValueWithOptionEmptyAsNullShouldNotBeChanged() { editor = new DefaultStringEditor(true); editor.setAsText("123"); assertEquals("123", editor.getValue(), "String value shouldn't be transformed."); }
@Test public void emptyValueWithoutOptionEmptyAsNullShouldNotBeChanged() { editor = new DefaultStringEditor(false); editor.setAsText(""); assertEquals("", editor.getValue(), "String value shouldn't be transformed."); }
@Test public void notEmptyValueWithoutOptionEmptyAsNullShouldNotBeChanged() { editor = new DefaultStringEditor(false); editor.setAsText("123"); assertEquals("123", editor.getValue(), "String value shouldn't be transformed."); }