@Test public void shouldNotBeAbleToLoadHttpMethodForGet() throws Exception { OauthAccessToken accessToken = new OauthAccessToken(); when(request.getEntity()).thenReturn(accessToken); HttpRequestBase httpMethod = new HttpGet(uri); try { engine.loadHttpMethod(request, httpMethod); Assert.fail(); } catch (ProcessingException e) { assertTrue(e.getMessage().contains("RESTEASY004565")); } }
@Test public void shouldBeAbleToLoadHttpMethodForPost() throws Exception { headers.setMediaType(MediaType.TEXT_PLAIN_TYPE); when(request.getDelegatingOutputStream()).thenReturn(new DelegatingOutputStream()); InputStream requestBody = getClass().getClassLoader().getResourceAsStream("mocks/pull_request_1.json"); ByteArrayOutputStream requestBodyOut = new ByteArrayOutputStream(); int bytes = IOUtils.copy(requestBody, requestBodyOut); when(request.getEntityStream()).thenReturn(requestBodyOut); OauthAccessToken accessToken = new OauthAccessToken(); when(request.getEntity()).thenReturn(accessToken); HttpPost post = new HttpPost(uri); engine.loadHttpMethod(request, post); verify(request).writeRequestBody(requestBodyOut); }