Search in sources :

Example 36 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.

the class DisplayNoneInCSSImplTest method runTest_ResultIsFail.

@Test
public void runTest_ResultIsFail() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo01.getAssocReqResp()).thenReturn(httpRequestInfo01);
    Mockito.when(httpRequestInfo01.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn("");
    Mockito.when(httpRequestInfo02.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo02.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo02.getAssocReqResp()).thenReturn(httpRequestInfo02);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo03.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo03.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo03.getAssocReqResp()).thenReturn(httpRequestInfo03);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo04.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo04.getAssocReqResp()).thenReturn(httpRequestInfo04);
    Mockito.when(httpRequestInfo05.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo05.getContentType()).thenReturn("text/css");
    Mockito.when(httpRequestInfo05.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo05.getObjName()).thenReturn(htmlString);
    Mockito.when(httpRequestInfo05.getAssocReqResp()).thenReturn(httpRequestInfo04);
    displayNoneInCSSImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    value.add(httpRequestInfo03);
    value.add(httpRequestInfo04);
    value.add(httpRequestInfo05);
    Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
    List<Session> sessionList = new ArrayList<Session>();
    Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
    sessionList.add(session01);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    AbstractBestPracticeResult testResult = displayNoneInCSSImpl.runTest(tracedata);
    assertEquals(BPResultType.FAIL, testResult.getResultType());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 37 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.

the class DisplayNoneInCSSImplTest method runTest_ResultIsPass.

@Test
public void runTest_ResultIsPass() {
    Mockito.when(httpRequestInfo06.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo06.getContentType()).thenReturn("text/html");
    Mockito.when(httpRequestInfo06.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo06.getAssocReqResp()).thenReturn(httpRequestInfo01);
    Mockito.when(httpRequestInfo06.getObjName()).thenReturn(htmlString);
    displayNoneInCSSImpl.setHttpRequestResponseHelper(reqhelper);
    try {
        Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenReturn(htmlString2);
    } catch (Exception e) {
        e.printStackTrace();
    }
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo06);
    Mockito.when(session03.getRequestResponseInfo()).thenReturn(value);
    List<Session> sessionList = new ArrayList<Session>();
    Mockito.when(session03.getDomainName()).thenReturn("www.google.com");
    sessionList.add(session03);
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
    AbstractBestPracticeResult testResult = displayNoneInCSSImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, testResult.getResultType());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 38 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.

the class VideoChunksPlot method refreshBPVideoResults.

private AROTraceData refreshBPVideoResults(AROTraceData model, AbstractBestPracticeResult bpResult, AbstractBestPracticeResult stallBPResult, AbstractBestPracticeResult bufferOccupancyBPResult) {
    removeList.clear();
    AROTraceData trace = model;
    for (AbstractBestPracticeResult bp : model.getBestPracticeResults()) {
        if (bp.getBestPracticeType() == BestPracticeType.STARTUP_DELAY) {
            updateAbstractBestPracticeParameters(bp, bpResult, model.getBestPracticeResults().indexOf(bp));
        } else if (stallBPResult != null && bp.getBestPracticeType() == BestPracticeType.VIDEO_STALL) {
            updateAbstractBestPracticeParameters(bp, stallBPResult, model.getBestPracticeResults().indexOf(bp));
        } else if (bufferOccupancyBPResult != null && bp.getBestPracticeType() == BestPracticeType.BUFFER_OCCUPANCY) {
            updateAbstractBestPracticeParameters(bp, bufferOccupancyBPResult, model.getBestPracticeResults().indexOf(bp));
        }
    }
    if (!removeList.isEmpty()) {
        for (int index : removeList.keySet()) {
            AbstractBestPracticeResult bp = removeList.get(index);
            trace.getBestPracticeResults().remove(bp);
            AbstractBestPracticeResult result = null;
            if (bp.getBestPracticeType() == BestPracticeType.STARTUP_DELAY) {
                result = bpResult;
            } else if (bp.getBestPracticeType() == BestPracticeType.VIDEO_STALL) {
                result = stallBPResult;
            } else if (bp.getBestPracticeType() == BestPracticeType.BUFFER_OCCUPANCY) {
                result = bufferOccupancyBPResult;
            }
            trace.getBestPracticeResults().add(index, result);
        }
    }
    return trace;
}
Also used : AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) AROTraceData(com.att.aro.core.pojo.AROTraceData)

Example 39 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.

the class ConnectionStatisticsChartPanel method generateDataForChart.

