Search in sources :

Example 1 with AccessingPeripheralResult

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));
}
Also used : EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) ArrayList(java.util.ArrayList) IOException(java.io.IOException) AROTraceData(com.att.aro.core.pojo.AROTraceData) AccessingPeripheralResult(com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult) Statistic(com.att.aro.core.packetanalysis.pojo.Statistic) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) CacheControlResult(com.att.aro.core.bestpractice.pojo.CacheControlResult) File(java.io.File) Ignore(org.junit.Ignore) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Example 2 with AccessingPeripheralResult

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;
}
Also used : TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) AccessingPeripheralResult(com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult) AbstractTraceResult(com.att.aro.core.packetanalysis.pojo.AbstractTraceResult) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) NumberFormat(java.text.NumberFormat)

Aggregations

AccessingPeripheralResult (com.att.aro.core.bestpractice.pojo.AccessingPeripheralResult)2 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)2 BaseTest (com.att.aro.core.BaseTest)1 AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)1 CacheControlResult (com.att.aro.core.bestpractice.pojo.CacheControlResult)1 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)1 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)1 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)1 Statistic (com.att.aro.core.packetanalysis.pojo.Statistic)1 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)1 AROTraceData (com.att.aro.core.pojo.AROTraceData)1 File (java.io.File)1 IOException (java.io.IOException)1 NumberFormat (java.text.NumberFormat)1 ArrayList (java.util.ArrayList)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1