### Question:
ContributorService implements SearchableEntityService { @Override public void deleteOldFromSearchIndex(Date timestamp) { searchClientService.performDeleteOldRecords(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, timestamp); }  @PostConstruct void init(); @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); String create(Map<String, Object> entity, boolean fireEvent); @Override void create(String id, Map<String, Object> entity); void create(String id, Map<String, Object> entity, boolean fireEvent); @Override void update(String id, Map<String, Object> entity); void update(String id, Map<String, Object> entity, boolean fireEvent); @Override void delete(String id); SearchResponse findByCode(String code); SearchResponse findByEmail(String email); SearchResponse findByName(String name, boolean exactMatch); SearchResponse findByTypeSpecificCode(String codeName, String codeValue); SearchResponse findByTypeSpecificCodeExistence(String codeName); Set<String> getRolesByTypeSpecificCode(String codeName, String username); static String createContributorId(String fullName, String email); static String extractContributorName(String contributorID); @SuppressWarnings("unchecked") static Set<String> extractRoles(Map<String, Object> fields); @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) String createOrUpdateFromProfile(ContributorProfile profile, String typeSpecificCodeField,
			String typeSpecificCodeValue); static String getContributorCode(Map<String, Object> contribStructure); @SuppressWarnings("unchecked") static String getContributorTypeSpecificCodeFirst(Map<String, Object> contribStructure,
			String contributorCodeType); Map<String, Object> changeContributorCode(String id, String code); Map<String, Object> mergeContributors(String idFrom, String idTo); @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 SEARCH_INDEX_NAME; static final String SEARCH_INDEX_TYPE; static final String FIELD_CODE; static final String FIELD_EMAIL; static final String FIELD_NAME; static final String FIELD_ROLES; static final String FIELD_HIRE_DATE; static final String FIELD_LEAVE_DATE; static final String FIELD_TYPE_SPECIFIC_CODE; }### Answer:
@Test public void deleteOldFromSearchIndex() throws InterruptedException { Client client = prepareESClientForUnitTest("ContributorServiceTest_22"); ContributorService tested = getTested(client); try { tested.init(); tested.create("10", prepareEntity("10")); tested.create("20", prepareEntity("20")); indexFlushAndRefresh(ContributorService.SEARCH_INDEX_NAME); Date timestamp = new Date(); tested.create("30", prepareEntity("30")); tested.create("40", prepareEntity("40")); tested.deleteOldFromSearchIndex(timestamp); indexFlushAndRefresh(ContributorService.SEARCH_INDEX_NAME); Assert.assertNull(indexGetDocument(ContributorService.SEARCH_INDEX_NAME, ContributorService.SEARCH_INDEX_TYPE, "10")); Assert.assertNull(indexGetDocument(ContributorService.SEARCH_INDEX_NAME, ContributorService.SEARCH_INDEX_TYPE, "20")); Assert.assertNotNull(indexGetDocument(ContributorService.SEARCH_INDEX_NAME, ContributorService.SEARCH_INDEX_TYPE, "30")); Assert.assertNotNull(indexGetDocument(ContributorService.SEARCH_INDEX_NAME, ContributorService.SEARCH_INDEX_TYPE, "40")); } finally { indexDelete(ContributorService.SEARCH_INDEX_NAME); finalizeESClientForUnitTest(); } }