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