use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class ImageCompressionImpl method getEntryList.
private List<ImageCompressionEntry> getEntryList() {
String originalImage = "";
String midCompressedImagePath = "";
String logCompressedImagepath = "";
long lowQualityImgSize = 0L;
long midQualityImgSize = 0L;
long orgImageSize = 0L;
String imgExtn = "";
List<ImageCompressionEntry> entryList = new ArrayList<ImageCompressionEntry>();
for (Session session : packetResult.getSessionlist()) {
for (HttpRequestResponseInfo reqResp : session.getRequestResponseInfo()) {
if (reqResp.getDirection() == HttpDirection.RESPONSE && reqResp.getContentType() != null && reqResp.getContentType().contains("image/")) {
originalImage = ImageHelper.extractFullNameFromRRInfo(reqResp);
if ((!originalImage.isEmpty() && !(originalImage.contains(".jpeg") || originalImage.contains(".jpg"))) && reqResp.getContentType().contains("jpeg")) {
originalImage = Util.parseImageName(originalImage, reqResp);
}
int pos = originalImage.lastIndexOf(".");
if (pos != -1) {
imgExtn = originalImage.substring(pos + 1, originalImage.length());
if (Util.isJPG(new File(imageFolderPath + originalImage), imgExtn)) {
midCompressedImagePath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.MID.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
logCompressedImagepath = imageCompressionFolderPath + originalImage.substring(0, originalImage.lastIndexOf(".")) + Quality.LOW.getFileDesc() + originalImage.substring(originalImage.lastIndexOf("."), originalImage.length());
orgImageSize = new File(imageFolderPath + originalImage).length();
midQualityImgSize = new File(midCompressedImagePath).length();
lowQualityImgSize = new File(logCompressedImagepath).length();
if (midQualityImgSize > 0 && ((orgImageSize - midQualityImgSize) * 100 / orgImageSize >= 15) && lowQualityImgSize < orgImageSize) {
orginalImagesSize = orginalImagesSize + orgImageSize;
midQualImgsSize = midQualImgsSize + midQualityImgSize;
entryList.add(new ImageCompressionEntry(reqResp, session.getDomainName(), imageFolderPath + originalImage, Util.doubleFileSize(orgImageSize), Util.doubleFileSize(midQualityImgSize), Util.doubleFileSize(lowQualityImgSize)));
}
}
}
}
}
}
return entryList;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class TransmissionPrivateDataImpl method search.
/**
* searching method depends on the type of searching handler (exact keyword searching or pattern searching)
* @param sessions
* @param handler
* @param privateDataSet
* @return
*/
private List<TransmissionPrivateDataEntry> search(List<Session> sessions, ISearchingHandler handler, Map<String, String> privateDataSet) {
List<TransmissionPrivateDataEntry> entries = new LinkedList<>();
SearchingPattern pattern = getSearchingPattern(handler, privateDataSet);
if (pattern.isEmpty()) {
return entries;
}
for (Session session : sessions) {
SearchingContent content = getContent(session);
SearchingResult result = handler.search(pattern, content);
List<String> wordsFound = result.getWords();
List<String> types = result.getTypes();
for (int i = 0; i < wordsFound.size(); i++) {
entries.add(populateEntry(session, wordsFound.get(i), types.get(i)));
}
}
return entries;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class VideoConcurrentSessionImpl method manifestConcurrentSessions.
public List<VideoConcurrentSession> manifestConcurrentSessions(SortedMap<Double, VideoStream> videoStreamMap) {
List<VideoConcurrentSession> concurrentSessionList = new ArrayList<VideoConcurrentSession>();
if (MapUtils.isNotEmpty(videoStreamCollection)) {
for (VideoStream videoStream : videoStreamMap.values()) {
if (videoStream.isSelected()) {
ArrayList<Double> sessionStartTimes = new ArrayList<>();
ArrayList<Double> sessionEndTimes = new ArrayList<>();
ArrayList<Session> sessionList = new ArrayList<>();
SortedMap<String, VideoEvent> videoEventList = videoStream.getVideoEventMap();
for (VideoEvent veEntry : videoEventList.values()) {
Session session = veEntry.getSession();
if (!sessionList.contains(session)) {
sessionList.add(session);
sessionStartTimes.add(session.getSessionStartTime());
sessionEndTimes.add(session.getSessionEndTime());
}
}
VideoConcurrentSession videoConcurrentSession = findConcurrency(sessionStartTimes, sessionEndTimes);
if (videoConcurrentSession != null && videoConcurrentSession.getConcurrentSessionCount() > 0) {
videoConcurrentSession.setVideoName(videoStream.getManifest().getVideoName());
concurrentSessionList.add(videoConcurrentSession);
}
}
}
}
return concurrentSessionList;
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class EmptyUrlImplTest method runTest_resIsPass.
@Test
public void runTest_resIsPass() {
Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE);
Mockito.when(httpRequestInfo01.getContentType()).thenReturn("abc");
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(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);
emptyUrlImpl.setHttpReqResHelper(reqhelper);
AbstractBestPracticeResult testResult = emptyUrlImpl.runTest(tracedata);
assertEquals(BPResultType.PASS, testResult.getResultType());
}
use of com.att.aro.core.packetanalysis.pojo.Session in project VideoOptimzer by attdevsupport.
the class Http10UsageImplTest method runTest_resTypeIsFail.
@Test
public void runTest_resTypeIsFail() {
Mockito.when(httpRequestInfo01.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10);
Mockito.when(httpRequestInfo02.getVersion()).thenReturn(HttpRequestResponseInfo.HTTP10);
List<HttpRequestResponseInfo> value = new ArrayList<HttpRequestResponseInfo>();
value.add(httpRequestInfo01);
value.add(httpRequestInfo02);
Mockito.when(session01.getRequestResponseInfo()).thenReturn(value);
List<Session> sessionList = new ArrayList<Session>();
sessionList.add(session01);
Mockito.when(tracedata.getSessionlist()).thenReturn(sessionList);
httpUsageImpl = (Http10UsageImpl) context.getBean("http10Usage");
AbstractBestPracticeResult result = httpUsageImpl.runTest(tracedata);
assertEquals(BPResultType.WARNING, result.getResultType());
}
Aggregations