@Test(expected = PagSeguroLibException.class) public void shouldThrowsErrorLib() throws Exception { when(httpClient.execute(any(HttpMethod.class), anyString(), anyMap(), any(HttpRequestBody.class))).thenThrow(new IOException()); authorizationSearchByNotification.execute(pagSeguro, httpClient); }
@Override public AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de autorizacao por codigo de notificacao"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: notificationCode:%s", notificationCode)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.AUTHORIZATION_SEARCH_BY_NOTIFICATION_CODE, pagseguro.getHost(), notificationCode), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de autorizacao por codigo de notificacao"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); AuthorizationDetail authorizationDetail = response.parseXMLContent(pagseguro, AuthorizationDetailXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de autorizacao por codigo de notificacao finalizada"); return authorizationDetail; }
AuthorizationSearchByNotification implements PagSeguroCommand<AuthorizationDetail> { @Override public AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de autorizacao por codigo de notificacao"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: notificationCode:%s", notificationCode)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.AUTHORIZATION_SEARCH_BY_NOTIFICATION_CODE, pagseguro.getHost(), notificationCode), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de autorizacao por codigo de notificacao"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); AuthorizationDetail authorizationDetail = response.parseXMLContent(pagseguro, AuthorizationDetailXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de autorizacao por codigo de notificacao finalizada"); return authorizationDetail; } }
AuthorizationSearchByNotification implements PagSeguroCommand<AuthorizationDetail> { @Override public AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de autorizacao por codigo de notificacao"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: notificationCode:%s", notificationCode)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.AUTHORIZATION_SEARCH_BY_NOTIFICATION_CODE, pagseguro.getHost(), notificationCode), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de autorizacao por codigo de notificacao"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); AuthorizationDetail authorizationDetail = response.parseXMLContent(pagseguro, AuthorizationDetailXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de autorizacao por codigo de notificacao finalizada"); return authorizationDetail; } AuthorizationSearchByNotification(String notificationCode); }
AuthorizationSearchByNotification implements PagSeguroCommand<AuthorizationDetail> { @Override public AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de autorizacao por codigo de notificacao"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: notificationCode:%s", notificationCode)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.AUTHORIZATION_SEARCH_BY_NOTIFICATION_CODE, pagseguro.getHost(), notificationCode), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de autorizacao por codigo de notificacao"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); AuthorizationDetail authorizationDetail = response.parseXMLContent(pagseguro, AuthorizationDetailXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de autorizacao por codigo de notificacao finalizada"); return authorizationDetail; } AuthorizationSearchByNotification(String notificationCode); @Override AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient); }
AuthorizationSearchByNotification implements PagSeguroCommand<AuthorizationDetail> { @Override public AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de autorizacao por codigo de notificacao"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: notificationCode:%s", notificationCode)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.AUTHORIZATION_SEARCH_BY_NOTIFICATION_CODE, pagseguro.getHost(), notificationCode), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de autorizacao por codigo de notificacao"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); AuthorizationDetail authorizationDetail = response.parseXMLContent(pagseguro, AuthorizationDetailXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de autorizacao por codigo de notificacao finalizada"); return authorizationDetail; } AuthorizationSearchByNotification(String notificationCode); @Override AuthorizationDetail execute(PagSeguro pagseguro, HttpClient httpClient);  }