HttpRequest httpRequest = mockRequest();
response = new ResponseImpl( httpRequest );
}
private HttpRequest mockRequest() throws MalformedURLException {
HttpRequest httpRequest = mock( HttpRequest.class );
HttpURLConnection connection = mock( HttpURLConnection.class );
when( connection.getURL() ).thenReturn( new URL( "http://test.com" ) );
when( httpRequest.getConnection() ).thenReturn( connection );
when( httpRequest.body() ).thenReturn( "test" );
when( httpRequest.code() ).thenReturn( 200 );
when( httpRequest.contentType() ).thenReturn( MediaType.TEXT_PLAIN.toString() );
HashMap<String, List<String>> headers = new HashMap<String, List<String>>();
List<String> values = new ArrayList<String>();
values.add( "test" );
headers.put( "test", values );
when( httpRequest.headers() ).thenReturn( headers );
return httpRequest;
}