use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.
the class FileCompressionImplTest method runTest_3.
/**
* tests for WARNING
*/
@Test
public void runTest_3() {
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(900);
// 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 100% (0KB of 0KB) 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("WARNING", result.getResultType().toString());
}
use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.
the class Http3xxCodeImplTest method runTest_resTypeIsPass.
@Test
public void runTest_resTypeIsPass() {
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
Mockito.when(httpRequestInfo01.getStatusCode()).thenReturn(200);
Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
List<Session> sessionList = new ArrayList<Session>();
sessionList.add(session01);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
http3xxCodeImpl = (Http3xxCodeImpl) context.getBean("http3xx");
AbstractBestPracticeResult result = http3xxCodeImpl.runTest(tracedata);
assertEquals(BPResultType.PASS, result.getResultType());
}
use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.
the class Http3xxCodeImplTest method runTest_resTypeIsFail.
@Test
public void runTest_resTypeIsFail() {
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
Mockito.when(httpRequestInfo01.getStatusCode()).thenReturn(304);
Mockito.when(httpRequestInfo01.getObjName()).thenReturn("");
Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST);
Mockito.when(httpRequestInfo02.getObjName()).thenReturn("");
Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo03.getScheme()).thenReturn(HttpRequestResponseInfo.HTTP_SCHEME);
Mockito.when(httpRequestInfo03.getStatusCode()).thenReturn(304);
Mockito.when(httpRequestInfo03.getObjName()).thenReturn("");
Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.REQUEST);
Mockito.when(httpRequestInfo04.getObjName()).thenReturn("");
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
value.add(httpRequestInfo03);
value.add(httpRequestInfo04);
Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
Mockito.when(session01.getDomainName()).thenReturn("www.google.com");
List<Session> sessionList = new ArrayList<Session>();
sessionList.add(session01);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
http3xxCodeImpl = (Http3xxCodeImpl) context.getBean("http3xx");
AbstractBestPracticeResult result = http3xxCodeImpl.runTest(tracedata);
assertEquals(BPResultType.FAIL, result.getResultType());
}
use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.
the class EmptyUrlImplTest 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);
emptyUrlImpl.setHttpReqResHelper(reqhelper);
AbstractBestPracticeResult testResult = emptyUrlImpl.runTest(tracedata);
assertEquals(BPResultType.PASS, testResult.getResultType());
}
use of com.att.aro.core.bestpractice.pojo.AbstractBestPracticeResult in project VideoOptimzer by attdevsupport.
the class EmptyUrlImplTest 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(htmlString2);
} 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);
emptyUrlImpl.setHttpReqResHelper(reqhelper);
AbstractBestPracticeResult testResult = emptyUrlImpl.runTest(tracedata);
assertEquals(BPResultType.FAIL, testResult.getResultType());
}
Aggregations