### Question:
MongoDbPortalPreferenceConverter implements HydratingModelConverter<PortalPreference, MongoDbPortalPreference> { @Override public MongoDbPortalPreference convert(PortalPreference source) { MongoDbPortalPreference converted = source instanceof MongoDbPortalPreference ? (MongoDbPortalPreference) source : new MongoDbPortalPreference(); converted.setKey(source.getKey()); converted.setValues(source.getValues()); return converted; }  @Override void hydrate(MongoDbPortalPreference dehydrated); @Override Class<PortalPreference> getSourceType(); @Override MongoDbPortalPreference convert(PortalPreference source);  }### Answer:
@Test public void convertPreference_valid(){ PortalPreference pp = new PortalPreferenceImpl(); pp.setKey("key"); pp.setValues(Lists.<String>newLinkedList()); MongoDbPortalPreference converted; MongoDbPortalPreference mpp = new MongoDbPortalPreference(); mpp.setKey("carol"); mpp.setValues(Lists.<String>newLinkedList()); converted = converter.convert(pp); assertThat(converted.getKey(), is(equalTo("key"))); assertTrue(converted.getValues().isEmpty()); converted = converter.convert(mpp); assertThat(converted.getKey(), is(equalTo("carol"))); assertTrue(converted.getValues().isEmpty()); assertThat(converted, is(sameInstance(mpp))); assertThat(converted.getId(), is(notNull())); }