@Test public void runTest_resIsNoErrTypeIsPass(){ Mockito.when(burstCollectionAnalysisData.getTotalEnergy()).thenReturn(0.0); Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData); connClsImpl = (ConnectionClosingImpl)context.getBean("connectionClosing"); AbstractBestPracticeResult result = connClsImpl.runTest(tracedata); assertEquals(BPResultType.PASS, result.getResultType()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { double wastedBurstEnergy = 0.0; boolean conClosingProbPassed = true; double tcpControlEnergy = 0; double tcpControlEnergyRatio = 0; double largestEnergyTime = 0.0; double maxEnergy = 0.0; double currentEnergy; if(tracedata.getBurstCollectionAnalysisData().getTotalEnergy() > 0){ for(Burst burst : tracedata.getBurstCollectionAnalysisData().getBurstCollection()){ if(burst.getBurstCategory() == BurstCategory.TCP_PROTOCOL){ currentEnergy = burst.getEnergy(); wastedBurstEnergy += burst.getEnergy(); if (currentEnergy > maxEnergy) { maxEnergy = currentEnergy; largestEnergyTime = burst.getBeginTime(); } } } double percentageWasted = wastedBurstEnergy / tracedata.getBurstCollectionAnalysisData().getTotalEnergy(); conClosingProbPassed = percentageWasted < 0.05; tcpControlEnergy = wastedBurstEnergy; tcpControlEnergyRatio = percentageWasted; } ConnectionClosingResult result = new ConnectionClosingResult(); if(!conClosingProbPassed){ result.setResultType(BPResultType.FAIL); NumberFormat nfo = NumberFormat.getInstance(); nfo.setMaximumFractionDigits(1); String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), nfo.format(tcpControlEnergy), nfo.format(tcpControlEnergyRatio*100)); result.setResultText(text); }else{ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } result.setWastedBurstEnergy(wastedBurstEnergy); result.setConClosingProb(conClosingProbPassed); result.setTcpControlEnergy(tcpControlEnergy); result.setTcpControlEnergyRatio(tcpControlEnergyRatio); result.setLargestEnergyTime(largestEnergyTime); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllConnClosingDesc(exportAllConnClosingDesc); return result; }
ConnectionClosingImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { double wastedBurstEnergy = 0.0; boolean conClosingProbPassed = true; double tcpControlEnergy = 0; double tcpControlEnergyRatio = 0; double largestEnergyTime = 0.0; double maxEnergy = 0.0; double currentEnergy; if(tracedata.getBurstCollectionAnalysisData().getTotalEnergy() > 0){ for(Burst burst : tracedata.getBurstCollectionAnalysisData().getBurstCollection()){ if(burst.getBurstCategory() == BurstCategory.TCP_PROTOCOL){ currentEnergy = burst.getEnergy(); wastedBurstEnergy += burst.getEnergy(); if (currentEnergy > maxEnergy) { maxEnergy = currentEnergy; largestEnergyTime = burst.getBeginTime(); } } } double percentageWasted = wastedBurstEnergy / tracedata.getBurstCollectionAnalysisData().getTotalEnergy(); conClosingProbPassed = percentageWasted < 0.05; tcpControlEnergy = wastedBurstEnergy; tcpControlEnergyRatio = percentageWasted; } ConnectionClosingResult result = new ConnectionClosingResult(); if(!conClosingProbPassed){ result.setResultType(BPResultType.FAIL); NumberFormat nfo = NumberFormat.getInstance(); nfo.setMaximumFractionDigits(1); String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), nfo.format(tcpControlEnergy), nfo.format(tcpControlEnergyRatio*100)); result.setResultText(text); }else{ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } result.setWastedBurstEnergy(wastedBurstEnergy); result.setConClosingProb(conClosingProbPassed); result.setTcpControlEnergy(tcpControlEnergy); result.setTcpControlEnergyRatio(tcpControlEnergyRatio); result.setLargestEnergyTime(largestEnergyTime); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllConnClosingDesc(exportAllConnClosingDesc); return result; } }
ConnectionClosingImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { double wastedBurstEnergy = 0.0; boolean conClosingProbPassed = true; double tcpControlEnergy = 0; double tcpControlEnergyRatio = 0; double largestEnergyTime = 0.0; double maxEnergy = 0.0; double currentEnergy; if(tracedata.getBurstCollectionAnalysisData().getTotalEnergy() > 0){ for(Burst burst : tracedata.getBurstCollectionAnalysisData().getBurstCollection()){ if(burst.getBurstCategory() == BurstCategory.TCP_PROTOCOL){ currentEnergy = burst.getEnergy(); wastedBurstEnergy += burst.getEnergy(); if (currentEnergy > maxEnergy) { maxEnergy = currentEnergy; largestEnergyTime = burst.getBeginTime(); } } } double percentageWasted = wastedBurstEnergy / tracedata.getBurstCollectionAnalysisData().getTotalEnergy(); conClosingProbPassed = percentageWasted < 0.05; tcpControlEnergy = wastedBurstEnergy; tcpControlEnergyRatio = percentageWasted; } ConnectionClosingResult result = new ConnectionClosingResult(); if(!conClosingProbPassed){ result.setResultType(BPResultType.FAIL); NumberFormat nfo = NumberFormat.getInstance(); nfo.setMaximumFractionDigits(1); String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), nfo.format(tcpControlEnergy), nfo.format(tcpControlEnergyRatio*100)); result.setResultText(text); }else{ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } result.setWastedBurstEnergy(wastedBurstEnergy); result.setConClosingProb(conClosingProbPassed); result.setTcpControlEnergy(tcpControlEnergy); result.setTcpControlEnergyRatio(tcpControlEnergyRatio); result.setLargestEnergyTime(largestEnergyTime); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllConnClosingDesc(exportAllConnClosingDesc); return result; }  }
ConnectionClosingImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { double wastedBurstEnergy = 0.0; boolean conClosingProbPassed = true; double tcpControlEnergy = 0; double tcpControlEnergyRatio = 0; double largestEnergyTime = 0.0; double maxEnergy = 0.0; double currentEnergy; if(tracedata.getBurstCollectionAnalysisData().getTotalEnergy() > 0){ for(Burst burst : tracedata.getBurstCollectionAnalysisData().getBurstCollection()){ if(burst.getBurstCategory() == BurstCategory.TCP_PROTOCOL){ currentEnergy = burst.getEnergy(); wastedBurstEnergy += burst.getEnergy(); if (currentEnergy > maxEnergy) { maxEnergy = currentEnergy; largestEnergyTime = burst.getBeginTime(); } } } double percentageWasted = wastedBurstEnergy / tracedata.getBurstCollectionAnalysisData().getTotalEnergy(); conClosingProbPassed = percentageWasted < 0.05; tcpControlEnergy = wastedBurstEnergy; tcpControlEnergyRatio = percentageWasted; } ConnectionClosingResult result = new ConnectionClosingResult(); if(!conClosingProbPassed){ result.setResultType(BPResultType.FAIL); NumberFormat nfo = NumberFormat.getInstance(); nfo.setMaximumFractionDigits(1); String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), nfo.format(tcpControlEnergy), nfo.format(tcpControlEnergyRatio*100)); result.setResultText(text); }else{ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } result.setWastedBurstEnergy(wastedBurstEnergy); result.setConClosingProb(conClosingProbPassed); result.setTcpControlEnergy(tcpControlEnergy); result.setTcpControlEnergyRatio(tcpControlEnergyRatio); result.setLargestEnergyTime(largestEnergyTime); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllConnClosingDesc(exportAllConnClosingDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
ConnectionClosingImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { double wastedBurstEnergy = 0.0; boolean conClosingProbPassed = true; double tcpControlEnergy = 0; double tcpControlEnergyRatio = 0; double largestEnergyTime = 0.0; double maxEnergy = 0.0; double currentEnergy; if(tracedata.getBurstCollectionAnalysisData().getTotalEnergy() > 0){ for(Burst burst : tracedata.getBurstCollectionAnalysisData().getBurstCollection()){ if(burst.getBurstCategory() == BurstCategory.TCP_PROTOCOL){ currentEnergy = burst.getEnergy(); wastedBurstEnergy += burst.getEnergy(); if (currentEnergy > maxEnergy) { maxEnergy = currentEnergy; largestEnergyTime = burst.getBeginTime(); } } } double percentageWasted = wastedBurstEnergy / tracedata.getBurstCollectionAnalysisData().getTotalEnergy(); conClosingProbPassed = percentageWasted < 0.05; tcpControlEnergy = wastedBurstEnergy; tcpControlEnergyRatio = percentageWasted; } ConnectionClosingResult result = new ConnectionClosingResult(); if(!conClosingProbPassed){ result.setResultType(BPResultType.FAIL); NumberFormat nfo = NumberFormat.getInstance(); nfo.setMaximumFractionDigits(1); String text = MessageFormat.format(textResults, ApplicationConfig.getInstance().getAppShortName(), nfo.format(tcpControlEnergy), nfo.format(tcpControlEnergyRatio*100)); result.setResultText(text); }else{ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); } result.setWastedBurstEnergy(wastedBurstEnergy); result.setConClosingProb(conClosingProbPassed); result.setTcpControlEnergy(tcpControlEnergy); result.setTcpControlEnergyRatio(tcpControlEnergyRatio); result.setLargestEnergyTime(largestEnergyTime); result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllConnClosingDesc(exportAllConnClosingDesc); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }