use of com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult in project VideoOptimzer by attdevsupport.
the class HtmlReportImplTest method reportGenerator_retunrIsTrue.
@Test
@Ignore
public void reportGenerator_retunrIsTrue() {
AccessingPeripheralResult access = new AccessingPeripheralResult();
access.setResultType(BPResultType.PASS);
CacheControlResult cache = new CacheControlResult();
cache.setResultType(BPResultType.FAIL);
List<AbstractBestPracticeResult> bpResults = new ArrayList<AbstractBestPracticeResult>();
bpResults.add(access);
bpResults.add(cache);
File tempFile = null;
try {
tempFile = folder.newFile("abc.html");
} catch (IOException e) {
e.printStackTrace();
}
if (tempFile != null) {
tempFile.deleteOnExit();
}
when(filereader.createFile(any(String.class))).thenReturn(tempFile);
AROTraceData results = new AROTraceData();
PacketAnalyzerResult analyzerResult = new PacketAnalyzerResult();
TraceDirectoryResult tracedirresult = new TraceDirectoryResult();
EnergyModel energyModel = new EnergyModel();
Statistic statistic = new Statistic();
statistic.setTotalByte(123);
statistic.setTotalHTTPSByte(123);
tracedirresult.setTraceDirectory("temp.txt");
analyzerResult.setTraceresult(tracedirresult);
analyzerResult.setEnergyModel(energyModel);
analyzerResult.setStatistic(statistic);
results.setAnalyzerResult(analyzerResult);
results.setBestPracticeResults(bpResults);
assertTrue(htmlReportImpl.reportGenerator("abc.html", results));
}
use of com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult in project VideoOptimzer by attdevsupport.
the class AccessingPeripheralImpl method runTest.
@Override
public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) {
AccessingPeripheralResult result = new AccessingPeripheralResult();
AbstractTraceResult traceResult = tracedata.getTraceresult();
TraceDirectoryResult trresult = null;
if (traceResult != null && traceResult instanceof TraceDirectoryResult) {
trresult = (TraceDirectoryResult) traceResult;
}
if (trresult != null && isPeripheralDataAvailable(trresult)) {
double activeGPSRatio = 0.0;
double activeBluetoothRatio = 0.0;
double activeCameraRatio = 0.0;
double gpsActiveDuration = 0.0;
double bluetoothActiveDuration = 0.0;
double cameraActiveDuration = 0.0;
double duration = 0.0;
boolean accessingPeripherals = true;
TimeRange timeRange = null;
if (tracedata.getFilter() != null) {
timeRange = tracedata.getFilter().getTimeRange();
}
if (tracedata.getTraceresult().getTraceResultType() == TraceResultType.TRACE_DIRECTORY) {
gpsActiveDuration = trresult.getGpsActiveDuration();
bluetoothActiveDuration = trresult.getBluetoothActiveDuration();
cameraActiveDuration = trresult.getCameraActiveDuration();
}
if (timeRange != null) {
duration = timeRange.getEndTime() - timeRange.getBeginTime();
} else {
duration = tracedata.getTraceresult().getTraceDuration();
}
activeGPSRatio = (gpsActiveDuration * 100) / duration;
activeBluetoothRatio = (bluetoothActiveDuration * 100) / duration;
activeCameraRatio = (cameraActiveDuration * 100) / duration;
result.setActiveBluetoothRatio(activeBluetoothRatio);
result.setActiveCameraRatio(activeCameraRatio);
result.setActiveGPSRatio(activeGPSRatio);
result.setActiveBluetoothDuration(bluetoothActiveDuration);
result.setActiveCameraDuration(cameraActiveDuration);
result.setActiveGPSDuration(gpsActiveDuration);
if (activeGPSRatio > PERIPHERAL_ACTIVE_LIMIT || activeBluetoothRatio > PERIPHERAL_ACTIVE_LIMIT || activeCameraRatio > PERIPHERAL_ACTIVE_LIMIT) {
accessingPeripherals = false;
}
String cameraPer = "0";
NumberFormat nfor = NumberFormat.getIntegerInstance();
if (cameraActiveDuration != 0.0) {
if (activeCameraRatio < 1.0) {
cameraPer = Util.percentageFormat(activeCameraRatio);
} else {
cameraPer = nfor.format(activeCameraRatio);
}
}
String key = "";
if (accessingPeripherals) {
result.setResultType(BPResultType.PASS);
key = this.textResultPass;
} else {
// ref. old analyzer give warning in this best practice
result.setResultType(BPResultType.WARNING);
key = this.textResults;
}
String text = MessageFormat.format(key, activeGPSRatio, activeBluetoothRatio, cameraPer);
result.setResultText(text);
result.setResultExcelText(MessageFormat.format(textExcelResults, result.getResultType().getDescription(), activeGPSRatio, activeBluetoothRatio, cameraPer));
} else {
result.setResultText(noData);
result.setResultType(BPResultType.NO_DATA);
result.setResultExcelText(BPResultType.NO_DATA.getDescription());
}
result.setAboutText(aboutText);
result.setDetailTitle(detailTitle);
result.setLearnMoreUrl(learnMoreUrl);
result.setOverviewTitle(overviewTitle);
result.setExportAllBTDesc(exportAllBTDesc);
result.setExportAllCamDesc(exportAllCamDesc);
result.setExportAllGPSDesc(exportAllGPSDesc);
return result;
}
Aggregations