use of uk.gov.pay.api.ledger.model.TransactionSearchParams in project pay-publicapi by alphagov.
the class TransactionSearchServiceTest method shouldThrowBadRequestException.
@Test
public void shouldThrowBadRequestException() {
TransactionSearchParams searchParams = mock(TransactionSearchParams.class);
when(searchParams.getQueryMap()).thenReturn(Map.of("not_supported", "hello"));
BadRequestException badRequestException = assertThrows(BadRequestException.class, () -> transactionSearchService.doSearch(new Account("1", TokenPaymentType.CARD, "a-token-link"), searchParams));
assertThat(badRequestException, aBadRequestExceptionWithError("P0401", "Invalid parameters: not_supported. See Public API documentation for the correct data formats"));
}
use of uk.gov.pay.api.ledger.model.TransactionSearchParams in project pay-publicapi by alphagov.
the class TransactionSearchServiceTest method testSearchTransaction.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-search-transaction" })
public void testSearchTransaction() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, "a-token-link");
TransactionSearchParams searchParams = new TransactionSearchParams();
TransactionSearchResults searchResults = transactionSearchService.doSearch(account, searchParams);
PaymentForSearchResult payment = searchResults.getResults().get(0);
assertThat(payment.getAmount(), is(1000L));
assertThat(payment.getState(), is(new PaymentState("created", false)));
assertThat(payment.getDescription(), is("Test description"));
assertThat(payment.getReference(), is("aReference"));
assertThat(payment.getLanguage(), is(SupportedLanguage.ENGLISH));
assertThat(payment.getPaymentId(), is(CHARGE_ID));
assertThat(payment.getReturnUrl().get(), is("https://example.org"));
assertThat(payment.getEmail().get(), is("someone@example.org"));
assertThat(payment.getPaymentProvider(), is("sandbox"));
assertThat(payment.getCreatedDate(), is("2018-09-22T10:13:16.067Z"));
assertThat(payment.getDelayedCapture(), is(false));
assertThat(payment.getCardDetails().get().getCardHolderName(), is("J. Smith"));
assertThat(payment.getCardDetails().get().getCardBrand(), is(""));
Address address = payment.getCardDetails().get().getBillingAddress().get();
assertThat(address.getLine1(), is("line1"));
assertThat(address.getLine2(), is("line2"));
assertThat(address.getPostcode(), is("AB1 2CD"));
assertThat(address.getCity(), is("London"));
assertThat(address.getCountry(), is("GB"));
assertThat(payment.getLinks().getSelf().getHref(), containsString("v1/payments/" + CHARGE_ID));
assertThat(payment.getLinks().getSelf().getMethod(), is("GET"));
assertThat(payment.getLinks().getRefunds().getHref(), containsString("v1/payments/" + CHARGE_ID + "/refunds"));
assertThat(payment.getLinks().getRefunds().getMethod(), is("GET"));
assertThat(searchResults.getCount(), is(1));
assertThat(searchResults.getTotal(), is(1));
assertThat(searchResults.getPage(), is(1));
assertThat(searchResults.getLinks().getSelf().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
assertThat(searchResults.getLinks().getFirstPage().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
assertThat(searchResults.getLinks().getLastPage().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
}
Aggregations