use of uk.gov.pay.api.exception.SearchPaymentsException in project pay-publicapi by alphagov.
the class PaginationDecorator method decoratePagination.
public HalRepresentation.HalRepresentationBuilder decoratePagination(HalRepresentation.HalRepresentationBuilder halRepresentationBuilder, SearchPagination pagination, String path) {
HalRepresentation.HalRepresentationBuilder builder = addPaginationProperties(halRepresentationBuilder, pagination);
SearchNavigationLinks links = pagination.getLinks();
try {
addLink(builder, "self", transformIntoPublicUri(baseUrl, links.getSelf(), path));
addLink(builder, "first_page", transformIntoPublicUri(baseUrl, links.getFirstPage(), path));
addLink(builder, "last_page", transformIntoPublicUri(baseUrl, links.getLastPage(), path));
addLink(builder, "prev_page", transformIntoPublicUri(baseUrl, links.getPrevPage(), path));
addLink(builder, "next_page", transformIntoPublicUri(baseUrl, links.getNextPage(), path));
} catch (URISyntaxException ex) {
throw new SearchPaymentsException(ex);
}
return builder;
}
use of uk.gov.pay.api.exception.SearchPaymentsException in project pay-publicapi by alphagov.
the class CardPaymentSearchServiceTest method shouldReturn404WhenSearchingWithNonExistentPageNumber.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-search-payments-page-not-found" })
public void shouldReturn404WhenSearchingWithNonExistentPageNumber() {
Account account = new Account("123456", TokenPaymentType.CARD, tokenLink);
var searchParams = new PaymentSearchParams.Builder().withDisplaySize("500").withPageNumber("999").build();
SearchPaymentsException searchPaymentsException = assertThrows(SearchPaymentsException.class, () -> paymentSearchService.searchLedgerPayments(account, searchParams));
assertThat(searchPaymentsException, hasProperty("errorStatus", is(404)));
}
use of uk.gov.pay.api.exception.SearchPaymentsException in project pay-publicapi by alphagov.
the class LedgerService method searchPayments.
public PaymentSearchResponse<TransactionResponse> searchPayments(Account account, Map<String, String> paramsAsMap) {
paramsAsMap.put(PARAM_ACCOUNT_ID, account.getAccountId());
paramsAsMap.put(PARAM_TRANSACTION_TYPE, PAYMENT_TRANSACTION_TYPE);
paramsAsMap.put(PARAM_EXACT_REFERENCE_MATCH, "true");
Response response = client.target(ledgerUriGenerator.transactionsURIWithParams(paramsAsMap)).request().accept(MediaType.APPLICATION_JSON_TYPE).get();
if (response.getStatus() == SC_OK) {
try {
return response.readEntity(new GenericType<PaymentSearchResponse<TransactionResponse>>() {
});
} catch (ProcessingException ex) {
throw new SearchPaymentsException(ex);
}
}
throw new SearchPaymentsException(response);
}
Aggregations