### Question:
MongoDbPortalPreferenceRepository implements PortalPreferenceRepository { @Override public void delete(PortalPreference item) { template.remove(getByKey(item.getKey()), PREFERENCE_COLLECTION); }  @Override List<PortalPreference> getAll(); @Override List<PortalPreference> getLimitedList(int offset, int pageSize); @Override int getCountAll(); @Override PortalPreference getByKey(String key); @Override Class<? extends PortalPreference> getType(); @Override PortalPreference get(String id); @Override PortalPreference save(PortalPreference item); @Override void delete(PortalPreference item); void setTemplate(MongoOperations template); void setConverter(HydratingConverterFactory converter); static final Class<PortalPreferenceImpl> CLASS; }### Answer:
@Test public void delete_Valid(){ PortalPreference item = new PortalPreferenceImpl(); item.setKey("123"); PortalPreference found = new PortalPreferenceImpl(); expect(template.findOne(query(where("key").is("123")), preferenceRepository.CLASS, CollectionNames.PREFERENCE_COLLECTION)).andReturn((PortalPreferenceImpl)found); template.remove(found, CollectionNames.PREFERENCE_COLLECTION); expectLastCall(); replay(template); preferenceRepository.delete(item); verify(template); }