### Question:
CategoryEditor extends PropertyEditorSupport { @Override public String getAsText() { Category category = (Category)getValue(); return (category == null) ? null : category.getId().toString(); } @Autowired  CategoryEditor(CategoryService categoryService); @Override void setAsText(String text); @Override String getAsText();  }### Answer:
@Test public void getAsText_validCategory() { categoryEditor.setValue(validCategory); assertThat(categoryEditor.getAsText(), is(validCategory.getId().toString())); }
@Test public void getAsText_nullCategory() { categoryEditor.setValue(null); assertThat(categoryEditor.getAsText(), is(nullValue(String.class))); }