use of uk.gov.pay.ledger.util.fixture.TransactionFixture in project pay-ledger by alphagov.
the class ContractTest method createThreePaymentsWithPaidoutDates.
@State("three payments with payout dates exists")
public void createThreePaymentsWithPaidoutDates(Map<String, String> params) {
String gatewayAccountId = params.get("account_id");
if (isBlank(gatewayAccountId)) {
gatewayAccountId = "123456";
}
String gatewayPayoutId1 = randomAlphanumeric(20);
String gatewayPayoutId2 = randomAlphanumeric(20);
String gatewayPayoutId3 = randomAlphanumeric(20);
String gatewayPayoutId4 = randomAlphanumeric(20);
TransactionFixture refundParentFixture = aTransactionFixture().withTransactionType("PAYMENT").withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId1).insert(app.getJdbi());
aTransactionFixture().withTransactionType("PAYMENT").withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId2).insert(app.getJdbi());
aTransactionFixture().withTransactionType("PAYMENT").withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId3).insert(app.getJdbi());
aTransactionFixture().withTransactionType("REFUND").withParentExternalId(refundParentFixture.getExternalId()).withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId4).insert(app.getJdbi());
aPayoutFixture().withGatewayPayoutId(gatewayPayoutId1).withGatewayAccountId(gatewayAccountId).withPaidOutDate(ZonedDateTime.parse("2020-09-19T10:15:30Z")).build().insert(app.getJdbi());
aPayoutFixture().withGatewayPayoutId(gatewayPayoutId2).withGatewayAccountId(gatewayAccountId).withPaidOutDate(ZonedDateTime.parse("2020-09-18T23:59:59.999Z")).build().insert(app.getJdbi());
aPayoutFixture().withGatewayPayoutId(gatewayPayoutId3).withGatewayAccountId(gatewayAccountId).withPaidOutDate(ZonedDateTime.parse("2020-09-21T00:00:00Z")).build().insert(app.getJdbi());
aPayoutFixture().withGatewayPayoutId(gatewayPayoutId4).withGatewayAccountId(gatewayAccountId).withPaidOutDate(ZonedDateTime.parse("2020-09-19T19:05:00Z")).build().insert(app.getJdbi());
}
use of uk.gov.pay.ledger.util.fixture.TransactionFixture in project pay-ledger by alphagov.
the class TransactionDaoSearchIT method shouldFilterByGatewayPayoutIdWhenSpecified.
@Test
public void shouldFilterByGatewayPayoutIdWhenSpecified() {
String gatewayAccountId = "account-id-" + nextLong();
String gatewayPayoutId = "payout-id-" + nextLong();
TransactionFixture transaction = aTransactionFixture().withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId).withCreatedDate(now().minusDays(1)).withTransactionType("PAYMENT").insert(rule.getJdbi());
TransactionFixture refund = aTransactionFixture().withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId).withTransactionType("REFUND").insert(rule.getJdbi());
aTransactionFixture().withGatewayAccountId(gatewayAccountId).withGatewayPayoutId(gatewayPayoutId + "different-id").withTransactionType("PAYMENT").insert(rule.getJdbi());
TransactionSearchParams searchParams = new TransactionSearchParams();
searchParams.setGatewayPayoutId(gatewayPayoutId);
List<TransactionEntity> transactionList = transactionDao.searchTransactions(searchParams);
assertThat(transactionList.size(), Matchers.is(2));
assertThat(transactionList.get(0).getExternalId(), is(refund.getExternalId()));
assertThat(transactionList.get(0).getGatewayPayoutId(), is(refund.getGatewayPayoutId()));
assertThat(transactionList.get(1).getExternalId(), is(transaction.getExternalId()));
assertThat(transactionList.get(1).getGatewayPayoutId(), is(transaction.getGatewayPayoutId()));
}
use of uk.gov.pay.ledger.util.fixture.TransactionFixture in project pay-ledger by alphagov.
the class TransactionDaoSearchIT method shouldFilterByGatewayAccountIdWhenSpecified.
@Test
public void shouldFilterByGatewayAccountIdWhenSpecified() {
String gatewayAccountId = "account-id-" + nextLong();
TransactionFixture transaction = aTransactionFixture().withGatewayAccountId(gatewayAccountId).withTransactionType("PAYMENT").insert(rule.getJdbi());
aTransactionFixture().withGatewayAccountId(gatewayAccountId + "different_account").withTransactionType("PAYMENT").insert(rule.getJdbi());
TransactionSearchParams searchParams = new TransactionSearchParams();
searchParams.setAccountIds(List.of(gatewayAccountId));
List<TransactionEntity> transactionList = transactionDao.searchTransactions(searchParams);
assertThat(transactionList.size(), Matchers.is(1));
assertThat(transactionList.get(0).getExternalId(), is(transaction.getExternalId()));
}
use of uk.gov.pay.ledger.util.fixture.TransactionFixture in project pay-ledger by alphagov.
the class TransactionDaoSearchIT method shouldNotFilterByGatewayAccountIdWhenNotSpecified.
@Test
public void shouldNotFilterByGatewayAccountIdWhenNotSpecified() {
String gatewayAccountId = "account-id-" + nextLong();
TransactionFixture mostRecent = aTransactionFixture().withGatewayAccountId(gatewayAccountId).withTransactionType("PAYMENT").withCreatedDate(now()).insert(rule.getJdbi());
TransactionFixture earlier = aTransactionFixture().withGatewayAccountId(gatewayAccountId + "different_account").withTransactionType("PAYMENT").withCreatedDate(now().minusHours(1)).insert(rule.getJdbi());
TransactionSearchParams searchParams = new TransactionSearchParams();
List<TransactionEntity> transactionList = transactionDao.searchTransactions(searchParams);
assertThat(transactionList.size(), Matchers.is(2));
assertThat(transactionList.get(0).getExternalId(), is(mostRecent.getExternalId()));
assertThat(transactionList.get(1).getExternalId(), is(earlier.getExternalId()));
}
use of uk.gov.pay.ledger.util.fixture.TransactionFixture in project pay-ledger by alphagov.
the class TransactionResourceCsvIT method shouldGetAllTransactionsForAGivenGatewayPayoutId.
@Test
public void shouldGetAllTransactionsForAGivenGatewayPayoutId() throws IOException {
String targetGatewayAccountId = randomNumeric(5);
String gatewayPayoutId = randomAlphanumeric(30);
TransactionFixture transactionFixture = aTransactionFixture().withTransactionType("PAYMENT").withGatewayAccountId(targetGatewayAccountId).withCreatedDate(now()).withGatewayPayoutId(gatewayPayoutId).insert(rule.getJdbi());
TransactionFixture transactionFixtureWithoutGatewayPayoutId = aTransactionFixture().withTransactionType("PAYMENT").withGatewayAccountId(targetGatewayAccountId).insert(rule.getJdbi());
TransactionFixture refundFixture = aTransactionFixture().withTransactionType("REFUND").withCreatedDate(now().plusDays(1)).withParentExternalId(transactionFixtureWithoutGatewayPayoutId.getExternalId()).withGatewayAccountId(targetGatewayAccountId).withGatewayPayoutId(gatewayPayoutId).insert(rule.getJdbi());
InputStream csvResponseStream = given().port(port).accept("text/csv").get("/v1/transaction?" + "account_id=" + targetGatewayAccountId + "&gateway_payout_id=" + gatewayPayoutId).then().statusCode(Response.Status.OK.getStatusCode()).contentType("text/csv").extract().asInputStream();
List<CSVRecord> csvRecords = CSVParser.parse(csvResponseStream, UTF_8, RFC4180.withFirstRecordAsHeader()).getRecords();
assertThat(csvRecords.size(), is(2));
CSVRecord refundRecord = csvRecords.get(0);
assertThat(refundRecord.get("GOV.UK Payment ID"), is(transactionFixtureWithoutGatewayPayoutId.getExternalId()));
CSVRecord paymentRecord = csvRecords.get(1);
assertThat(paymentRecord.get("GOV.UK Payment ID"), is(transactionFixture.getExternalId()));
}
Aggregations