@Test(expected = PagSeguroLibException.class) public void shouldThrowsErrorLib() throws Exception { when(httpClient.execute(any(HttpMethod.class), anyString(), anyMap(), any(HttpRequestBody.class))).thenThrow(new IOException()); transactionSearchByDateRange.execute(pagSeguro, httpClient); }
@Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao por intervalo de data"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MC.convert(transactionSearch); LOGGER.info("Valores convertidos"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: %s", map)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.TRANSACTION_SEARCH, pagseguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de transacao por intervalo de data"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); DataList<? extends TransactionSummary> transactionsSummary = response.parseXMLContent(pagseguro, TransactionSearchResponseXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de transacao por intervalo de data finalizada"); return transactionsSummary; }
TransactionSearchByDateRange implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao por intervalo de data"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MC.convert(transactionSearch); LOGGER.info("Valores convertidos"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: %s", map)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.TRANSACTION_SEARCH, pagseguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de transacao por intervalo de data"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); DataList<? extends TransactionSummary> transactionsSummary = response.parseXMLContent(pagseguro, TransactionSearchResponseXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de transacao por intervalo de data finalizada"); return transactionsSummary; } }
TransactionSearchByDateRange implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao por intervalo de data"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MC.convert(transactionSearch); LOGGER.info("Valores convertidos"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: %s", map)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.TRANSACTION_SEARCH, pagseguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de transacao por intervalo de data"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); DataList<? extends TransactionSummary> transactionsSummary = response.parseXMLContent(pagseguro, TransactionSearchResponseXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de transacao por intervalo de data finalizada"); return transactionsSummary; } TransactionSearchByDateRange(TransactionSearch transactionSearch); }
TransactionSearchByDateRange implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao por intervalo de data"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MC.convert(transactionSearch); LOGGER.info("Valores convertidos"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: %s", map)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.TRANSACTION_SEARCH, pagseguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de transacao por intervalo de data"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); DataList<? extends TransactionSummary> transactionsSummary = response.parseXMLContent(pagseguro, TransactionSearchResponseXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de transacao por intervalo de data finalizada"); return transactionsSummary; } TransactionSearchByDateRange(TransactionSearch transactionSearch); @Override DataList<? extends TransactionSummary> execute(PagSeguro pagseguro,
                                                        HttpClient httpClient); }
TransactionSearchByDateRange implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao por intervalo de data"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MC.convert(transactionSearch); LOGGER.info("Valores convertidos"); final HttpResponse response; try { LOGGER.debug(String.format("Parametros: %s", map)); response = httpClient.execute(HttpMethod.GET, String.format(Endpoints.TRANSACTION_SEARCH, pagseguro.getHost(), map.toUrlEncode(CharSet.ENCODING_UTF)), null, null); LOGGER.debug(String.format("Resposta: %s", response.toString())); } catch (IOException e) { LOGGER.error("Erro ao executar busca de transacao por intervalo de data"); throw new PagSeguroLibException(e); } LOGGER.info("Parseando XML de resposta"); DataList<? extends TransactionSummary> transactionsSummary = response.parseXMLContent(pagseguro, TransactionSearchResponseXML.class); LOGGER.info("Parseamento finalizado"); LOGGER.info("Busca de transacao por intervalo de data finalizada"); return transactionsSummary; } TransactionSearchByDateRange(TransactionSearch transactionSearch); @Override DataList<? extends TransactionSummary> execute(PagSeguro pagseguro,
                                                        HttpClient httpClient);  }