### Question:
ProjectService implements SearchableEntityService { public SearchResponse findByTypeSpecificCode(String codeName, String codeValue) { try { return searchClientService.performFilterByOneField(SEARCH_INDEX_NAME, SEARCH_INDEX_TYPE, FIELD_TYPE_SPECIFIC_CODE + "." + codeName, codeValue); } catch (SearchIndexMissingException e) { return null; } }  @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 findByTypeSpecificCode() throws InterruptedException { Client client = prepareESClientForUnitTest("ProjectServiceTest_6"); ProjectService tested = getTested(client); try { indexDelete(ProjectService.SEARCH_INDEX_NAME); { SearchResponse sr = tested.findByTypeSpecificCode(CODE_NAME_1, "test"); Assert.assertNull(sr); } indexCreate(ProjectService.SEARCH_INDEX_NAME); { SearchResponse sr = tested.findByTypeSpecificCode(CODE_NAME_2, "test"); Assert.assertEquals(0, sr.getHits().getTotalHits()); } indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "10", "{\"code\":\"test1\"" + ", \"type_specific_code\" : {\"code_type1\":\"test\",\"code_type2\":[\"ct2_1_1\",\"ct2_1_2\"]}" + "}"); indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "20", "{\"code\":\"test2\"" + ", \"type_specific_code\" : {\"code_type1\":\"ct1_2\",\"code_type2\":[\"ct2_2_1\",\"test\"]}" + "}"); indexInsertDocument(ProjectService.SEARCH_INDEX_NAME, ProjectService.SEARCH_INDEX_TYPE, "30", "{\"code\":\"test3\"" + ", \"type_specific_code\" : {\"code_type1\":\"ct1_3\",\"code_type2\":[\"ct2_3_1\",\"test_3_2\"]}" + "}"); indexFlushAndRefresh(ProjectService.SEARCH_INDEX_NAME); { SearchResponse sr = tested.findByTypeSpecificCode(CODE_NAME_1, "test"); Assert.assertEquals(1, sr.getHits().getTotalHits()); Assert.assertEquals("10", sr.getHits().getHits()[0].getId()); sr = tested.findByTypeSpecificCode(CODE_NAME_2, "test"); Assert.assertEquals(1, sr.getHits().getTotalHits()); Assert.assertEquals("20", sr.getHits().getHits()[0].getId()); sr = tested.findByTypeSpecificCode(CODE_NAME_2, "te"); Assert.assertEquals(0, sr.getHits().getTotalHits()); } } finally { indexDelete(ProjectService.SEARCH_INDEX_NAME); finalizeESClientForUnitTest(); } }