@Test(expected = PagSeguroLibException.class) public void shouldThrowsErrorLib() throws Exception { when(httpClient.execute(any(HttpMethod.class), anyString(), anyMap(), any(HttpRequestBody.class))).thenThrow(new IOException()); sessionResource.create(); }
public CreatedSession create(String authorizationCode) { final RequestMap map = new RequestMap(); map.putString("authorizationCode", authorizationCode); final HttpResponse response; try { response = httpClient.execute(HttpMethod.POST, String.format(Endpoints.SESSION_CREATE_APPLICATION, pagSeguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); } catch (IOException e) { throw new PagSeguroLibException(e); } return response.parseXMLContent(pagSeguro, CreatedSessionXML.class); }
SessionResource { public CreatedSession create(String authorizationCode) { final RequestMap map = new RequestMap(); map.putString("authorizationCode", authorizationCode); final HttpResponse response; try { response = httpClient.execute(HttpMethod.POST, String.format(Endpoints.SESSION_CREATE_APPLICATION, pagSeguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); } catch (IOException e) { throw new PagSeguroLibException(e); } return response.parseXMLContent(pagSeguro, CreatedSessionXML.class); } }
SessionResource { public CreatedSession create(String authorizationCode) { final RequestMap map = new RequestMap(); map.putString("authorizationCode", authorizationCode); final HttpResponse response; try { response = httpClient.execute(HttpMethod.POST, String.format(Endpoints.SESSION_CREATE_APPLICATION, pagSeguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); } catch (IOException e) { throw new PagSeguroLibException(e); } return response.parseXMLContent(pagSeguro, CreatedSessionXML.class); } SessionResource(PagSeguro pagSeguro, HttpClient httpClient); }
SessionResource { public CreatedSession create(String authorizationCode) { final RequestMap map = new RequestMap(); map.putString("authorizationCode", authorizationCode); final HttpResponse response; try { response = httpClient.execute(HttpMethod.POST, String.format(Endpoints.SESSION_CREATE_APPLICATION, pagSeguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); } catch (IOException e) { throw new PagSeguroLibException(e); } return response.parseXMLContent(pagSeguro, CreatedSessionXML.class); } SessionResource(PagSeguro pagSeguro, HttpClient httpClient); CreatedSession create(String authorizationCode); CreatedSession create(); CreatedSession createDirectPreApproval(String authorizationCode); CreatedSession createDirectPreApproval(); }
SessionResource { public CreatedSession create(String authorizationCode) { final RequestMap map = new RequestMap(); map.putString("authorizationCode", authorizationCode); final HttpResponse response; try { response = httpClient.execute(HttpMethod.POST, String.format(Endpoints.SESSION_CREATE_APPLICATION, pagSeguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); } catch (IOException e) { throw new PagSeguroLibException(e); } return response.parseXMLContent(pagSeguro, CreatedSessionXML.class); } SessionResource(PagSeguro pagSeguro, HttpClient httpClient); CreatedSession create(String authorizationCode); CreatedSession create(); CreatedSession createDirectPreApproval(String authorizationCode); CreatedSession createDirectPreApproval();  }