@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()); }
@Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http3xxCodeResult result = new Http3xxCodeResult(); SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>(); Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>(); List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>(); HttpRequestResponseInfo lastRequestObj = null; for(Session session: tracedata.getSessionlist()){ lastRequestObj = null; for(HttpRequestResponseInfo req: session.getRequestResponseInfo()){ if(req.getDirection() == HttpDirection.REQUEST){ lastRequestObj = req; } if(req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 300 && req.getStatusCode() < 400){ Integer code = req.getStatusCode(); Integer count = httpRedirectCounts3XX.get(code); if(count != null){ httpRedirectCounts3XX.put(code, count + 1); }else{ httpRedirectCounts3XX.put(code, 1); firstResMap.put(code, req); } httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName())); } } } if(httpRedirectCounts3XX.isEmpty()){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpError(exportAllHttpError); result.setHttp3xxResCode(httprescodelist); result.setHttpRedirectCounts3XX(httpRedirectCounts3XX); result.setFirstResMap(firstResMap); return result; }
Http3xxCodeImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http3xxCodeResult result = new Http3xxCodeResult(); SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>(); Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>(); List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>(); HttpRequestResponseInfo lastRequestObj = null; for(Session session: tracedata.getSessionlist()){ lastRequestObj = null; for(HttpRequestResponseInfo req: session.getRequestResponseInfo()){ if(req.getDirection() == HttpDirection.REQUEST){ lastRequestObj = req; } if(req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 300 && req.getStatusCode() < 400){ Integer code = req.getStatusCode(); Integer count = httpRedirectCounts3XX.get(code); if(count != null){ httpRedirectCounts3XX.put(code, count + 1); }else{ httpRedirectCounts3XX.put(code, 1); firstResMap.put(code, req); } httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName())); } } } if(httpRedirectCounts3XX.isEmpty()){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpError(exportAllHttpError); result.setHttp3xxResCode(httprescodelist); result.setHttpRedirectCounts3XX(httpRedirectCounts3XX); result.setFirstResMap(firstResMap); return result; } }
Http3xxCodeImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http3xxCodeResult result = new Http3xxCodeResult(); SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>(); Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>(); List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>(); HttpRequestResponseInfo lastRequestObj = null; for(Session session: tracedata.getSessionlist()){ lastRequestObj = null; for(HttpRequestResponseInfo req: session.getRequestResponseInfo()){ if(req.getDirection() == HttpDirection.REQUEST){ lastRequestObj = req; } if(req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 300 && req.getStatusCode() < 400){ Integer code = req.getStatusCode(); Integer count = httpRedirectCounts3XX.get(code); if(count != null){ httpRedirectCounts3XX.put(code, count + 1); }else{ httpRedirectCounts3XX.put(code, 1); firstResMap.put(code, req); } httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName())); } } } if(httpRedirectCounts3XX.isEmpty()){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpError(exportAllHttpError); result.setHttp3xxResCode(httprescodelist); result.setHttpRedirectCounts3XX(httpRedirectCounts3XX); result.setFirstResMap(firstResMap); return result; }  }
Http3xxCodeImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http3xxCodeResult result = new Http3xxCodeResult(); SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>(); Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>(); List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>(); HttpRequestResponseInfo lastRequestObj = null; for(Session session: tracedata.getSessionlist()){ lastRequestObj = null; for(HttpRequestResponseInfo req: session.getRequestResponseInfo()){ if(req.getDirection() == HttpDirection.REQUEST){ lastRequestObj = req; } if(req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 300 && req.getStatusCode() < 400){ Integer code = req.getStatusCode(); Integer count = httpRedirectCounts3XX.get(code); if(count != null){ httpRedirectCounts3XX.put(code, count + 1); }else{ httpRedirectCounts3XX.put(code, 1); firstResMap.put(code, req); } httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName())); } } } if(httpRedirectCounts3XX.isEmpty()){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpError(exportAllHttpError); result.setHttp3xxResCode(httprescodelist); result.setHttpRedirectCounts3XX(httpRedirectCounts3XX); result.setFirstResMap(firstResMap); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata); }
Http3xxCodeImpl implements IBestPractice { @Override public AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata) { Http3xxCodeResult result = new Http3xxCodeResult(); SortedMap<Integer, Integer> httpRedirectCounts3XX = new TreeMap<Integer, Integer>(); Map<Integer, HttpRequestResponseInfo> firstResMap = new HashMap<Integer, HttpRequestResponseInfo>(); List<HttpCode3xxEntry> httprescodelist = new ArrayList<HttpCode3xxEntry>(); HttpRequestResponseInfo lastRequestObj = null; for(Session session: tracedata.getSessionlist()){ lastRequestObj = null; for(HttpRequestResponseInfo req: session.getRequestResponseInfo()){ if(req.getDirection() == HttpDirection.REQUEST){ lastRequestObj = req; } if(req.getDirection() == HttpDirection.RESPONSE && HttpRequestResponseInfo.HTTP_SCHEME.equals(req.getScheme()) && req.getStatusCode() >= 300 && req.getStatusCode() < 400){ Integer code = req.getStatusCode(); Integer count = httpRedirectCounts3XX.get(code); if(count != null){ httpRedirectCounts3XX.put(code, count + 1); }else{ httpRedirectCounts3XX.put(code, 1); firstResMap.put(code, req); } httprescodelist.add(new HttpCode3xxEntry(req, lastRequestObj, session.getDomainName())); } } } if(httpRedirectCounts3XX.isEmpty()){ result.setResultType(BPResultType.PASS); result.setResultText(textResultPass); }else{ result.setResultType(BPResultType.FAIL); result.setResultText(Http3xx4xxHelper.createFailResult(httpRedirectCounts3XX, textResults, errorPlural, errorSingular)); } result.setAboutText(aboutText); result.setDetailTitle(detailTitle); result.setLearnMoreUrl(learnMoreUrl); result.setOverviewTitle(overviewTitle); result.setExportAllHttpError(exportAllHttpError); result.setHttp3xxResCode(httprescodelist); result.setHttpRedirectCounts3XX(httpRedirectCounts3XX); result.setFirstResMap(firstResMap); return result; }  @Override AbstractBestPracticeResult runTest(PacketAnalyzerResult tracedata);  }