@Test public void runTest_resTypeIsFail() { List<CacheEntry> duplicateContent = new ArrayList<CacheEntry>(); for (int i = 0; i < 5; i++) { duplicateContent.add(entryArray[i]); } Mockito.when(cacheAnalysis.getDuplicateContentBytes()).thenReturn(value); Mockito.when(cacheAnalysis.getDuplicateContentBytesRatio()).thenReturn(1.0); Mockito.when(cacheAnalysis.getDuplicateContent()).thenReturn(duplicateContent); Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis); duplicateContentImpl = (DuplicateContentImpl) context.getBean("duplicateContent"); AbstractBestPracticeResult testResult = duplicateContentImpl.runTest(tracedata); assertEquals(BPResultType.FAIL, testResult.getResultType()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { DuplicateContentResult result = new DuplicateContentResult(); CacheAnalysis cacheAnalysis = tracedata.getCacheAnalysis(); result.setDuplicateContentBytes(cacheAnalysis.getDuplicateContentBytes()); result.setDuplicateContentBytesRatio(cacheAnalysis.getDuplicateContentBytesRatio()); int duplicateContentsize = cacheAnalysis.getDuplicateContent().size(); result.setDuplicateContentsize(duplicateContentsize); int totalTCPBytes = 0; if (tracedata.getStatistic() != null) { totalTCPBytes = tracedata.getStatistic().getTotalTCPBytes(); } result.setTotalContentBytes(totalTCPBytes); List<CacheEntry> caUResult = cacheAnalysis.getDuplicateContent(); result.setDuplicateContentList(caUResult); int duplicateContentSizeOfUniqueItems = caUResult.size(); result.setDuplicateContentSizeOfUniqueItems(duplicateContentSizeOfUniqueItems); if (duplicateContentsize <= 3) { result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } else { result.setResultType(BPResultType.FAIL); DecimalFormat numf = new DecimalFormat("#.##"); NumberFormat numf2 = NumberFormat.getInstance(); numf2.setMaximumFractionDigits(3); String text = MessageFormat.format(textResults, numf.format(result.getDuplicateContentBytes() * 100.0 / result.getTotalContentBytes()), result.getDuplicateContentSizeOfUniqueItems(), numf2.format(((double) result.getDuplicateContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR), numf2.format(((double) result.getTotalContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR)); result.setResultText(text); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllFiles(exportAllFiles); result.setExportAllPct(exportAllPct); result.setStaticsUnitsMbytes(staticsUnitsMbytes); return result; }
DuplicateContentImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { DuplicateContentResult result = new DuplicateContentResult(); CacheAnalysis cacheAnalysis = tracedata.getCacheAnalysis(); result.setDuplicateContentBytes(cacheAnalysis.getDuplicateContentBytes()); result.setDuplicateContentBytesRatio(cacheAnalysis.getDuplicateContentBytesRatio()); int duplicateContentsize = cacheAnalysis.getDuplicateContent().size(); result.setDuplicateContentsize(duplicateContentsize); int totalTCPBytes = 0; if (tracedata.getStatistic() != null) { totalTCPBytes = tracedata.getStatistic().getTotalTCPBytes(); } result.setTotalContentBytes(totalTCPBytes); List<CacheEntry> caUResult = cacheAnalysis.getDuplicateContent(); result.setDuplicateContentList(caUResult); int duplicateContentSizeOfUniqueItems = caUResult.size(); result.setDuplicateContentSizeOfUniqueItems(duplicateContentSizeOfUniqueItems); if (duplicateContentsize <= 3) { result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } else { result.setResultType(BPResultType.FAIL); DecimalFormat numf = new DecimalFormat("#.##"); NumberFormat numf2 = NumberFormat.getInstance(); numf2.setMaximumFractionDigits(3); String text = MessageFormat.format(textResults, numf.format(result.getDuplicateContentBytes() * 100.0 / result.getTotalContentBytes()), result.getDuplicateContentSizeOfUniqueItems(), numf2.format(((double) result.getDuplicateContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR), numf2.format(((double) result.getTotalContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR)); result.setResultText(text); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllFiles(exportAllFiles); result.setExportAllPct(exportAllPct); result.setStaticsUnitsMbytes(staticsUnitsMbytes); return result; } }
DuplicateContentImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { DuplicateContentResult result = new DuplicateContentResult(); CacheAnalysis cacheAnalysis = tracedata.getCacheAnalysis(); result.setDuplicateContentBytes(cacheAnalysis.getDuplicateContentBytes()); result.setDuplicateContentBytesRatio(cacheAnalysis.getDuplicateContentBytesRatio()); int duplicateContentsize = cacheAnalysis.getDuplicateContent().size(); result.setDuplicateContentsize(duplicateContentsize); int totalTCPBytes = 0; if (tracedata.getStatistic() != null) { totalTCPBytes = tracedata.getStatistic().getTotalTCPBytes(); } result.setTotalContentBytes(totalTCPBytes); List<CacheEntry> caUResult = cacheAnalysis.getDuplicateContent(); result.setDuplicateContentList(caUResult); int duplicateContentSizeOfUniqueItems = caUResult.size(); result.setDuplicateContentSizeOfUniqueItems(duplicateContentSizeOfUniqueItems); if (duplicateContentsize <= 3) { result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } else { result.setResultType(BPResultType.FAIL); DecimalFormat numf = new DecimalFormat("#.##"); NumberFormat numf2 = NumberFormat.getInstance(); numf2.setMaximumFractionDigits(3); String text = MessageFormat.format(textResults, numf.format(result.getDuplicateContentBytes() * 100.0 / result.getTotalContentBytes()), result.getDuplicateContentSizeOfUniqueItems(), numf2.format(((double) result.getDuplicateContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR), numf2.format(((double) result.getTotalContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR)); result.setResultText(text); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllFiles(exportAllFiles); result.setExportAllPct(exportAllPct); result.setStaticsUnitsMbytes(staticsUnitsMbytes); return result; }  }
DuplicateContentImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { DuplicateContentResult result = new DuplicateContentResult(); CacheAnalysis cacheAnalysis = tracedata.getCacheAnalysis(); result.setDuplicateContentBytes(cacheAnalysis.getDuplicateContentBytes()); result.setDuplicateContentBytesRatio(cacheAnalysis.getDuplicateContentBytesRatio()); int duplicateContentsize = cacheAnalysis.getDuplicateContent().size(); result.setDuplicateContentsize(duplicateContentsize); int totalTCPBytes = 0; if (tracedata.getStatistic() != null) { totalTCPBytes = tracedata.getStatistic().getTotalTCPBytes(); } result.setTotalContentBytes(totalTCPBytes); List<CacheEntry> caUResult = cacheAnalysis.getDuplicateContent(); result.setDuplicateContentList(caUResult); int duplicateContentSizeOfUniqueItems = caUResult.size(); result.setDuplicateContentSizeOfUniqueItems(duplicateContentSizeOfUniqueItems); if (duplicateContentsize <= 3) { result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } else { result.setResultType(BPResultType.FAIL); DecimalFormat numf = new DecimalFormat("#.##"); NumberFormat numf2 = NumberFormat.getInstance(); numf2.setMaximumFractionDigits(3); String text = MessageFormat.format(textResults, numf.format(result.getDuplicateContentBytes() * 100.0 / result.getTotalContentBytes()), result.getDuplicateContentSizeOfUniqueItems(), numf2.format(((double) result.getDuplicateContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR), numf2.format(((double) result.getTotalContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR)); result.setResultText(text); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllFiles(exportAllFiles); result.setExportAllPct(exportAllPct); result.setStaticsUnitsMbytes(staticsUnitsMbytes); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
DuplicateContentImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { DuplicateContentResult result = new DuplicateContentResult(); CacheAnalysis cacheAnalysis = tracedata.getCacheAnalysis(); result.setDuplicateContentBytes(cacheAnalysis.getDuplicateContentBytes()); result.setDuplicateContentBytesRatio(cacheAnalysis.getDuplicateContentBytesRatio()); int duplicateContentsize = cacheAnalysis.getDuplicateContent().size(); result.setDuplicateContentsize(duplicateContentsize); int totalTCPBytes = 0; if (tracedata.getStatistic() != null) { totalTCPBytes = tracedata.getStatistic().getTotalTCPBytes(); } result.setTotalContentBytes(totalTCPBytes); List<CacheEntry> caUResult = cacheAnalysis.getDuplicateContent(); result.setDuplicateContentList(caUResult); int duplicateContentSizeOfUniqueItems = caUResult.size(); result.setDuplicateContentSizeOfUniqueItems(duplicateContentSizeOfUniqueItems); if (duplicateContentsize <= 3) { result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } else { result.setResultType(BPResultType.FAIL); DecimalFormat numf = new DecimalFormat("#.##"); NumberFormat numf2 = NumberFormat.getInstance(); numf2.setMaximumFractionDigits(3); String text = MessageFormat.format(textResults, numf.format(result.getDuplicateContentBytes() * 100.0 / result.getTotalContentBytes()), result.getDuplicateContentSizeOfUniqueItems(), numf2.format(((double) result.getDuplicateContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR), numf2.format(((double) result.getTotalContentBytes()) / DUPLICATE_CONTENT_DENOMINATOR)); result.setResultText(text); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllFiles(exportAllFiles); result.setExportAllPct(exportAllPct); result.setStaticsUnitsMbytes(staticsUnitsMbytes); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }