Search in sources :

Example 16 with AbstractBestPracticeResult

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

the class ScreenRotationImplTest method runTest_resIsNoErr_Pass.

@Test
public void runTest_resIsNoErr_Pass() {
    tracedata = Mockito.mock(PacketAnalyzerResult.class);
    burstCollectionAnalysisData = Mockito.mock(BurstCollectionAnalysisData.class);
    burst01 = mock(Burst.class);
    Mockito.when(burst01.getBurstCategory()).thenReturn(BurstCategory.UNKNOWN);
    Mockito.when(burst01.getBeginTime()).thenReturn(1.0);
    List<Burst> burstCollection = new ArrayList<Burst>();
    burstCollection.add(burst01);
    Mockito.when(tracedata.getBurstCollectionAnalysisData()).thenReturn(burstCollectionAnalysisData);
    Mockito.when(burstCollectionAnalysisData.getBurstCollection()).thenReturn(burstCollection);
    screenRotationImpl = (ScreenRotationImpl) context.getBean("screenRotation");
    AbstractBestPracticeResult result = screenRotationImpl.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) BurstCollectionAnalysisData(com.att.aro.core.packetanalysis.pojo.BurstCollectionAnalysisData) PacketAnalyzerResult(com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 17 with AbstractBestPracticeResult

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

the class ScriptsImplTest method runTest_resIsPass.

@Test
public void runTest_resIsPass() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(false);
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    value.add(httpRequestInfo03);
    value.add(httpRequestInfo04);
    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);
    scriptImpl.setHttpRequestResponseHelper(reqhelper);
    AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
    scriptImpl.setHttpRequestResponseHelper(null);
    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 18 with AbstractBestPracticeResult

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

the class ScriptsImplTest method getContentStringIsNullThrowException.

@Test
public void getContentStringIsNullThrowException() throws Exception {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn(null);
    Mockito.when(httpRequestInfo02.getContentLength()).thenReturn(0);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo03.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(3);
    Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(true);
    Mockito.when(reqhelper.getContentString(any(HttpRequestResponseInfo.class), any(Session.class))).thenThrow(new Exception());
    List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
    value.add(httpRequestInfo01);
    value.add(httpRequestInfo02);
    value.add(httpRequestInfo03);
    value.add(httpRequestInfo04);
    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);
    scriptImpl.setHttpRequestResponseHelper(reqhelper);
    AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
    scriptImpl.setHttpRequestResponseHelper(null);
    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 19 with AbstractBestPracticeResult

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

the class ScriptsImplTest method runTest_resIsFail.

@Test
public void runTest_resIsFail() {
    Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo01.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(1);
    Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
    Mockito.when(httpRequestInfo02.getContentType()).thenReturn(null);
    Mockito.when(httpRequestInfo02.getContentLength()).thenReturn(0);
    Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo03.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(2);
    Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE);
    Mockito.when(httpRequestInfo04.getContentType()).thenReturn("html");
    Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(3);
    Mockito.when(reqhelper.isHtml(any(String.class))).thenReturn(true);
    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);
    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);
    scriptImpl.setHttpRequestResponseHelper(reqhelper);
    AbstractBestPracticeResult testResult = scriptImpl.runTest(tracedata);
    scriptImpl.setHttpRequestResponseHelper(null);
    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 20 with AbstractBestPracticeResult

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

the class FileCompressionImplTest method runTest_2.

/**
 * tests for PASS
 */
@Test
public void runTest_2() {
    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(1);
    // condition 3 & 4
    // "application/ecmascript" "application/json" "application/javascript" "text/javascript" "message/http"
    Mockito.when(req.getContentType()).thenReturn("application/.something.xml");
    Mockito.when(req.getContentEncoding()).thenReturn("identity");
    FileCompressionImpl = (FileCompressionImpl) context.getBean("textFileCompression");
    AbstractBestPracticeResult 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 0 text files above 850 bytes 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("PASS", 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)

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