@Test public void runTest_resIsFail() { Date date = new Date(); Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE); Mockito.when(httpRequestInfo01.getFirstDataPacket()).thenReturn(pktInfo01); Mockito.when(httpRequestInfo01.getContentType()).thenReturn("image/"); 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.getFirstDataPacket()).thenReturn(pktInfo02); Mockito.when(httpRequestInfo03.getContentType()).thenReturn("image/"); Mockito.when(httpRequestInfo03.getContentLength()).thenReturn(2); Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE); Mockito.when(httpRequestInfo04.getFirstDataPacket()).thenReturn(pktInfo01); Mockito.when(httpRequestInfo04.getContentType()).thenReturn("image/"); Mockito.when(httpRequestInfo04.getContentLength()).thenReturn(3); Mockito.when(pktInfo01.getTimeStamp()).thenReturn((date.getTime()) / 1000 + 0.0); Mockito.when(pktInfo02.getTimeStamp()).thenReturn((date.getTime() / 1000) + 1.0); 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); AbstractBestPracticeResult testResult = spriteImageImpl.runTest(tracedata); assertEquals(BPResultType.FAIL, testResult.getResultType()); }
@Test public void runTest_resIsPass() { Mockito.when(httpRequestInfo01.getDirection()).thenReturn(HttpDirection.RESPONSE); Mockito.when(httpRequestInfo01.getContentType()).thenReturn("abc"); Mockito.when(httpRequestInfo01.getContentLength()).thenReturn(6145); Mockito.when(httpRequestInfo02.getDirection()).thenReturn(HttpDirection.REQUEST); Mockito.when(httpRequestInfo03.getDirection()).thenReturn(HttpDirection.RESPONSE); Mockito.when(httpRequestInfo04.getDirection()).thenReturn(HttpDirection.RESPONSE); 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); AbstractBestPracticeResult testResult = spriteImageImpl.runTest(tracedata); assertEquals(BPResultType.PASS, testResult.getResultType()); }