### Question:
ProjectService implements SearchableEntityService { @Override public void update(String id, Map<String, Object> entity) { entityService.update(id, entity); updateSearchIndex(id, entity); }  @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 update() { Client client = prepareESClientForUnitTest("ProjectServiceTest_3"); ProjectService tested = getTested(client); try { { Mockito.reset(tested.entityService); Map<String, Object> entity = new HashMap<String, Object>(); entity.put("name", "v1"); tested.update("1", entity); Mockito.verify(tested.entityService).update("1", entity); Map<String, Object> r = indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "1"); Assert.assertNotNull(r); Assert.assertEquals("v1", r.get("name")); } { Mockito.reset(tested.entityService); Map<String, Object> entity = new HashMap<String, Object>(); entity.put("name", "v2"); tested.update("2", entity); Mockito.verify(tested.entityService).update("2", entity); Map<String, Object> r = indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "2"); Assert.assertNotNull(r); Assert.assertEquals("v2", r.get("name")); r = indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "1"); Assert.assertNotNull(r); Assert.assertEquals("v1", r.get("name")); } { Mockito.reset(tested.entityService); Map<String, Object> entity = new HashMap<String, Object>(); entity.put("name", "v1_1"); tested.update("1", entity); Mockito.verify(tested.entityService).update("1", entity); Map<String, Object> r = indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "2"); Assert.assertNotNull(r); Assert.assertEquals("v2", r.get("name")); r = indexGetDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "1"); Assert.assertNotNull(r); Assert.assertEquals("v1_1", r.get("name")); } } finally { indexDelete(ProjectService.SEARCH_INDEX_NAME); finalizeESClientForUnitTest(); } }