Skip to content

Commit

Permalink
profile: Remove deprecated killbillClient APIs from TestAccount
Browse files Browse the repository at this point in the history
Also remove duplicate method basicRequestOptions() (and use requestOptions instaed all throughout our tests)
  • Loading branch information
sbrossie committed Jan 24, 2017
1 parent 6ce617c commit 1385d70
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 114 deletions.
Expand Up @@ -145,7 +145,7 @@ protected Subscription createEntitlement(final UUID accountId, final String bund
input.setBillingPeriod(billingPeriod);
input.setPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);

return killBillClient.createSubscription(input, null, waitCompletion ? DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC : -1, basicRequestOptions());
return killBillClient.createSubscription(input, null, waitCompletion ? DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC : -1, requestOptions);
}

protected Account createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice() throws Exception {
Expand Down Expand Up @@ -257,14 +257,4 @@ protected void crappyWaitForLackOfProperSynchonization(int sleepValueMSec) throw
Thread.sleep(sleepValueMSec);
}

/**
* Return a RequestOptions instance with the createdBy, reason and comment fields populated
* @return an instance of RequestOptions
*/
protected RequestOptions basicRequestOptions() {
return RequestOptions.builder()
.withCreatedBy(createdBy)
.withReason(reason)
.withComment(comment).build();
}
}

Large diffs are not rendered by default.

