Commit 2b642df2 authored by expectocode's avatar expectocode

Add PDF response test

parent e4afe5ee
Pipeline #113608 passed with stages
in 4 minutes and 11 seconds
......@@ -4,6 +4,7 @@ import org.junit.Test;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import java.io.PrintWriter;
......@@ -12,7 +13,7 @@ import static org.mockito.Mockito.*;
public class WebServerTest {
@Test
public void returnsCorrectFormat() throws Exception {
public void returnsMarkdownResult() throws Exception {
HttpServletRequest mockedReq = mock(HttpServletRequest.class);
HttpServletResponse mockedResp = mock(HttpServletResponse.class);
......@@ -33,4 +34,26 @@ public class WebServerTest {
}
}
\ No newline at end of file
@Test
public void returnsPdfResult() throws Exception {
HttpServletRequest mockedReq = mock(HttpServletRequest.class);
HttpServletResponse mockedResp = mock(HttpServletResponse.class);
ServletOutputStream mockedOutput = mock(ServletOutputStream.class);
when(mockedReq.getParameter("q")).thenReturn("test search query");
when(mockedReq.getParameter("format")).thenReturn("PDF");
when(mockedResp.getOutputStream()).thenReturn(mockedOutput);
WebServer.Website testSite = new WebServer.Website();
testSite.doGet(mockedReq, mockedResp);
verify(mockedResp, times(1)).setContentType("application/pdf");
verify(mockedResp, times(1)).setHeader("Content-Disposition", "attachment;filename=result.pdf");
verify(mockedResp, times(1)).getOutputStream();
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment