### Question:
MongoDbCategoryConverter implements HydratingModelConverter<Category, MongoDbCategory> { @Override public MongoDbCategory convert(Category source) { MongoDbCategory category = new MongoDbCategory(); category.setId(source.getId() == null ? generateId() : source.getId()); category.setCreatedDate(source.getCreatedDate()); category.setCreatedUserId(source.getCreatedUserId()); category.setLastModifiedUserId(source.getLastModifiedUserId()); category.setWidgetRepository(null); category.setText(source.getText()); category.setWidgets(null); return category; }  @Override void hydrate(MongoDbCategory dehydrated); @Override Class<Category> getSourceType(); @Override MongoDbCategory convert(Category source); void setMongoWidgetOperations(MongoWidgetOperations mongoWidgetOperations);  }### Answer:
@Test public void convert_valid(){ Category c = new CategoryImpl(); c.setCreatedDate(DATE1); c.setCreatedUserId(USER1ID); c.setId(USER1ID); c.setLastModifiedUserId(USER2ID); c.setText("asdf"); c.setWidgets(Lists.<Widget>newArrayList()); c.setLastModifiedDate(DATE2); MongoDbCategory mongoC = converter.convert(c); assertThat(mongoC.getCreatedDate(), is(equalTo(DATE1))); assertThat(mongoC.getCreatedUserId(), is(equalTo(USER1ID))); assertThat(mongoC.getId(), is(equalTo(USER1ID))); assertThat(mongoC.getLastModifiedUserId(), is(equalTo(USER2ID))); assertThat(mongoC.getWidgetRepository(), is(nullValue())); assertThat(mongoC.getText(), is("asdf")); assertThat(c.getWidgets().size(), is(0)); }
@Test public void convert_Null(){ Category source = new CategoryImpl(); MongoDbCategory converted = converter.convert(source); assertNull(converted.getLastModifiedUserId()); assertNull(converted.getCreatedUserId()); assertNotNull(converted.getId()); }