### Question:
BaseDaoESImp implements BaseDao { protected void appendBase(BoolQueryBuilder boolQueryBuilder, List<String> list, List<String> notList, String field) { if (!CommonUtil.isEmpty(list) || !CommonUtil.isEmpty(notList)) { BoolQueryBuilder query = new BoolQueryBuilder(); if (list != null) { for (String item : list) { MatchPhraseQueryBuilder _query = new MatchPhraseQueryBuilder(field, item); query = query.should(_query); } boolQueryBuilder.must(query); } if (notList != null) { for (String item : notList) { MatchPhraseQueryBuilder _query = new MatchPhraseQueryBuilder(field, item); query = query.should(_query); } boolQueryBuilder.mustNot(query); } } } BaseDaoESImp();  BaseDaoESImp(Properties properties); static String getResourceAbsolutePath(String resourcePath); static String genericScriptReader(Path path); void setESClient(ESClient esclient); @Override BoolQueryBuilder createQueryForMultiValue(TargetingChannel targetingChannel); @Override BoolQueryBuilder createQueryForMultiValuePlusAgeGender(TargetingChannel targetingChannel); @Override BoolQueryBuilder createQueryForAgeGender(TargetingChannel targetingChannel); @Override Map<Double, BoolQueryBuilder> createQueryForSingleValuesWithRegionRatio(TargetingChannel targetingChannel); @Override BoolQueryBuilder createQueryForSingleValues(TargetingChannel targetingChannel); @Override BoolQueryBuilder createOrQueryForSingleValue(List<TargetingChannel> tcs); @Override BoolQueryBuilder createInvQueryForSingleValue(TargetingChannel targetingChannel); @Override BoolQueryBuilder createInvQuery(BoolQueryBuilder boolQueryBuilder); @Override BoolQueryBuilder createAndQueryForSingleValue(List<TargetingChannel> tcs); @Override BoolQueryBuilder createAndQueryForMultiValuePlusAgeGender(List<TargetingChannel> tcs); @Override BoolQueryBuilder createAndQueryForAgeGender(List<TargetingChannel> tcs); static final String ES_TYPE; static final String ES_PREDICTION_DOC_PREFIX; static final String ES_TBR_DOC_PREFIX; static final String ES_CHART_DOC_PREFIX; }### Answer:
@Test public void appendBase() { BoolQueryBuilder bqBldr = new BoolQueryBuilder(); List<String> list = new ArrayList(), noList = new ArrayList(); list.add("pdas"); noList.add("uninstalled"); String field = "field"; BaseDaoESImp bd = new BaseDaoESImp(); bd.appendBase(bqBldr, list, noList, field); String exp = "{\"bool\":{\"must\":[{\"bool\":{\"should\":[{\"match_phrase\":{\"field\":{\"query\":\"pdas\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}}," + "{\"match_phrase\":{\"field\":{\"query\":\"uninstalled\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}}]," + "\"adjust_pure_negative\":true,\"boost\":1.0}}],\"must_not\":[{\"bool\":{\"should\":[{\"match_phrase\":{\"field\":{\"query\":\"pdas\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}}," + "{\"match_phrase\":{\"field\":{\"query\":\"uninstalled\",\"slop\":0,\"zero_terms_query\":\"NONE\",\"boost\":1.0}}}],\"adjust_pure_negative\":true,\"boost\":1.0}}]," + "\"adjust_pure_negative\":true,\"boost\":1.0}}"; assertEquals(exp, bqBldr.toString().replaceAll("\\s+", "")); }