use of org.killbill.billing.client.model.InvoicePayments in project killbill by killbill.
the class TestInvoice method testInvoicePayments.
@Test(groups = "slow", description = "Can retrieve invoice payments")
public void testInvoicePayments() throws Exception {
clock.setTime(new DateTime(2012, 4, 25, 0, 3, 42, 0));
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
assertEquals(invoices.size(), 2);
final Invoice invoiceWithPositiveAmount = Iterables.tryFind(invoices, new Predicate<Invoice>() {
@Override
public boolean apply(final Invoice input) {
return input.getAmount().compareTo(BigDecimal.ZERO) > 0;
}
}).orNull();
Assert.assertNotNull(invoiceWithPositiveAmount);
final InvoicePayments objFromJson = killBillClient.getInvoicePayment(invoiceWithPositiveAmount.getInvoiceId());
assertEquals(objFromJson.size(), 1);
assertEquals(invoiceWithPositiveAmount.getAmount().compareTo(objFromJson.get(0).getPurchasedAmount()), 0);
}
use of org.killbill.billing.client.model.InvoicePayments in project killbill by killbill.
the class TestInvoicePayment method testWithFailedInvoicePayment.
@Test(groups = "slow")
public void testWithFailedInvoicePayment() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
InvoicePayments invoicePayments = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoicePayments.size(), 1);
final InvoicePayment invoicePayment = invoicePayments.get(0);
// Verify targetInvoiceId is not Null. See #593
assertNotNull(invoicePayment.getTargetInvoiceId());
final Invoices invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoices.size(), 2);
final Invoice invoice = invoices.get(1);
// Verify this is the correct value
assertEquals(invoicePayment.getTargetInvoiceId(), invoice.getInvoiceId());
// Make a payment and verify both invoice payment point to the same targetInvoiceId
killBillClient.payAllInvoices(accountJson.getAccountId(), false, null, requestOptions);
invoicePayments = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoicePayments.size(), 2);
for (final InvoicePayment cur : invoicePayments) {
assertEquals(cur.getTargetInvoiceId(), invoice.getInvoiceId());
}
}
Aggregations