private ConnectionStatisticsInfo generateDataForChart() {
    ConnectionStatisticsInfo connectionStatisticsPojo = new ConnectionStatisticsInfo();
    double sessionTermPct = 0.0;
    int longBurstCount = 0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        int termSessions = 0;
        int properTermSessions = 0;
        for (Session tcpSession : traceDataModel.getAnalyzerResult().getSessionlist()) {
            if (!tcpSession.isUdpOnly()) {
                Termination termination = tcpSession.getSessionTermination();
                if (termination != null) {
                    ++termSessions;
                    if (termination.getSessionTerminationDelay() <= SESSION_TERMINATION_THRESHOLD) {
                        ++properTermSessions;
                    }
                }
            }
        }
        if (termSessions > 0) {
            sessionTermPct = 100.0 * properTermSessions / termSessions;
        }
        longBurstCount = traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getLongBurstCount();
    }
    connectionStatisticsPojo.setSessionTermPct(sessionTermPct);
    double tightlyCoupledTCPPct = 0.0;
    if (traceDataModel != null && traceDataModel.getAnalyzerResult() != null) {
        int burstSize = traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection().size();
        int periodicBurstCount = 0;
        for (Burst burstInfo : traceDataModel.getAnalyzerResult().getBurstCollectionAnalysisData().getBurstCollection()) {
            BurstCategory bCategory = burstInfo.getBurstCategory();
            if (bCategory == BurstCategory.PERIODICAL) {
                periodicBurstCount += 1;
            }
        }
        double nonPeriodicBurstPct = 100 - 100.0 * periodicBurstCount / burstSize;
        connectionStatisticsPojo.setNonPeriodicBurstPct(nonPeriodicBurstPct);
        int tightlyCoupledBurstCount = 0;
        for (AbstractBestPracticeResult abstractResult : traceDataModel.getBestPracticeResults()) {
            if (abstractResult.getBestPracticeType().equals(BestPracticeType.UNNECESSARY_CONNECTIONS) && abstractResult.getResultType() != BPResultType.NONE) {
                UnnecessaryConnectionResult unnecessaryConnt = (UnnecessaryConnectionResult) abstractResult;
                tightlyCoupledBurstCount = unnecessaryConnt.getTightlyCoupledBurstCount();
            }
        }
        tightlyCoupledTCPPct = 100.0 * tightlyCoupledBurstCount / burstSize;
        connectionStatisticsPojo.setTightlyCoupledTCPPct(tightlyCoupledTCPPct);
        double longBurstPct = 0.0;
        longBurstPct = 100.0 * longBurstCount / burstSize;
        connectionStatisticsPojo.setLongBurstPct(longBurstPct);
    }
    return connectionStatisticsPojo;
}
Also used : UnnecessaryConnectionResult(com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult) BurstCategory(com.att.aro.core.packetanalysis.pojo.BurstCategory) ConnectionStatisticsInfo(com.att.aro.ui.model.overview.ConnectionStatisticsInfo) Burst(com.att.aro.core.packetanalysis.pojo.Burst) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Termination(com.att.aro.core.packetanalysis.pojo.Termination) Session(com.att.aro.core.packetanalysis.pojo.Session)

Example 40 with AbstractBestPracticeResult

use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult 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)

Aggregations

AbstractBestPracticeResult (com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult)66 BaseTest (com.att.aro.core.BaseTest)47 ArrayList (java.util.ArrayList)47 Test (org.junit.Test)47 Session (com.att.aro.core.packetanalysis.pojo.Session)33 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)29 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)17 Burst (com.att.aro.core.packetanalysis.pojo.Burst)8 BestPracticeType (com.att.aro.core.bestpractice.pojo.BestPracticeType)6 CacheEntry (com.att.aro.core.packetanalysis.pojo.CacheEntry)6 List (java.util.List)6 IBestPractice (com.att.aro.core.bestpractice.IBestPractice)5 BPResultType (com.att.aro.core.bestpractice.pojo.BPResultType)4 UnnecessaryConnectionResult (com.att.aro.core.bestpractice.pojo.UnnecessaryConnectionResult)4 BufferOccupancyResult (com.att.aro.core.bestpractice.pojo.BufferOccupancyResult)3 TsharkException (com.att.aro.core.exception.TsharkException)3 BurstCollectionAnalysisData (com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData)3 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)3 AROTraceData (com.att.aro.core.pojo.AROTraceData)3 IOException (java.io.IOException)3