@Test public void shouldThrowsBadRequest() { try { String responseAsString = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" + "<errors>" + "<error>" + "<code>0001</code>" + "<message>Abandoned date range is required.</message>" + "</error>" + "</errors>"; HttpResponse response = new HttpResponse(400, responseAsString); when(httpClient.execute(any(HttpMethod.class), anyString(), anyMap(), any(HttpRequestBody.class))).thenReturn(response); transactionSearchByAbandoned.execute(pagSeguro, httpClient); } catch (PagSeguroBadRequestException e) { ServerErrors errors = e.getErrors(); ServerError error = errors.getErrors().iterator().next(); assertEquals(new Integer(0001), error.getCode()); assertEquals("Abandoned date range is required.", error.getMessage()); } catch (Exception e) { } }
@Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao abandonada"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MP.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_ABANDONED, 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 abandonada"); 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 abandonada finalizada"); return transactionsSummary; }
TransactionSearchByAbandoned implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao abandonada"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MP.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_ABANDONED, 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 abandonada"); 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 abandonada finalizada"); return transactionsSummary; } }
TransactionSearchByAbandoned implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao abandonada"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MP.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_ABANDONED, 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 abandonada"); 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 abandonada finalizada"); return transactionsSummary; } TransactionSearchByAbandoned(TransactionSearch transactionSearch); }
TransactionSearchByAbandoned implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao abandonada"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MP.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_ABANDONED, 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 abandonada"); 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 abandonada finalizada"); return transactionsSummary; } TransactionSearchByAbandoned(TransactionSearch transactionSearch); @Override DataList<? extends TransactionSummary> execute(PagSeguro pagseguro,
                                                        HttpClient httpClient); }
TransactionSearchByAbandoned implements PagSeguroCommand<DataList<? extends
    TransactionSummary>> { @Override public DataList<? extends TransactionSummary> execute(PagSeguro pagseguro, HttpClient httpClient) { LOGGER.info("Iniciando busca de transacao abandonada"); LOGGER.info("Convertendo valores"); final RequestMap map = TRANSACTION_SEARCH_MP.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_ABANDONED, 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 abandonada"); 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 abandonada finalizada"); return transactionsSummary; } TransactionSearchByAbandoned(TransactionSearch transactionSearch); @Override DataList<? extends TransactionSummary> execute(PagSeguro pagseguro,
                                                        HttpClient httpClient);  }