diff --git a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoice.java b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoice.java
index 9ee931b..8c611f6 100644
--- a/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoice.java
+++ b/profiles/killbill/src/test/java/org/killbill/billing/jaxrs/TestInvoice.java
@@ -69,7 +69,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, false, AuditLevel.FULL);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, false, AuditLevel.FULL, requestOptions);
assertEquals(invoices.size(), 2);
for (final Invoice invoiceJson : invoices) {
Assert.assertEquals(invoiceJson.getAuditLogs().size(), 1);
@@ -85,21 +85,21 @@ public class TestInvoice extends TestJaxrsBase {
final Invoice invoiceJson = invoices.get(0);
// Check get with & without items
- assertTrue(killBillClient.getInvoice(invoiceJson.getInvoiceId(), Boolean.FALSE).getItems().isEmpty());
- assertTrue(killBillClient.getInvoice(invoiceJson.getInvoiceNumber(), Boolean.FALSE).getItems().isEmpty());
- assertEquals(killBillClient.getInvoice(invoiceJson.getInvoiceId(), Boolean.TRUE).getItems().size(), invoiceJson.getItems().size());
- assertEquals(killBillClient.getInvoice(invoiceJson.getInvoiceNumber(), Boolean.TRUE).getItems().size(), invoiceJson.getItems().size());
+ assertTrue(killBillClient.getInvoice(invoiceJson.getInvoiceId(), Boolean.FALSE, Boolean.FALSE, requestOptions).getItems().isEmpty());
+ assertTrue(killBillClient.getInvoice(invoiceJson.getInvoiceNumber(), Boolean.FALSE, Boolean.FALSE, requestOptions).getItems().isEmpty());
+ assertEquals(killBillClient.getInvoice(invoiceJson.getInvoiceId(), Boolean.TRUE, Boolean.FALSE, requestOptions).getItems().size(), invoiceJson.getItems().size());
+ assertEquals(killBillClient.getInvoice(invoiceJson.getInvoiceNumber(), Boolean.TRUE, Boolean.FALSE, requestOptions).getItems().size(), invoiceJson.getItems().size());
// Check we can retrieve an individual invoice
- final Invoice firstInvoice = killBillClient.getInvoice(invoiceJson.getInvoiceId());
+ final Invoice firstInvoice = killBillClient.getInvoice(invoiceJson.getInvoiceId(), requestOptions);
assertEquals(firstInvoice, invoiceJson);
// Check we can retrieve the invoice by number
- final Invoice firstInvoiceByNumberJson = killBillClient.getInvoice(invoiceJson.getInvoiceNumber());
+ final Invoice firstInvoiceByNumberJson = killBillClient.getInvoice(invoiceJson.getInvoiceNumber(), requestOptions);
assertEquals(firstInvoiceByNumberJson, invoiceJson);
// Check we can retrieve the HTML version
- final String htmlInvoice = killBillClient.getInvoiceAsHtml(invoiceJson.getInvoiceId());
+ final String htmlInvoice = killBillClient.getInvoiceAsHtml(invoiceJson.getInvoiceId(), requestOptions);
assertEquals(htmlInvoice, "<html>\n" +
" <head>\n" +
" <style type=\"text/css\">\n" +
@@ -201,7 +201,7 @@ public class TestInvoice extends TestJaxrsBase {
final InvoiceDryRun dryRunArg = new InvoiceDryRun(DryRunType.UPCOMING_INVOICE, null,
null, null, null, null, null, null, null, null, null, null);
- final Invoice dryRunInvoice = killBillClient.createDryRunInvoice(accountJson.getAccountId(), null, dryRunArg, createdBy, reason, comment);
+ final Invoice dryRunInvoice = killBillClient.createDryRunInvoice(accountJson.getAccountId(), null, dryRunArg, requestOptions);
assertEquals(dryRunInvoice.getBalance(), new BigDecimal("249.95"));
assertEquals(dryRunInvoice.getTargetDate(), new LocalDate(2012, 6, 25));
assertEquals(dryRunInvoice.getItems().size(), 1);
@@ -211,10 +211,10 @@ public class TestInvoice extends TestJaxrsBase {
final LocalDate futureDate = dryRunInvoice.getTargetDate();
// The one more time with no DryRun
- killBillClient.createInvoice(accountJson.getAccountId(), futureDate, createdBy, reason, comment);
+ killBillClient.createInvoice(accountJson.getAccountId(), futureDate, requestOptions);
// Check again # invoices, should be 3 this time
- final List<Invoice> newInvoiceList = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
+ final List<Invoice> newInvoiceList = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(newInvoiceList.size(), 3);
}
@@ -227,7 +227,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithDefaultPaymentMethod();
final InvoiceDryRun dryRunArg = new InvoiceDryRun(DryRunType.TARGET_DATE, SubscriptionEventType.START_BILLING,
null, "Assault-Rifle", ProductCategory.BASE, BillingPeriod.ANNUAL, null, null, null, null, null, null);
- final Invoice dryRunInvoice = killBillClient.createDryRunInvoice(accountJson.getAccountId(), new LocalDate(initialDate, DateTimeZone.forID(accountJson.getTimeZone())), dryRunArg, createdBy, reason, comment);
+ final Invoice dryRunInvoice = killBillClient.createDryRunInvoice(accountJson.getAccountId(), new LocalDate(initialDate, DateTimeZone.forID(accountJson.getTimeZone())), dryRunArg, requestOptions);
assertEquals(dryRunInvoice.getItems().size(), 1);
}
@@ -238,7 +238,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoices.size(), 2);
final Invoice invoiceWithPositiveAmount = Iterables.tryFind(invoices, new Predicate<Invoice>() {
@@ -249,7 +249,7 @@ public class TestInvoice extends TestJaxrsBase {
}).orNull();
Assert.assertNotNull(invoiceWithPositiveAmount);
- final InvoicePayments objFromJson = killBillClient.getInvoicePayment(invoiceWithPositiveAmount.getInvoiceId());
+ final InvoicePayments objFromJson = killBillClient.getInvoicePayment(invoiceWithPositiveAmount.getInvoiceId(), requestOptions);
assertEquals(objFromJson.size(), 1);
assertEquals(invoiceWithPositiveAmount.getAmount().compareTo(objFromJson.get(0).getPurchasedAmount()), 0);
}
@@ -262,20 +262,20 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Check there was no payment made
- assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId()).size(), 0);
+ assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId(), requestOptions).size(), 0);
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoices.size(), 2);
final Invoice invoiceToPay = invoices.get(1);
assertEquals(invoiceToPay.getBalance().compareTo(BigDecimal.ZERO), 1);
// Pay all invoices
- killBillClient.payAllInvoices(accountJson.getAccountId(), true, null, createdBy, reason, comment);
- for (final Invoice invoice : killBillClient.getInvoicesForAccount(accountJson.getAccountId())) {
+ killBillClient.payAllInvoices(accountJson.getAccountId(), true, null, requestOptions);
+ for (final Invoice invoice : killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions)) {
assertEquals(invoice.getBalance().compareTo(BigDecimal.ZERO), 0);
}
- assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId()).size(), 1);
+ assertEquals(killBillClient.getPaymentsForAccount(accountJson.getAccountId(), requestOptions).size(), 1);
}
@Test(groups = "slow", description = "Can create an insta-payment")
@@ -286,7 +286,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(invoices.size(), 2);
for (final Invoice cur : invoices) {
@@ -299,7 +299,7 @@ public class TestInvoice extends TestJaxrsBase {
invoicePayment.setPurchasedAmount(cur.getBalance());
invoicePayment.setAccountId(accountJson.getAccountId());
invoicePayment.setTargetInvoiceId(cur.getInvoiceId());
- final InvoicePayment objFromJson = killBillClient.createInvoicePayment(invoicePayment, true, createdBy, reason, comment);
+ final InvoicePayment objFromJson = killBillClient.createInvoicePayment(invoicePayment, true, requestOptions);
assertEquals(cur.getBalance().compareTo(objFromJson.getPurchasedAmount()), 0);
}
}
@@ -309,11 +309,11 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Verify we didn't get any invoicePayment
- final List<InvoicePayment> noPaymentsFromJson = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId());
+ final List<InvoicePayment> noPaymentsFromJson = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(noPaymentsFromJson.size(), 0);
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId());
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final UUID invoiceId = invoices.get(1).getInvoiceId();
@@ -323,17 +323,17 @@ public class TestInvoice extends TestJaxrsBase {
invoicePayment.setPurchasedAmount(BigDecimal.TEN);
invoicePayment.setAccountId(accountJson.getAccountId());
invoicePayment.setTargetInvoiceId(invoiceId);
- killBillClient.createInvoicePayment(invoicePayment, true, createdBy, reason, comment);
+ killBillClient.createInvoicePayment(invoicePayment, true, requestOptions);
// Verify we indeed got the invoicePayment
- final List<InvoicePayment> paymentsFromJson = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId());
+ final List<InvoicePayment> paymentsFromJson = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), requestOptions);
assertEquals(paymentsFromJson.size(), 1);
assertEquals(paymentsFromJson.get(0).getPurchasedAmount().compareTo(BigDecimal.TEN), 0);
assertEquals(paymentsFromJson.get(0).getTargetInvoiceId(), invoiceId);
// Check the PaymentMethod from paymentMethodId returned in the Payment object
final UUID paymentMethodId = paymentsFromJson.get(0).getPaymentMethodId();
- final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(paymentMethodId);
+ final PaymentMethod paymentMethodJson = killBillClient.getPaymentMethod(paymentMethodId, requestOptions);
assertEquals(paymentMethodJson.getPaymentMethodId(), paymentMethodId);
assertEquals(paymentMethodJson.getAccountId(), accountJson.getAccountId());
assertEquals(paymentMethodJson.getPluginName(), ExternalPaymentProviderPlugin.PLUGIN_NAME);
@@ -345,7 +345,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final Invoice invoice = invoices.get(1);
@@ -360,10 +360,10 @@ public class TestInvoice extends TestJaxrsBase {
adjustmentInvoiceItem.setAccountId(accountJson.getAccountId());
adjustmentInvoiceItem.setInvoiceId(invoice.getInvoiceId());
adjustmentInvoiceItem.setInvoiceItemId(invoiceItem.getInvoiceItemId());
- killBillClient.adjustInvoiceItem(invoiceItem, createdBy, reason, comment);
+ killBillClient.adjustInvoiceItem(invoiceItem, requestOptions);
// Verify the new invoice balance is zero
- final Invoice adjustedInvoice = killBillClient.getInvoice(invoice.getInvoiceId(), true, AuditLevel.FULL);
+ final Invoice adjustedInvoice = killBillClient.getInvoice(invoice.getInvoiceId(), true, false, AuditLevel.FULL, requestOptions);
assertEquals(adjustedInvoice.getAmount().compareTo(BigDecimal.ZERO), 0);
// Verify invoice audit logs
@@ -406,7 +406,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final Invoice invoice = invoices.get(1);
@@ -424,10 +424,10 @@ public class TestInvoice extends TestJaxrsBase {
adjustmentInvoiceItem.setInvoiceItemId(invoiceItem.getInvoiceItemId());
adjustmentInvoiceItem.setAmount(adjustedAmount);
adjustmentInvoiceItem.setCurrency(invoice.getCurrency().name());
- killBillClient.adjustInvoiceItem(adjustmentInvoiceItem, createdBy, reason, comment);
+ killBillClient.adjustInvoiceItem(adjustmentInvoiceItem, requestOptions);
// Verify the new invoice balance
- final Invoice adjustedInvoice = killBillClient.getInvoice(invoice.getInvoiceId());
+ final Invoice adjustedInvoice = killBillClient.getInvoice(invoice.getInvoiceId(), requestOptions);
final BigDecimal adjustedInvoiceBalance = invoice.getBalance().add(adjustedAmount.negate()).setScale(2, BigDecimal.ROUND_HALF_UP);
assertEquals(adjustedInvoice.getBalance().compareTo(adjustedInvoiceBalance), 0, String.format("Adjusted invoice balance is %s, should be %s", adjustedInvoice.getBalance(), adjustedInvoiceBalance));
}
@@ -437,7 +437,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 2);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
@@ -446,15 +446,16 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setDescription(UUID.randomUUID().toString());
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), false, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.of(externalCharge), clock.getUTCToday(), false, true, requestOptions);
+ assertEquals(createdExternalCharges.size(), 1);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true, false, requestOptions);
assertEquals(invoiceWithItems.getBalance().compareTo(chargeAmount), 0);
assertEquals(invoiceWithItems.getItems().size(), 1);
assertEquals(invoiceWithItems.getItems().get(0).getDescription(), externalCharge.getDescription());
assertNull(invoiceWithItems.getItems().get(0).getBundleId());
// Verify the total number of invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 3);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 3);
}
@Test(groups = "slow", description = "Can create multiple external charges")
@@ -462,7 +463,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 2);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
@@ -483,13 +484,13 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge2.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge2);
- final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(externalCharges, clock.getUTCToday(), false, true, createdBy, reason, comment);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(externalCharges, clock.getUTCToday(), false, true, requestOptions);
assertEquals(createdExternalCharges.size(), 2);
- assertEquals(createdExternalCharges.get(0).getCurrency().toString(), accountJson.getCurrency());
- assertEquals(createdExternalCharges.get(1).getCurrency().toString(), accountJson.getCurrency());
+ assertEquals(createdExternalCharges.get(0).getCurrency(), accountJson.getCurrency());
+ assertEquals(createdExternalCharges.get(1).getCurrency(), accountJson.getCurrency());
// Verify the total number of invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 3);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 3);
}
@Test(groups = "slow", description = "Can create multiple external charges with same invoice and external keys")
@@ -497,7 +498,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 2);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
@@ -518,23 +519,20 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge2.setDescription(UUID.randomUUID().toString());
externalCharges.add(externalCharge2);
- String paymentExternalKey = "anyPaymentExternalKey";
- String transactionExternalKey = "anyTransactionExternalKey";
+ final String paymentExternalKey = "anyPaymentExternalKey";
+ final String transactionExternalKey = "anyTransactionExternalKey";
final List<InvoiceItem> createdExternalCharges =
killBillClient.createExternalCharges(externalCharges, clock.getUTCToday(), true, true,
- paymentExternalKey, transactionExternalKey, RequestOptions.builder()
- .withCreatedBy(createdBy)
- .withReason(reason)
- .withComment(comment).build());
+ paymentExternalKey, transactionExternalKey, requestOptions);
assertEquals(createdExternalCharges.size(), 2);
- assertEquals(createdExternalCharges.get(0).getCurrency().toString(), accountJson.getCurrency());
- assertEquals(createdExternalCharges.get(1).getCurrency().toString(), accountJson.getCurrency());
+ assertEquals(createdExternalCharges.get(0).getCurrency(), accountJson.getCurrency());
+ assertEquals(createdExternalCharges.get(1).getCurrency(), accountJson.getCurrency());
// Verify the total number of invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 3);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 3);
- Payments payments = killBillClient.getPaymentsForAccount(accountJson.getAccountId(), AuditLevel.NONE, RequestOptions.empty());
+ final Payments payments = killBillClient.getPaymentsForAccount(accountJson.getAccountId(), AuditLevel.NONE, requestOptions);
assertNotNull(payments);
// Verify payment with paymentExternalKey provided
assertEquals(payments.get(payments.size() - 1).getPaymentExternalKey(), paymentExternalKey);
@@ -547,7 +545,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 2);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
@@ -555,14 +553,15 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setAccountId(accountJson.getAccountId());
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), true, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.<InvoiceItem>of(externalCharge), clock.getUTCToday(), true, true, requestOptions);
+ assertEquals(createdExternalCharges.size(), 1);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true);
assertEquals(invoiceWithItems.getBalance().compareTo(BigDecimal.ZERO), 0);
assertEquals(invoiceWithItems.getItems().size(), 1);
assertNull(invoiceWithItems.getItems().get(0).getBundleId());
// Verify the total number of invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 3);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 3);
}
@Test(groups = "slow", description = "Can create an external charge for a bundle")
@@ -570,7 +569,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 2);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 2);
// Post an external charge
final BigDecimal chargeAmount = BigDecimal.TEN;
@@ -580,14 +579,15 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setBundleId(bundleId);
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), false, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.<InvoiceItem>of(externalCharge), clock.getUTCToday(), false, true, requestOptions);
+ assertEquals(createdExternalCharges.size(), 1);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true);
assertEquals(invoiceWithItems.getBalance().compareTo(chargeAmount), 0);
assertEquals(invoiceWithItems.getItems().size(), 1);
assertEquals(invoiceWithItems.getItems().get(0).getBundleId(), bundleId);
// Verify the total number of invoices
- assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId()).size(), 3);
+ assertEquals(killBillClient.getInvoicesForAccount(accountJson.getAccountId(), requestOptions).size(), 3);
}
@Test(groups = "slow", description = "Can create an external charge on an existing invoice")
@@ -595,7 +595,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final UUID invoiceId = invoices.get(1).getInvoiceId();
@@ -609,13 +609,14 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setInvoiceId(invoiceId);
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), false, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.of(externalCharge), clock.getUTCToday(), false, true, requestOptions);
+ assertEquals(createdExternalCharges.size(), 1);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true, false, requestOptions);
assertEquals(invoiceWithItems.getItems().size(), originalNumberOfItemsForInvoice + 1);
assertNull(invoiceWithItems.getItems().get(originalNumberOfItemsForInvoice).getBundleId());
// Verify the new invoice balance
- final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId);
+ final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId, requestOptions);
final BigDecimal adjustedInvoiceBalance = originalInvoiceAmount.add(chargeAmount.setScale(2, RoundingMode.HALF_UP));
assertEquals(adjustedInvoice.getBalance().compareTo(adjustedInvoiceBalance), 0);
}
@@ -625,11 +626,10 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final UUID invoiceId = invoices.get(1).getInvoiceId();
- final BigDecimal originalInvoiceAmount = invoices.get(1).getAmount();
final int originalNumberOfItemsForInvoice = invoices.get(1).getItems().size();
// Post an external charge
@@ -639,13 +639,14 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setAmount(chargeAmount);
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setInvoiceId(invoiceId);
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), true, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.of(externalCharge), clock.getUTCToday(), true, true, requestOptions);
+ assertEquals(createdExternalCharges.size(), 1);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true,false, requestOptions);
assertEquals(invoiceWithItems.getItems().size(), originalNumberOfItemsForInvoice + 1);
assertNull(invoiceWithItems.getItems().get(originalNumberOfItemsForInvoice).getBundleId());
// Verify the new invoice balance
- final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId);
+ final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId, requestOptions);
assertEquals(adjustedInvoice.getBalance().compareTo(BigDecimal.ZERO), 0);
}
@@ -654,7 +655,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, false, requestOptions);
// 2 invoices but look for the non zero dollar one
assertEquals(invoices.size(), 2);
final UUID invoiceId = invoices.get(1).getInvoiceId();
@@ -670,13 +671,13 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setCurrency(accountJson.getCurrency());
externalCharge.setInvoiceId(invoiceId);
externalCharge.setBundleId(bundleId);
- final InvoiceItem createdExternalCharge = killBillClient.createExternalCharge(externalCharge, clock.getUTCToday(), false, true, createdBy, reason, comment);
- final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharge.getInvoiceId(), true);
+ final List<InvoiceItem> createdExternalCharges = killBillClient.createExternalCharges(ImmutableList.<InvoiceItem>of(externalCharge), clock.getUTCToday(), false, true, requestOptions);
+ final Invoice invoiceWithItems = killBillClient.getInvoice(createdExternalCharges.get(0).getInvoiceId(), true,false, requestOptions);
assertEquals(invoiceWithItems.getItems().size(), originalNumberOfItemsForInvoice + 1);
assertEquals(invoiceWithItems.getItems().get(originalNumberOfItemsForInvoice).getBundleId(), bundleId);
// Verify the new invoice balance
- final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId);
+ final Invoice adjustedInvoice = killBillClient.getInvoice(invoiceId, requestOptions);
final BigDecimal adjustedInvoiceBalance = originalInvoiceAmount.add(chargeAmount.setScale(2, RoundingMode.HALF_UP));
assertEquals(adjustedInvoice.getBalance().compareTo(adjustedInvoiceBalance), 0);
}
@@ -690,17 +691,17 @@ public class TestInvoice extends TestJaxrsBase {
crappyWaitForLackOfProperSynchonization();
}
- final Invoices allInvoices = killBillClient.getInvoices();
+ final Invoices allInvoices = killBillClient.getInvoices(requestOptions);
Assert.assertEquals(allInvoices.size(), 5);
for (final Invoice invoice : allInvoices) {
- Assert.assertEquals(killBillClient.searchInvoices(invoice.getInvoiceId().toString()).size(), 1);
- Assert.assertEquals(killBillClient.searchInvoices(invoice.getAccountId().toString()).size(), 5);
- Assert.assertEquals(killBillClient.searchInvoices(invoice.getInvoiceNumber().toString()).size(), 1);
- Assert.assertEquals(killBillClient.searchInvoices(invoice.getCurrency().toString()).size(), 5);
+ Assert.assertEquals(killBillClient.searchInvoices(invoice.getInvoiceId().toString(), requestOptions).size(), 1);
+ Assert.assertEquals(killBillClient.searchInvoices(invoice.getAccountId().toString(), requestOptions).size(), 5);
+ Assert.assertEquals(killBillClient.searchInvoices(invoice.getInvoiceNumber().toString(), requestOptions).size(), 1);
+ Assert.assertEquals(killBillClient.searchInvoices(invoice.getCurrency().toString(), requestOptions).size(), 5);
}
- Invoices page = killBillClient.getInvoices(0L, 1L);
+ Invoices page = killBillClient.getInvoices(0L, 1L, requestOptions);
for (int i = 0; i < 5; i++) {
Assert.assertNotNull(page);
Assert.assertEquals(page.size(), 1);
@@ -715,20 +716,19 @@ public class TestInvoice extends TestJaxrsBase {
final Account account = createAccountWithDefaultPaymentMethod();
- final DateTime effectiveDate = clock.getUTCNow();
final BigDecimal creditAmount = BigDecimal.TEN;
final Credit credit = new Credit();
credit.setAccountId(account.getAccountId());
credit.setInvoiceId(null);
credit.setCreditAmount(creditAmount);
- final Credit creditJson = killBillClient.createCredit(credit, false, createdBy, reason, comment);
+ final Credit creditJson = killBillClient.createCredit(credit, false, requestOptions);
Invoice invoice = killBillClient.getInvoice(creditJson.getInvoiceId());
Assert.assertEquals(invoice.getStatus(), InvoiceStatus.DRAFT.toString());
- killBillClient.commitInvoice(invoice.getInvoiceId(), createdBy, reason, comment);
+ killBillClient.commitInvoice(invoice.getInvoiceId(), requestOptions);
- invoice = killBillClient.getInvoice(creditJson.getInvoiceId());
+ invoice = killBillClient.getInvoice(creditJson.getInvoiceId(), requestOptions);
Assert.assertEquals(invoice.getStatus(), InvoiceStatus.COMMITTED.toString());
}
@@ -737,7 +737,7 @@ public class TestInvoice extends TestJaxrsBase {
final Account accountJson = createAccountNoPMBundleAndSubscriptionAndWaitForFirstInvoice();
// Get the invoices
- final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, true);
+ final List<Invoice> invoices = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, true, requestOptions);
assertEquals(invoices.size(), 2);
// Migrate an invoice with one external charge
@@ -749,7 +749,7 @@ public class TestInvoice extends TestJaxrsBase {
externalCharge.setItemType(InvoiceItemType.EXTERNAL_CHARGE.toString());
externalCharge.setCurrency(accountJson.getCurrency());
- final Account accountWithBalance = killBillClient.getAccount(accountJson.getAccountId(), true, true);
+ final Account accountWithBalance = killBillClient.getAccount(accountJson.getAccountId(), true, true, requestOptions);
final Invoice migrationInvoice = killBillClient.createMigrationInvoice(accountJson.getAccountId(), null, ImmutableList.<InvoiceItem>of(externalCharge), requestOptions);
assertEquals(migrationInvoice.getBalance(), BigDecimal.ZERO);
@@ -757,10 +757,10 @@ public class TestInvoice extends TestJaxrsBase {
assertEquals(migrationInvoice.getItems().get(0).getAmount().compareTo(chargeAmount), 0);
assertEquals(migrationInvoice.getItems().get(0).getCurrency(), accountJson.getCurrency());
- final List<Invoice> invoicesWithMigration = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, true);
+ final List<Invoice> invoicesWithMigration = killBillClient.getInvoicesForAccount(accountJson.getAccountId(), true, true, requestOptions);
assertEquals(invoicesWithMigration.size(), 3);
- final Account accountWithBalanceAfterMigration = killBillClient.getAccount(accountJson.getAccountId(), true, true);
+ final Account accountWithBalanceAfterMigration = killBillClient.getAccount(accountJson.getAccountId(), true, true, requestOptions);
assertEquals(accountWithBalanceAfterMigration.getAccountBalance().compareTo(accountWithBalance.getAccountBalance()), 0);
}
@@ -778,21 +778,21 @@ public class TestInvoice extends TestJaxrsBase {
// insert credit to child account
final Credit creditJson = killBillClient.createCredit(credit, true, requestOptions);
- Invoices childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false);
+ Invoices childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false, requestOptions);
Assert.assertEquals(childInvoices.size(), 1);
Assert.assertEquals(childInvoices.get(0).getCreditAdj().compareTo(BigDecimal.TEN), 0);
- Invoices parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false);
+ Invoices parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false, requestOptions);
Assert.assertEquals(parentInvoices.size(), 0);
// transfer credit to parent account
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), requestOptions);
- childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false);
+ childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false, requestOptions);
Assert.assertEquals(childInvoices.size(), 2);
Assert.assertEquals(childInvoices.get(1).getCreditAdj().compareTo(BigDecimal.TEN.negate()), 0);
- parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false);
+ parentInvoices = killBillClient.getInvoicesForAccount(parentAccount.getAccountId(), true, false, requestOptions);
Assert.assertEquals(parentInvoices.size(), 1);
Assert.assertEquals(parentInvoices.get(0).getCreditAdj().compareTo(BigDecimal.TEN), 0);
}