### Question:
TBRDaoESImp extends BaseDaoESImp implements TBRDao { @Override public double getTBRRatio_PI_TCs(List<TargetingChannel> tcs) throws IOException { if (CommonUtil.isEmpty(tcs)) { return 0; } BoolQueryBuilder boolQueryBuilder = null; for (TargetingChannel tc : tcs) { if (boolQueryBuilder == null) { boolQueryBuilder = createQueryForMultiValuePlusAgeGender(tc); } else { BoolQueryBuilder boolQueryBuilder1 = createQueryForMultiValuePlusAgeGender(tc); boolQueryBuilder.must(boolQueryBuilder1); } } double v1 = getSumForQuery(boolQueryBuilder); if (v1 == 0) { return 0; } boolQueryBuilder = null; for (TargetingChannel tc : tcs) { if (boolQueryBuilder == null) { boolQueryBuilder = createQueryForAgeGender(tc); } else { BoolQueryBuilder boolQueryBuilder1 = createQueryForAgeGender(tc); boolQueryBuilder.must(boolQueryBuilder1); } } double v2 = getSumForQuery(boolQueryBuilder); if (v2 == 0) { LOGGER.info("Inconsistent data in TBR"); v2 = 1; } return v1 / v2; } TBRDaoESImp(Properties properties); @Override double getTBRRatio(TargetingChannel targetingChannel); @Override double getTBRRatio_PI_BNs_DOT_qBAR(List<TargetingChannel> bns, TargetingChannel q); @Override double getTBRRatio_PI_TCs(List<TargetingChannel> tcs);  }### Answer:
@Test public void getTBRRatio_PI_TCs() throws IOException { TBRDaoESImp tbrDaoImp = new TBRDaoESImp(DEF_PROP); tbrDaoImp.setESClient(DEF_ESCLI); List<TargetingChannel> tcs = new ArrayList(); TargetingChannel tc1 = new TargetingChannel(), tc2 = new TargetingChannel(), tc3 = new TargetingChannel(); tc1.setA(Arrays.asList("2")); tc1.setG(Arrays.asList("g_m")); tc2.setA(Arrays.asList("3")); tc3.setR(Arrays.asList("456")); tcs.add(tc1); tcs.add(tc2); tcs.add(tc3); double res = tbrDaoImp.getTBRRatio_PI_TCs(tcs); assertEquals(0D, res, 0); res = tbrDaoImp.getTBRRatio_PI_TCs(Arrays.asList(new TargetingChannel())); assertEquals(1D, res, 0); res = tbrDaoImp.getTBRRatio_PI_TCs(new ArrayList()); assertEquals(0D, res, 0); }