@Test public void runTest_resTypeIsFail() { Date date = new Date(); for (int j = 0; j < 20; j++) { double timeLine = 0.0; when(burstArray[j].getBurstCategory()).thenReturn(BurstCategory.TCP_LOSS_OR_DUP); when(burstArray[j].getBeginTime()).thenReturn((date.getTime() / 1000) + 4.0 + timeLine); when(burstArray[j].getEndTime()).thenReturn((date.getTime() / 1000) + 10.0 + timeLine); when(burstArray[j + 1].getBurstCategory()).thenReturn(BurstCategory.PERIODICAL); when(burstArray[j + 1].getBeginTime()).thenReturn((date.getTime() / 1000) + 11.0 + timeLine); when(burstArray[j + 1].getEndTime()).thenReturn((date.getTime() / 1000) + 23.0 + timeLine); when(burstArray[j + 2].getBurstCategory()).thenReturn(BurstCategory.LONG); when(burstArray[j + 2].getBeginTime()).thenReturn((date.getTime() / 1000) + 25.0 + timeLine); when(burstArray[j + 2].getEndTime()).thenReturn((date.getTime() / 1000) + 40.0 + timeLine); when(burstArray[j + 3].getBurstCategory()).thenReturn(BurstCategory.CPU); when(burstArray[j + 3].getBeginTime()).thenReturn((date.getTime() / 1000) + 41.0 + timeLine); when(burstArray[j + 3].getEndTime()).thenReturn((date.getTime() / 1000) + 50.0 + timeLine); when(burstArray[j + 4].getBurstCategory()).thenReturn(BurstCategory.SERVER_NET_DELAY); when(burstArray[j + 4].getBeginTime()).thenReturn((date.getTime() / 1000) + 51.0 + timeLine); when(burstArray[j + 4].getEndTime()).thenReturn((date.getTime() / 1000) + 65.0 + timeLine); j = j + 5; timeLine = timeLine + 20.0; } List<Burst> burstCollection = new ArrayList<Burst>(); for (int i = 0; i < 26; i++) { burstCollection.add(burstArray[i]); } Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection); Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData); unConnImpl = (UnnecessaryConnectionImpl) context.getBean("unnecessaryConnection"); unConnImpl.runTest(tracedata); AbstractBestPracticeResult result = unConnImpl.runTest(tracedata); assertEquals(BPResultType.FAIL, result.getResultType()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { UnnecessaryConnectionResult result = new UnnecessaryConnectionResult(); ucEntryList = new ArrayList<UnnecessaryConnectionEntry>(); validateUnnecessaryConnections(tracedata.getBurstCollectionAnalysisData().getBurstCollection()); if(tightlyCoupledBurstCount < 4){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); String text = MessageFormat.format(this.textResults, this.tightlyCoupledBurstCount); result.setResultText(text); } result.setTightlyCoupledBurstCount(tightlyCoupledBurstCount); result.setTightlyCoupledBurstTime(tightlyCoupledBurstTime); result.setTightlyCoupledBurstsDetails(ucEntryList); result.setSelfTest(false); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllMultiConnDesc(exportAllMultiConnDesc); return result; }
UnnecessaryConnectionImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { UnnecessaryConnectionResult result = new UnnecessaryConnectionResult(); ucEntryList = new ArrayList<UnnecessaryConnectionEntry>(); validateUnnecessaryConnections(tracedata.getBurstCollectionAnalysisData().getBurstCollection()); if(tightlyCoupledBurstCount < 4){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); String text = MessageFormat.format(this.textResults, this.tightlyCoupledBurstCount); result.setResultText(text); } result.setTightlyCoupledBurstCount(tightlyCoupledBurstCount); result.setTightlyCoupledBurstTime(tightlyCoupledBurstTime); result.setTightlyCoupledBurstsDetails(ucEntryList); result.setSelfTest(false); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllMultiConnDesc(exportAllMultiConnDesc); return result; } }
UnnecessaryConnectionImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { UnnecessaryConnectionResult result = new UnnecessaryConnectionResult(); ucEntryList = new ArrayList<UnnecessaryConnectionEntry>(); validateUnnecessaryConnections(tracedata.getBurstCollectionAnalysisData().getBurstCollection()); if(tightlyCoupledBurstCount < 4){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); String text = MessageFormat.format(this.textResults, this.tightlyCoupledBurstCount); result.setResultText(text); } result.setTightlyCoupledBurstCount(tightlyCoupledBurstCount); result.setTightlyCoupledBurstTime(tightlyCoupledBurstTime); result.setTightlyCoupledBurstsDetails(ucEntryList); result.setSelfTest(false); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllMultiConnDesc(exportAllMultiConnDesc); return result; }  }
UnnecessaryConnectionImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { UnnecessaryConnectionResult result = new UnnecessaryConnectionResult(); ucEntryList = new ArrayList<UnnecessaryConnectionEntry>(); validateUnnecessaryConnections(tracedata.getBurstCollectionAnalysisData().getBurstCollection()); if(tightlyCoupledBurstCount < 4){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); String text = MessageFormat.format(this.textResults, this.tightlyCoupledBurstCount); result.setResultText(text); } result.setTightlyCoupledBurstCount(tightlyCoupledBurstCount); result.setTightlyCoupledBurstTime(tightlyCoupledBurstTime); result.setTightlyCoupledBurstsDetails(ucEntryList); result.setSelfTest(false); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllMultiConnDesc(exportAllMultiConnDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
UnnecessaryConnectionImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { UnnecessaryConnectionResult result = new UnnecessaryConnectionResult(); ucEntryList = new ArrayList<UnnecessaryConnectionEntry>(); validateUnnecessaryConnections(tracedata.getBurstCollectionAnalysisData().getBurstCollection()); if(tightlyCoupledBurstCount < 4){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); String text = MessageFormat.format(this.textResults, this.tightlyCoupledBurstCount); result.setResultText(text); } result.setTightlyCoupledBurstCount(tightlyCoupledBurstCount); result.setTightlyCoupledBurstTime(tightlyCoupledBurstTime); result.setTightlyCoupledBurstsDetails(ucEntryList); result.setSelfTest(false); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllMultiConnDesc(exportAllMultiConnDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }