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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations