use of uk.gov.pay.api.exception.SearchRefundsException in project pay-publicapi by alphagov.
the class LedgerService method searchRefunds.
public SearchRefundsResponseFromLedger searchRefunds(Account account, Map<String, String> paramsAsMap) {
paramsAsMap.put(PARAM_ACCOUNT_ID, account.getAccountId());
paramsAsMap.put(PARAM_TRANSACTION_TYPE, REFUND_TRANSACTION_TYPE);
Response response = client.target(ledgerUriGenerator.transactionsURIWithParams(paramsAsMap)).request().accept(MediaType.APPLICATION_JSON_TYPE).get();
if (response.getStatus() == SC_OK) {
try {
return response.readEntity(SearchRefundsResponseFromLedger.class);
} catch (ProcessingException exception) {
throw new SearchRefundsException(exception);
}
}
throw new SearchRefundsException(response);
}
use of uk.gov.pay.api.exception.SearchRefundsException in project pay-publicapi by alphagov.
the class SearchRefundsServiceTest method shouldReturn404WhenSearchingWithNonExistentPageNumber.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-search-refunds-page-not-found" })
public void shouldReturn404WhenSearchingWithNonExistentPageNumber() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
RefundsParams params = new RefundsParams(null, null, "999", "500", null, null);
SearchRefundsException searchRefundsException = assertThrows(SearchRefundsException.class, () -> searchRefundsService.searchLedgerRefunds(account, params));
assertThat(searchRefundsException, hasProperty("errorStatus", is(404)));
}
Aggregations