Expand Up @@ -68,7 +68,7 @@ public void testAdminPaymentEndpoint() throws Exception {
authTransaction.setPaymentExternalKey(paymentExternalKey);
authTransaction.setTransactionExternalKey(authTransactionExternalKey);
authTransaction.setTransactionType("AUTHORIZE");
final Payment authPayment = killBillClient.createPayment(account.getAccountId(), account.getPaymentMethodId(), authTransaction, basicRequestOptions());
final Payment authPayment = killBillClient.createPayment(account.getAccountId(), account.getPaymentMethodId(), authTransaction, requestOptions);

// First fix transactionStatus and paymentSstate (but not lastSuccessPaymentState
// Note that state is not consistent between TransactionStatus and lastSuccessPaymentState but we don't care.
Expand Down Expand Up @@ -176,7 +176,7 @@ private void doCapture(final Payment payment, final boolean expectException) thr
captureTransaction.setPaymentExternalKey(payment.getPaymentExternalKey());
captureTransaction.setTransactionExternalKey(capture1TransactionExternalKey);
try {
killBillClient.captureAuthorization(captureTransaction, basicRequestOptions());
killBillClient.captureAuthorization(captureTransaction, requestOptions);
if (expectException) {
Assert.fail("Capture should not succeed, after auth was moved to a PAYMENT_FAILURE");
}
Expand Down
Expand Up @@ -180,13 +180,13 @@ public void testBlockBundle() throws Exception {
final Subscription subscription2 = killBillClient.getSubscription(entitlement.getSubscriptionId());
assertEquals(subscription2.getState(), EntitlementState.ACTIVE);

final BlockingStates blockingStates = killBillClient.getBlockingStates(accountJson.getAccountId(), null, ImmutableList.<String>of("service"), AuditLevel.FULL, basicRequestOptions());
final BlockingStates blockingStates = killBillClient.getBlockingStates(accountJson.getAccountId(), null, ImmutableList.<String>of("service"), AuditLevel.FULL, requestOptions);
Assert.assertEquals(blockingStates.size(), 2);

final BlockingStates blockingStates2 = killBillClient.getBlockingStates(accountJson.getAccountId(), ImmutableList.<BlockingStateType>of(BlockingStateType.SUBSCRIPTION_BUNDLE), null, AuditLevel.FULL, basicRequestOptions());
final BlockingStates blockingStates2 = killBillClient.getBlockingStates(accountJson.getAccountId(), ImmutableList.<BlockingStateType>of(BlockingStateType.SUBSCRIPTION_BUNDLE), null, AuditLevel.FULL, requestOptions);
Assert.assertEquals(blockingStates2.size(), 2);

final BlockingStates blockingStates3 = killBillClient.getBlockingStates(accountJson.getAccountId(), null, null, AuditLevel.FULL, basicRequestOptions());
final BlockingStates blockingStates3 = killBillClient.getBlockingStates(accountJson.getAccountId(), null, null, AuditLevel.FULL, requestOptions);
Assert.assertEquals(blockingStates3.size(), 3);
}

Expand Down
Expand Up @@ -291,7 +291,7 @@ public void testOverridePrice() throws Exception {
final Subscription newInput = new Subscription();
newInput.setSubscriptionId(subscription2.getSubscriptionId());
newInput.setPlanName("pistol-monthly");
final Subscription subscription3 = killBillClient.updateSubscription(newInput, null, BillingActionPolicy.IMMEDIATE, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, basicRequestOptions());
final Subscription subscription3 = killBillClient.updateSubscription(newInput, null, BillingActionPolicy.IMMEDIATE, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, requestOptions);

Assert.assertEquals(subscription3.getEvents().size(), 4);
Assert.assertEquals(subscription3.getEvents().get(0).getEventType(), SubscriptionEventType.START_ENTITLEMENT.name());
Expand Down Expand Up @@ -515,7 +515,7 @@ public void testMoveEntitlementBCD() throws Exception {
final Subscription updatedSubscription = new Subscription();
updatedSubscription.setSubscriptionId(entitlementJson.getSubscriptionId());
updatedSubscription.setBillCycleDayLocal(9);
killBillClient.updateSubscriptionBCD(updatedSubscription, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, basicRequestOptions());
killBillClient.updateSubscriptionBCD(updatedSubscription, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, requestOptions);


final Subscription result = killBillClient.getSubscription(entitlementJson.getSubscriptionId());
Expand Down Expand Up @@ -545,7 +545,7 @@ public void testEntitlementUsingPlanName() throws Exception {
input.setExternalKey("somethingSpecial");
input.setPlanName("shotgun-monthly");

final Subscription entitlementJson = killBillClient.createSubscription(input, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, basicRequestOptions());
final Subscription entitlementJson = killBillClient.createSubscription(input, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, requestOptions);
Assert.assertEquals(entitlementJson.getProductName(), "Shotgun");
Assert.assertEquals(entitlementJson.getBillingPeriod(), BillingPeriod.MONTHLY);
Assert.assertEquals(entitlementJson.getPriceList(), DefaultPriceListSet.DEFAULT_PRICELIST_NAME);
Expand All @@ -556,7 +556,7 @@ public void testEntitlementUsingPlanName() throws Exception {
newInput.setAccountId(entitlementJson.getAccountId());
newInput.setSubscriptionId(entitlementJson.getSubscriptionId());
newInput.setPlanName("pistol-monthly");
final Subscription newEntitlementJson = killBillClient.updateSubscription(newInput, null, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, basicRequestOptions());
final Subscription newEntitlementJson = killBillClient.updateSubscription(newInput, null, null, DEFAULT_WAIT_COMPLETION_TIMEOUT_SEC, requestOptions);
Assert.assertEquals(newEntitlementJson.getProductName(), "Pistol");
Assert.assertEquals(newEntitlementJson.getBillingPeriod(), BillingPeriod.MONTHLY);
Assert.assertEquals(newEntitlementJson.getPriceList(), DefaultPriceListSet.DEFAULT_PRICELIST_NAME);
Expand Down
Expand Up @@ -751,7 +751,7 @@ public void testInvoiceMigration() throws Exception {

final Account accountWithBalance = killBillClient.getAccount(accountJson.getAccountId(), true, true);

final Invoice migrationInvoice = killBillClient.createMigrationInvoice(accountJson.getAccountId(), null, ImmutableList.<InvoiceItem>of(externalCharge), basicRequestOptions());
final Invoice migrationInvoice = killBillClient.createMigrationInvoice(accountJson.getAccountId(), null, ImmutableList.<InvoiceItem>of(externalCharge), requestOptions);
assertEquals(migrationInvoice.getBalance(), BigDecimal.ZERO);
assertEquals(migrationInvoice.getItems().size(), 1);
assertEquals(migrationInvoice.getItems().get(0).getAmount().compareTo(chargeAmount), 0);
Expand Down Expand Up @@ -786,7 +786,7 @@ public void testInvoiceTransferCreditToParentAccount() throws Exception {
Assert.assertEquals(parentInvoices.size(), 0);

// transfer credit to parent account
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), basicRequestOptions());
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), requestOptions);

childInvoices = killBillClient.getInvoicesForAccount(childAccount.getAccountId(), true, false);
Assert.assertEquals(childInvoices.size(), 2);
Expand All @@ -803,7 +803,7 @@ public void testInvoiceTransferCreditAccountNoParent() throws Exception {
final Account account = createAccount();

// transfer credit to parent account
killBillClient.transferChildCreditToParent(account.getAccountId(), basicRequestOptions());
killBillClient.transferChildCreditToParent(account.getAccountId(), requestOptions);

}

Expand All @@ -814,7 +814,7 @@ public void testInvoiceTransferCreditAccountNoCredit() throws Exception {
final Account childAccount = createAccount(parentAccount.getAccountId());

// transfer credit to parent account
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), basicRequestOptions());
killBillClient.transferChildCreditToParent(childAccount.getAccountId(), requestOptions);

}

Expand Down
Expand Up @@ -238,22 +238,22 @@ public void testWithFailedInvoicePayment() throws Exception {

final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();

InvoicePayments invoicePayments = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), basicRequestOptions());
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(), basicRequestOptions());
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, basicRequestOptions());
invoicePayments = killBillClient.getInvoicePaymentsForAccount(accountJson.getAccountId(), basicRequestOptions());
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());
Expand Down

1 comment on commit 1385d70

@pierre
Copy link
Member

@pierre pierre commented on 1385d70 Jan 25, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Yay! Cleanup!

Please sign in to comment.