FeatureRepositoryCustomImpl implements FeatureRepositoryCustom { @Override public void delete(String idApplication, String idFeature) { Feature feature=mongoTemplate.findById(idFeature, Feature.class, collectionName+idApplication); mongoTemplate.remove(feature, collectionName+idApplication); }  @Override Feature save(String idApplication, Feature feature); @Override void delete(String idApplication, String idFeature); @Override Feature findByApplicationIdentifierAndId(String idApplication, String idFeature); @Override Collection<Feature> searchIDAppAndQuery(String idApplication,String query,Integer pageIndex, Integer pageSize); @Override Collection<Feature> searchIDAppAndQuery(String idApplication,String query,Integer pageIndex, Integer pageSize, String orderField, String order);  }
@Test public void deleteFeatureTest(){ String idApplication = "1"; String idFeature = "2"; Feature feature=Mockito.mock(Feature.class); Mockito.when(mongoTemplate.findById(idFeature,Feature.class,collectionName+idApplication)).thenReturn(feature); featureRepository.delete(idApplication, idFeature); Mockito.verify(mongoTemplate).findById(idFeature,Feature.class,collectionName+idApplication); Mockito.verify(mongoTemplate).remove(feature,collectionName+idApplication); }