### Question:
ProjectService implements SearchableEntityService { @Override public void delete(String id) { entityService.delete(id); try { searchClientService.performDelete(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, id); } catch (SearchIndexMissingException e) { } }  @Override StreamingOutput getAll(Integer from, Integer size, String[] fieldsToRemove); @Override List<Map<String, Object>> getAll(); @Override Map<String, Object> get(String id); @Override String create(Map<String, Object> entity); @Override void create(String id, Map<String, Object> entity); @Override void update(String id, Map<String, Object> entity); @Override void delete(String id); SearchResponse findByCode(String code); SearchResponse findByTypeSpecificCode(String codeName, String codeValue); @Override ListRequest listRequestInit(); @Override ListRequest listRequestNext(ListRequest previous); @Override BulkRequestBuilder prepareBulkRequest(); @Override void updateSearchIndex(BulkRequestBuilder brb, String id, Map<String, Object> entity); @Override void deleteOldFromSearchIndex(Date timestamp); static final String FIELD_CODE; static final String FIELD_NAME; static final String FIELD_TYPE_SPECIFIC_CODE; static final String SEARCH_INDEX_NAME; static final String SEARCH_INDEX_TYPE; }### Answer:
@Test public void delete() throws InterruptedException { Client client = prepareESClientForUnitTest("ProjectServiceTest_4"); ProjectService tested = getTested(client); try { { Mockito.reset(tested.entityService); tested.delete("1"); Mockito.verify(tested.entityService).delete("1"); } indexDelete(ProjectService.SEARCH_INDEX_NAME); indexCreate(ProjectService.SEARCH_INDEX_NAME); Thread.sleep(100); { Mockito.reset(tested.entityService); tested.delete("1"); Mockito.verify(tested.entityService).delete("1"); } indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "10", "{\"name\":\"test1\",\"idx\":\"1\"}"); indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "20", "{\"name\":\"test2\",\"idx\":\"2\"}"); indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "30", "{\"name\":\"test3\",\"idx\":\"3\"}"); indexFlushAndRefresh(ProjectService.SEARCH_INDEX_NAME); { Mockito.reset(tested.entityService); tested.delete("10"); Mockito.verify(tested.entityService).delete("10"); Assert.assertNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "10")); Assert .assertNotNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "20")); Assert .assertNotNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "30")); Mockito.reset(tested.entityService); tested.delete("30"); Mockito.verify(tested.entityService).delete("30"); Assert.assertNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "10")); Assert .assertNotNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "20")); Assert.assertNull(indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "30")); } } finally { indexDelete(ProjectService.SEARCH_INDEX_NAME); finalizeESClientForUnitTest(); } }