Search in sources :

Example 51 with AbstractBestPracticeResult

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

the class DuplicateContentImplTest method runTest_resTypeIsPass.

@Test
public void runTest_resTypeIsPass() {
    List<CacheEntry> duplicateContent = new ArrayList<CacheEntry>();
    for (int i = 0; i < 2; i++) {
        duplicateContent.add(entryArray[i]);
    }
    Mockito.when(cacheAnalysis.getDuplicateContentBytes()).thenReturn(value);
    Mockito.when(cacheAnalysis.getDuplicateContentBytesRatio()).thenReturn(0.1);
    Mockito.when(cacheAnalysis.getTotalBytesDownloaded()).thenReturn(value);
    Mockito.when(cacheAnalysis.getDuplicateContent()).thenReturn(duplicateContent);
    Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis);
    duplicateContentImpl = (DuplicateContentImpl) context.getBean("duplicateContent");
    AbstractBestPracticeResult testResult = duplicateContentImpl.runTest(tracedata);
    assertEquals(BPResultType.PASS, testResult.getResultType());
}
Also used : ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 52 with AbstractBestPracticeResult

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

the class FileCompressionImplTest method runTest_1.

/**
 * tests for a FAIL
 */
@Test
public void runTest_1() {
    tracedata = mock(PacketAnalyzerResult.class);
    session = mock(Session.class);
    sessionlist = new ArrayList<Session>();
    sessionlist.add(session);
    req = mock(HttpRequestResponseInfo.class);
    req.setDirection(HttpDirection.REQUEST);
    List<HttpRequestResponseInfo> reqList = new ArrayList<HttpRequestResponseInfo>();
    reqList.add(req);
    Mockito.when(session.getRequestResponseInfo()).thenReturn(reqList);
    Mockito.when(session.getDomainName()).thenReturn("mock.domain.name");
    Mockito.when(tracedata.getSessionlist()).thenReturn(sessionlist);
    // HttpDirection.REQUEST
    Mockito.when(req.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(req.getObjName()).thenReturn("mock.obj.name");
    // condition 1
    Mockito.when(req.getPacketDirection()).thenReturn(PacketDirection.DOWNLINK);
    // condition 2
    Mockito.when(req.getContentLength()).thenReturn(1001024);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("message/http");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult result = FileCompressionImpl.runTest(tracedata);
    result = FileCompressionImpl.runTest(tracedata);
    assertEquals("Sending compressed files over the network will speed delivery, and unzipping files on a device is a very low overhead operation. Ensure that all your text files are compressed while being sent over the network.", result.getAboutText());
    assertEquals("FILE_COMPRESSION", result.getBestPracticeType().toString());
    assertEquals("Text File Compression", result.getDetailTitle());
    assertEquals("File Download: Text File Compression", result.getOverviewTitle());
    assertEquals(ApplicationConfig.getInstance().getAppShortName() + " detected 100% (977KB of 977KB) of text files were sent without compression. Adding compression will speed the delivery of your content to your customers. (Note: Only files larger than 850 bytes are flagged.)", result.getResultText());
    assertEquals("FAIL", result.getResultType().toString());
}
Also used : HttpRequestResponseInfo(com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Session(com.att.aro.core.packetanalysis.pojo.Session) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 53 with AbstractBestPracticeResult

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

the class UnnecessaryConnectionImplTest method runTest_resTypeIsPass.

@Test
public void runTest_resTypeIsPass() {
    when(burstArray[0].getBurstCategory()).thenReturn(BurstCategory.SCREEN_ROTATION);
    when(burstArray[0].getBeginTime()).thenReturn(1.0);
    when(burstArray[0].getEndTime()).thenReturn(5.0);
    when(burstArray[1].getBurstCategory()).thenReturn(BurstCategory.CPU);
    when(burstArray[1].getEndTime()).thenReturn(6.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burstArray[0]);
    burstCollection.add(burstArray[1]);
    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.PASS, result.getResultType());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 54 with AbstractBestPracticeResult

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

the class UnnecessaryConnectionImplTest method runTest_resTypeIsFail.

@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());
}
Also used : Burst(com.att.aro.core.packetanalysis.pojo.Burst) ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) Date(java.util.Date) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 55 with AbstractBestPracticeResult

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

the class UsingCacheImplTest method runTest_Fail.

@Test
public void runTest_Fail() {
    List<CacheEntry> diagnosisResults = new ArrayList<CacheEntry>();
    Mockito.when(entryArray[0].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_CACHABLE);
    Mockito.when(entryArray[0].hasCacheHeaders()).thenReturn(true);
    Mockito.when(entryArray[1].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_CACHE_MISSED);
    Mockito.when(entryArray[1].hasCacheHeaders()).thenReturn(false);
    Mockito.when(entryArray[1].getSessionFirstPacket()).thenReturn(pktInfo01);
    Mockito.when(entryArray[2].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP_PARTIALHIT);
    Mockito.when(entryArray[2].hasCacheHeaders()).thenReturn(true);
    Mockito.when(entryArray[3].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_NOT_EXPIRED_DUP);
    Mockito.when(entryArray[3].hasCacheHeaders()).thenReturn(true);
    Mockito.when(entryArray[4].getDiagnosis()).thenReturn(Diagnosis.CACHING_DIAG_OBJ_NOT_CHANGED_304);
    Mockito.when(entryArray[4].hasCacheHeaders()).thenReturn(false);
    for (int i = 0; i < 5; i++) {
        diagnosisResults.add(entryArray[i]);
    }
    Mockito.when(cacheAnalysis.getDiagnosisResults()).thenReturn(diagnosisResults);
    Mockito.when(tracedata.getCacheAnalysis()).thenReturn(cacheAnalysis);
    AbstractBestPracticeResult testResult = usingCacheImpl.runTest(tracedata);
    assertEquals(BPResultType.WARNING, testResult.getResultType());
}
Also used : ArrayList(java.util.ArrayList) AbstractBestPracticeResult(com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult) CacheEntry(com.att.aro.core.packetanalysis.pojo.CacheEntry) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

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