killbill-aplcache
Changes
beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java 10(+6 -4)
beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestBillingAlignment.java 10(+6 -4)
beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java 119(+61 -58)
beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithOverdueEnforcementOffTag.java 13(+7 -6)
beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java 9(+5 -4)
beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java 111(+25 -86)
beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoInvoiceOffTag.java 41(+11 -30)
beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoPayOff.java 29(+8 -21)
osgi/killbill-osgi.iml 2(+1 -1)
subscription/src/test/java/com/ning/billing/subscription/api/migration/TestMigration.java 24(+12 -12)
subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairWithAO.java 52(+26 -26)
subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiChangePlan.java 14(+7 -7)
subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCreate.java 22(+11 -11)
Details
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
index 5d5fad9..4f1b82d 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
@@ -26,6 +26,7 @@ import com.ning.billing.beatrix.util.PaymentChecker.ExpectedPaymentCheck;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.Subscription;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
import com.ning.billing.invoice.api.Invoice;
@@ -141,12 +142,10 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
// We take april as it has 30 days (easier to play with BCD)
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDay(new LocalDate(2012, 4, 1));
-
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- final Subscription bpSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
//
// ADD ADD_ON ON THE SAME DAY TO TRIGGER PAYMENT
//
@@ -164,7 +163,10 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
paymentPluginApi.setPaymentRuntimeExceptionOnNextCalls(expectedRuntimeException);
}
- createBaseEntitlementAndCheckForCompletion(bundle.getId(), "Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, expectedEvents.toArray(new NextEvent[expectedEvents.size()]));
+ final DefaultEntitlement aoEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Telescopic-Scope", ProductCategory.BASE, BillingPeriod.MONTHLY,
+ expectedEvents.toArray(new NextEvent[expectedEvents.size()]));
+
+
Invoice invoice = invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), new LocalDate(2012, 5, 1), InvoiceItemType.RECURRING, new BigDecimal("399.95")));
if (expectedException == null && expectedRuntimeException == null) {
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestBillingAlignment.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestBillingAlignment.java
index 40c9d22..03c9da1 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestBillingAlignment.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestBillingAlignment.java
@@ -27,10 +27,13 @@ import com.ning.billing.beatrix.integration.TestIntegrationBase;
import com.ning.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.Subscription;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
import com.ning.billing.invoice.api.InvoiceItemType;
+import static org.testng.Assert.assertNotNull;
+
public class TestBillingAlignment extends TestIntegrationBase {
// TODO test fails as it should not create a proration when the chnage to annual occurs. Instaed we should restart from the data of the chnage
@@ -49,13 +52,12 @@ public class TestBillingAlignment extends TestIntegrationBase {
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDay(new LocalDate(2012, 4, 1));
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
// (Start with monthly that has a 'Account' billing alignment
//
- final Subscription bpSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 4, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
// GET OUT TRIAL
@@ -63,7 +65,7 @@ public class TestBillingAlignment extends TestIntegrationBase {
//
// Change plan to annual that has been configured to have a 'Subscription' billing alignment
- changeEntitlementAndCheckForCompletion(bpSubscription, "Shotgun", BillingPeriod.ANNUAL, NextEvent.CHANGE, NextEvent.INVOICE);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Shotgun", BillingPeriod.ANNUAL, null, NextEvent.CHANGE, NextEvent.INVOICE);
/*
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueBase.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueBase.java
index dc707e7..02dca81 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueBase.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueBase.java
@@ -65,12 +65,8 @@ public abstract class TestOverdueBase extends TestIntegrationBase {
assertNotNull(account);
paymentApi.addPaymentMethod(BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, account, true, paymentMethodPlugin, callContext);
-
- bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
productName = "Shotgun";
term = BillingPeriod.MONTHLY;
-
paymentPlugin.clear();
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
index ce1ef2e..d9ea99e 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
@@ -30,6 +30,9 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
+import com.ning.billing.entitlement.api.Entitlement;
+import com.ning.billing.entitlement.api.EntitlementApiException;
import com.ning.billing.subscription.api.user.SubscriptionUserApiException;
import com.ning.billing.subscription.api.user.Subscription;
import com.ning.billing.invoice.api.Invoice;
@@ -105,16 +108,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// 2012, 5, 31 => DAY 30 have to get out of trial {I0, P0}
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// 2012, 6, 8 => Retry P0
addDaysAndCheckForCompletion(8, NextEvent.PAYMENT_ERROR);
@@ -131,9 +134,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 6, 31 => P1 (We se 6/31 instead of 6/30 because invoice might happen later in that day)
addDaysAndCheckForCompletion(7, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// 2012, 7, 2 => Retry P0
addDaysAndCheckForCompletion(1, NextEvent.PAYMENT_ERROR);
@@ -169,7 +172,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
}
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
- checkChangePlanWithOverdueState(baseSubscription, false);
+ checkChangePlanWithOverdueState(baseEntitlement, false);
invoiceChecker.checkRepairedInvoice(account.getId(), 3,
callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
@@ -181,7 +184,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("154.85")),
// Credits consumed
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 23), new LocalDate(2012, 7, 23), InvoiceItemType.CBA_ADJ, new BigDecimal("-154.85")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Verify the account balance: 249.95 - 74.99 - 154.85
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-11.79")), 0);
@@ -198,16 +201,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// 2012, 5, 31 => DAY 30 have to get out of trial {I0, P0}
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// 2012, 6, 8 => Retry P0
addDaysAndCheckForCompletion(8, NextEvent.PAYMENT_ERROR);
@@ -224,9 +227,9 @@ public class TestOverdueIntegration extends TestOverdueBase {
// 2012, 6, 31 => P1 (We se 6/31 instead of 6/30 because invoice might happen later in that day)
addDaysAndCheckForCompletion(7, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// 2012, 7, 2 => Retry P0
addDaysAndCheckForCompletion(1, NextEvent.PAYMENT_ERROR);
@@ -264,7 +267,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Add 10 days to generate next invoice
- addDaysAndCheckForCompletion(10, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
+ addDaysAndCheckForCompletion(10, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT, NextEvent.PAYMENT);
invoiceChecker.checkRepairedInvoice(account.getId(), 3,
callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
@@ -277,7 +280,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
// Credits consumed
new ExpectedInvoiceItemCheck(new LocalDate(2012, 8, 2), new LocalDate(2012, 8, 2), InvoiceItemType.CBA_ADJ, new BigDecimal("-102.13")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 8, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 8, 31), callContext);
// Verify the account balance: 249.95 - 74.99 - 154.85
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(BigDecimal.ZERO), 0);
@@ -292,16 +295,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// 2012, 5, 31 => DAY 30 have to get out of trial {I0, P0}
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2013, 5, 31), InvoiceItemType.RECURRING, new BigDecimal("2399.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2013, 5, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2013, 5, 31), callContext);
// 2012, 6, 8 => Retry P0
addDaysAndCheckForCompletion(8, NextEvent.PAYMENT_ERROR);
@@ -344,7 +347,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Move to 2012, 7, 31 and Make a change of plan
addDaysAndCheckForCompletion(8);
- checkChangePlanWithOverdueState(baseSubscription, false);
+ checkChangePlanWithOverdueState(baseEntitlement, false);
invoiceChecker.checkRepairedInvoice(account.getId(), 2,
@@ -358,7 +361,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("599.95")),
// Credits consumed
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 7, 31), InvoiceItemType.CBA_ADJ, new BigDecimal("-599.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 8, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 8, 31), callContext);
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-1484.41")), 0);
}
@@ -375,16 +378,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
accountInternalApi.removePaymentMethod(account.getId(), internalCallContext);
// Create subscription
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment. A payment error, one for each invoice, should be on the bus (because there is no payment method)
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -400,32 +403,32 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(20, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Now we should be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// DAY 67 - 37 days after invoice
addDaysAndCheckForCompletion(2);
// Should still be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// DAY 75 - 45 days after invoice
addDaysAndCheckForCompletion(8);
// Should now be in OD2
checkODState("OD2");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// DAY 85 - 55 days after invoice
addDaysAndCheckForCompletion(10);
// Should now be in OD3
checkODState("OD3");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// Add a payment method and set it as default
paymentApi.addPaymentMethod(BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, account, true, paymentMethodPlugin, callContext);
@@ -439,7 +442,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
}
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
- checkChangePlanWithOverdueState(baseSubscription, false);
+ checkChangePlanWithOverdueState(baseEntitlement, false);
invoiceChecker.checkRepairedInvoice(account.getId(), 3,
callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
@@ -451,7 +454,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("116.09")),
// Credits consumed
new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 25), new LocalDate(2012, 7, 25), InvoiceItemType.CBA_ADJ, new BigDecimal("-116.09")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Verify the account balance: 249.95 - 124.98 - 116.09
assertEquals(invoiceUserApi.getAccountBalance(account.getId(), callContext).compareTo(new BigDecimal("-8.88")), 0);
@@ -462,10 +465,10 @@ public class TestOverdueIntegration extends TestOverdueBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
// Create a subscription without failing payments
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// Create an external charge on a new invoice
addDaysAndCheckForCompletion(5);
@@ -479,7 +482,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(25, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state - the invoice for the bundle has been paid, but not the invoice with the external charge
// We refresh overdue just to be safe, see below
@@ -507,16 +510,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
// Create subscription and don't fail payments
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -531,7 +534,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(20, NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -541,7 +544,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
refundPaymentAndCheckForCompletion(account, payment, NextEvent.INVOICE_ADJUSTMENT);
// We should now be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
}
@Test(groups = "slow")
@@ -549,16 +552,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
// Create subscription and don't fail payments
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -573,7 +576,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(20, NextEvent.INVOICE, NextEvent.PAYMENT);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -583,7 +586,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
createChargeBackAndCheckForCompletion(payment, NextEvent.INVOICE_ADJUSTMENT);
// We should now be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
}
@Test(groups = "slow")
@@ -592,16 +595,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -616,11 +619,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(20, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Now we should be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// We have two unpaid non-zero dollar invoices at this point
// Pay the first one via an external payment - we should then be 5 days apart from the second invoice
@@ -642,16 +645,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -666,11 +669,11 @@ public class TestOverdueIntegration extends TestOverdueBase {
addDaysAndCheckForCompletion(20, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 3, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 6, 30), new LocalDate(2012, 7, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// Now we should be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
// We have two unpaid non-zero dollar invoices at this point
// Adjust the first (and only) item of the first invoice - we should then be 5 days apart from the second invoice
@@ -683,7 +686,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
invoiceChecker.checkRepairedInvoice(account.getId(), 2,
callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")),
new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 5, 31), InvoiceItemType.ITEM_ADJ, new BigDecimal("-249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 7, 31), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 7, 31), callContext);
// DAY 70 - 10 days after second invoice
addDaysAndCheckForCompletion(5);
@@ -702,7 +705,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// We should now be in OD1
checkODState("OD1");
- checkChangePlanWithOverdueState(baseSubscription, true);
+ checkChangePlanWithOverdueState(baseEntitlement, true);
invoiceChecker.checkInvoice(account.getId(), 4, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 7, 31), new LocalDate(2012, 8, 31), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
@@ -718,16 +721,16 @@ public class TestOverdueIntegration extends TestOverdueBase {
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
}
- private void checkChangePlanWithOverdueState(final Subscription subscription, final boolean shouldFail) {
+ private void checkChangePlanWithOverdueState(final Entitlement entitlement, final boolean shouldFail) {
if (shouldFail) {
try {
- subscription.changePlan("Pistol", term, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow(), callContext);
- } catch (SubscriptionUserApiException e) {
+ entitlement.changePlan("Pistol", term, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow().toLocalDate(), callContext);
+ } catch (EntitlementApiException e) {
assertTrue(e.getCause() instanceof BlockingApiException);
}
} else {
// Upgrade - we don't expect a payment here due to the scenario (the account will have some CBA)
- changeEntitlementAndCheckForCompletion(subscription, "Assault-Rifle", BillingPeriod.MONTHLY, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
+ changeEntitlementAndCheckForCompletion(entitlement, "Assault-Rifle", BillingPeriod.MONTHLY, null, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
}
}
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithOverdueEnforcementOffTag.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithOverdueEnforcementOffTag.java
index 333e31b..5c679fb 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithOverdueEnforcementOffTag.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithOverdueEnforcementOffTag.java
@@ -26,6 +26,7 @@ import com.ning.billing.ObjectType;
import com.ning.billing.api.TestApiListener.NextEvent;
import com.ning.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.Subscription;
import com.ning.billing.invoice.api.InvoiceItemType;
import com.ning.billing.util.svcapi.junction.DefaultBlockingState;
@@ -71,16 +72,16 @@ public class TestOverdueWithOverdueEnforcementOffTag extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// DAY 36 -- RIGHT AFTER OD1
addDaysAndCheckForCompletion(6);
@@ -104,16 +105,16 @@ public class TestOverdueWithOverdueEnforcementOffTag extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// DAY 36 -- RIGHT AFTER OD1
addDaysAndCheckForCompletion(6);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
index e053ac7..30da00b 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueWithSubscriptionCancellation.java
@@ -26,6 +26,7 @@ import org.testng.annotations.Test;
import com.ning.billing.api.TestApiListener.NextEvent;
import com.ning.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.Subscription;
import com.ning.billing.subscription.api.user.SubscriptionState;
import com.ning.billing.invoice.api.InvoiceItemType;
@@ -64,16 +65,16 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
- final Subscription baseSubscription = createBaseEntitlementAndCheckForCompletion(bundle.getId(), productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 5, 1), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
// DAY 30 have to get out of trial before first payment
addDaysAndCheckForCompletion(30, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT_ERROR);
invoiceChecker.checkInvoice(account.getId(), 2, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 31), new LocalDate(2012, 6, 30), InvoiceItemType.RECURRING, new BigDecimal("249.95")));
- invoiceChecker.checkChargedThroughDate(baseSubscription.getId(), new LocalDate(2012, 6, 30), callContext);
+ invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 6, 30), callContext);
// Should still be in clear state
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
@@ -84,7 +85,7 @@ public class TestOverdueWithSubscriptionCancellation extends TestOverdueBase {
// Should be in OD1
checkODState("OD1");
- final Subscription cancelledBaseSubscription = subscriptionUserApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final Subscription cancelledBaseSubscription = ((DefaultEntitlement) entitlementApi.getEntitlementFromId(baseEntitlement.getId(), callContext)).getSubscription();
assertTrue(cancelledBaseSubscription.getState() == SubscriptionState.CANCELLED);
}
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestBundleTransfer.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestBundleTransfer.java
index e3cfad7..7ecce7c 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestBundleTransfer.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestBundleTransfer.java
@@ -24,6 +24,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceItem;
import com.ning.billing.invoice.api.InvoiceItemType;
@@ -53,7 +54,6 @@ public class TestBundleTransfer extends TestIntegrationBase {
final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "mycutebundle", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
@@ -61,18 +61,12 @@ public class TestBundleTransfer extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
assertTrue(busHandler.isCompleted(DELAY));
assertListenerStatus();
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
-
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvent(NextEvent.PHASE);
@@ -113,7 +107,6 @@ public class TestBundleTransfer extends TestIntegrationBase {
final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "mycutebundle", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
@@ -121,18 +114,12 @@ public class TestBundleTransfer extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
assertListenerStatus();
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvent(NextEvent.PHASE);
@@ -180,26 +167,20 @@ public class TestBundleTransfer extends TestIntegrationBase {
final DateTime initialDate = new DateTime(2012, 4, 1, 0, 15, 42, 0, testTimeZone);
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "mycutebundle", callContext);
-
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
assertListenerStatus();
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvent(NextEvent.PHASE);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestCustomFieldApi.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestCustomFieldApi.java
index 30bd0e0..5d1c8f3 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestCustomFieldApi.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestCustomFieldApi.java
@@ -32,6 +32,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
@@ -84,21 +85,12 @@ public class TestCustomFieldApi extends TestIntegrationBase {
//
// Create necessary logic to end up with an Invoice object on that account.
//
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
final List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
Assert.assertEquals(invoices.size(), 1);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
index 583c10f..d8d9e46 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegration.java
@@ -36,10 +36,10 @@ import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.entitlement.api.DefaultEntitlement;
-import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceItemType;
import com.ning.billing.payment.api.PaymentStatus;
+import com.ning.billing.subscription.api.user.SubscriptionData;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
@@ -101,8 +101,8 @@ public class TestIntegration extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
- SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlementAndCheckForCompletion.getSubscription());
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlement.getSubscription());
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
// No end date for the trial item (fixed price of zero), and CTD should be today (i.e. when the trial started)
invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
@@ -110,7 +110,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN IMMEDIATELY AND EXPECT BOTH EVENTS: NextEvent.CHANGE NextEvent.INVOICE
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Assault-Rifle", BillingPeriod.MONTHLY, NextEvent.CHANGE, NextEvent.INVOICE));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Assault-Rifle", BillingPeriod.MONTHLY, null, NextEvent.CHANGE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
@@ -128,7 +128,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN EOT AND EXPECT NOTHING
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Pistol", BillingPeriod.MONTHLY));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Pistol", BillingPeriod.MONTHLY, null);
//
// MOVE TIME AFTER CTD AND EXPECT BOTH EVENTS : NextEvent.CHANGE NextEvent.INVOICE
@@ -157,7 +157,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// FINALLY CANCEL SUBSCRIPTION EOT
//
- subscription = subscriptionDataFromSubscription(cancelEntitlementAndCheckForCompletion(subscription, clock.getUTCNow()));
+ cancelEntitlementAndCheckForCompletion(baseEntitlement, clock.getUTCNow());
// MOVE AFTER CANCEL DATE AND EXPECT EVENT : NextEvent.CANCEL
addDaysAndCheckForCompletion(31, NextEvent.CANCEL);
@@ -182,8 +182,8 @@ public class TestIntegration extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
- SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlementAndCheckForCompletion.getSubscription());
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlement.getSubscription());
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
// No end date for the trial item (fixed price of zero), and CTD should be today (i.e. when the trial started)
invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
@@ -191,7 +191,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN IMMEDIATELY AND EXPECT BOTH EVENTS: NextEvent.CHANGE NextEvent.INVOICE
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Assault-Rifle", BillingPeriod.MONTHLY, NextEvent.CHANGE, NextEvent.INVOICE));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Assault-Rifle", BillingPeriod.MONTHLY, null , NextEvent.CHANGE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
@@ -209,7 +209,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN EOT AND EXPECT NOTHING
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Pistol", BillingPeriod.MONTHLY));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Pistol", BillingPeriod.MONTHLY, null);
//
// MOVE TIME AFTER CTD AND EXPECT BOTH EVENTS : NextEvent.CHANGE NextEvent.INVOICE
@@ -238,7 +238,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// FINALLY CANCEL SUBSCRIPTION EOT
//
- subscription = subscriptionDataFromSubscription(cancelEntitlementAndCheckForCompletion(subscription, clock.getUTCNow()));
+ cancelEntitlementAndCheckForCompletion(baseEntitlement, clock.getUTCNow());
// MOVE AFTER CANCEL DATE AND EXPECT EVENT : NextEvent.CANCEL
addDaysAndCheckForCompletion(31, NextEvent.CANCEL);
@@ -263,8 +263,8 @@ public class TestIntegration extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
- SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlementAndCheckForCompletion.getSubscription());
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ SubscriptionData subscription = subscriptionDataFromSubscription(baseEntitlement.getSubscription());
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
@@ -274,7 +274,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN IMMEDIATELY AND EXPECT BOTH EVENTS: NextEvent.CHANGE NextEvent.INVOICE
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Assault-Rifle", BillingPeriod.MONTHLY, NextEvent.CHANGE, NextEvent.INVOICE));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Assault-Rifle", BillingPeriod.MONTHLY, null, NextEvent.CHANGE, NextEvent.INVOICE);
invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
@@ -298,7 +298,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// CHANGE PLAN EOT AND EXPECT NOTHING
//
- subscription = subscriptionDataFromSubscription(changeEntitlementAndCheckForCompletion(subscription, "Pistol", BillingPeriod.MONTHLY));
+ changeEntitlementAndCheckForCompletion(baseEntitlement, "Pistol", BillingPeriod.MONTHLY, null);
//
// MOVE TIME AFTER CTD AND EXPECT BOTH EVENTS : NextEvent.CHANGE NextEvent.INVOICE
@@ -327,7 +327,7 @@ public class TestIntegration extends TestIntegrationBase {
//
// FINALLY CANCEL SUBSCRIPTION EOT
//
- subscription = subscriptionDataFromSubscription(cancelEntitlementAndCheckForCompletion(subscription, clock.getUTCNow()));
+ cancelEntitlementAndCheckForCompletion(baseEntitlement, clock.getUTCNow());
// MOVE AFTER CANCEL DATE AND EXPECT EVENT : NextEvent.CANCEL
addDaysAndCheckForCompletion(31, NextEvent.CANCEL);
@@ -394,7 +394,7 @@ public class TestIntegration extends TestIntegrationBase {
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
// MOVE CLOCK A LITTLE BIT-- STILL IN TRIAL
@@ -406,11 +406,11 @@ public class TestIntegration extends TestIntegrationBase {
busHandler.pushExpectedEvent(NextEvent.INVOICE);
busHandler.pushExpectedEvent(NextEvent.PAYMENT);
- final DefaultEntitlement aoEntitlement1 = addAOEntitlementAndCheckForCompletion(baseEntitlementAndCheckForCompletion.getId(), "Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,
+ final DefaultEntitlement aoEntitlement1 = addAOEntitlementAndCheckForCompletion(baseEntitlement.getId(), "Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,
NextEvent.CREATE, NextEvent.INVOICE, NextEvent.PAYMENT);
- final DefaultEntitlement aoEntitlement2 = addAOEntitlementAndCheckForCompletion(baseEntitlementAndCheckForCompletion.getId(), "Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,
+ final DefaultEntitlement aoEntitlement2 = addAOEntitlementAndCheckForCompletion(baseEntitlement.getId(), "Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,
NextEvent.CREATE, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -474,15 +474,15 @@ public class TestIntegration extends TestIntegrationBase {
busHandler.pushExpectedEvent(NextEvent.CREATE);
busHandler.pushExpectedEvent(NextEvent.INVOICE);
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
- assertNotNull(baseEntitlementAndCheckForCompletion);
+ assertNotNull(baseEntitlement);
assertTrue(busHandler.isCompleted(DELAY));
//
// VERIFY CTD HAS BEEN SET
//
- final SubscriptionData subscription = (SubscriptionData) baseEntitlementAndCheckForCompletion.getSubscription();
+ final SubscriptionData subscription = (SubscriptionData) baseEntitlement.getSubscription();
final DateTime startDate = subscription.getCurrentPhaseStart();
final BigDecimal rate = subscription.getCurrentPhase().getFixedPrice().getPrice(Currency.USD);
final int invoiceItemCount = 1;
@@ -497,7 +497,7 @@ public class TestIntegration extends TestIntegrationBase {
clock.addDeltaFromReality(AT_LEAST_ONE_MONTH_MS);
assertTrue(busHandler.isCompleted(DELAY));
- final DefaultEntitlement entitlement = (DefaultEntitlement) entitlementApi.getEntitlementFromId(baseEntitlementAndCheckForCompletion.getId(), callContext);
+ final DefaultEntitlement entitlement = (DefaultEntitlement) entitlementApi.getEntitlementFromId(baseEntitlement.getId(), callContext);
entitlement.cancelEntitlementWithDate(clock.getUTCNow().toLocalDate(), callContext);
// MOVE AFTER CANCEL DATE AND EXPECT EVENT : NextEvent.CANCEL
@@ -535,7 +535,7 @@ public class TestIntegration extends TestIntegrationBase {
final String planSetName = "DEFAULT";
- final DefaultEntitlement baseEntitlementAndCheckForCompletion = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "bundleKey", productName, ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(accountId, callContext);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
index 2173510..9b05a8b 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
@@ -54,6 +54,7 @@ import com.ning.billing.beatrix.util.PaymentChecker;
import com.ning.billing.beatrix.util.RefundChecker;
import com.ning.billing.beatrix.util.SubscriptionChecker;
import com.ning.billing.bus.api.PersistentBus;
+import com.ning.billing.catalog.api.ActionPolicy;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
@@ -288,33 +289,6 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implemen
final Entitlement entitlement = entitlementApi.getEntitlementFromId(subscriptionId, callContext);
-
- /*
- final List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(accountId);
- final List<InvoiceItem> invoiceItems = new ArrayList<InvoiceItem>();
- for (final Invoice invoice : invoices) {
- invoiceItems.addAll(invoice.getInvoiceItems());
- }
- assertEquals(invoiceItems.size(), totalInvoiceItemCount);
-
- boolean wasFound = false;
-
- // We implicitly assume here that the account timezone is the same as the one for startDate/endDate
- for (final InvoiceItem item : invoiceItems) {
- if (item.getStartDate().compareTo(new LocalDate(startDate)) == 0) {
- if ((item.getEndDate() == null && endDate == null) || (item.getEndDate() != null && new LocalDate(endDate).compareTo(item.getEndDate()) == 0)) {
- if (item.getAmount().compareTo(amount) == 0) {
- wasFound = true;
- break;
- }
- }
- }
- }
-
- if (!wasFound) {
- fail();
- }
- */
final Subscription subscription = ((DefaultEntitlement) entitlement).getSubscription();
final DateTime ctd = subscription.getChargedThroughDate();
assertNotNull(ctd);
@@ -551,16 +525,21 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implemen
protected DefaultEntitlement changeEntitlementAndCheckForCompletion(final Entitlement entitlement,
- final String productName,
- final BillingPeriod billingPeriod,
- final NextEvent... events) {
+ final String productName,
+ final BillingPeriod billingPeriod,
+ final ActionPolicy billingPolicy,
+ final NextEvent... events) {
return (DefaultEntitlement) doCallAndCheckForCompletion(new Function<Void, Entitlement>() {
@Override
public Entitlement apply(@Nullable final Void dontcare) {
try {
// Need to fetch again to get latest CTD updated from the system
final Entitlement refreshedEntitlement = entitlementApi.getEntitlementFromId(entitlement.getId(), callContext);
- refreshedEntitlement.changePlan(productName, billingPeriod, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow().toLocalDate(), callContext);
+ if (billingPolicy == null) {
+ refreshedEntitlement.changePlan(productName, billingPeriod, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow().toLocalDate(), callContext);
+ } else {
+ refreshedEntitlement.changePlanOverrideBillingPolicy(productName, billingPeriod, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow().toLocalDate(), billingPolicy ,callContext);
+ }
return refreshedEntitlement;
} catch (EntitlementApiException e) {
fail(e.getMessage());
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
index 42a5341..9243b2a 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationInvoiceWithRepairLogic.java
@@ -36,17 +36,15 @@ import com.ning.billing.beatrix.util.PaymentChecker.ExpectedPaymentCheck;
import com.ning.billing.catalog.api.ActionPolicy;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
-import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
-import com.ning.billing.subscription.api.user.SubscriptionData;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceItemType;
import com.ning.billing.invoice.generator.DefaultInvoiceGeneratorWithSwitchRepairLogic;
import com.ning.billing.invoice.generator.DefaultInvoiceGeneratorWithSwitchRepairLogic.REPAIR_INVOICE_LOGIC;
import com.ning.billing.payment.api.Payment;
import com.ning.billing.payment.api.PaymentStatus;
-import com.ning.billing.subscription.api.user.SubscriptionBundle;
import com.google.common.collect.ImmutableList;
@@ -80,20 +78,13 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
final BillingPeriod term = BillingPeriod.MONTHLY;
final String pricelistName = PriceListSet.DEFAULT_PRICELIST_NAME;
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), UUID.randomUUID().toString(), callContext);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, pricelistName, null);
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1);
@@ -147,10 +138,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Force a plan change
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- bpSubscription.changePlanWithPolicy("Blowdart", term, pricelistName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
@@ -188,20 +176,11 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
final BillingPeriod term = BillingPeriod.MONTHLY;
final String pricelistName = PriceListSet.DEFAULT_PRICELIST_NAME;
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), UUID.randomUUID().toString(), callContext);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, pricelistName, null);
-
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1);
@@ -217,10 +196,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Change plan in trial - there is no repair
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE);
- bpSubscription.changePlanWithPolicy("Assault-Rifle", term, pricelistName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Assault-Rifle", term, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 2);
@@ -260,12 +236,9 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Force another plan change
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
// Move the clock to 2012-05-07
clock.addDays(5);
- bpSubscription.changePlanWithPolicy("Blowdart", term, pricelistName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Blowdart", term, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 4);
@@ -292,12 +265,9 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// Force another plan change
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
// Move the clock to 2012-05-08
clock.addDays(1);
- bpSubscription.changePlanWithPolicy("Pistol", term, pricelistName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, "Pistol", term, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 5);
@@ -429,7 +399,6 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
@@ -438,18 +407,12 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
+
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -466,12 +429,9 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertTrue(bpSubscription.changePlanWithPolicy(productName, BillingPeriod.MONTHLY, planSetName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ bpEntitlement = changeEntitlementAndCheckForCompletion(bpEntitlement, productName, term, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
@@ -553,7 +513,6 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
@@ -562,18 +521,12 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
+
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -590,9 +543,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertTrue(bpSubscription.changePlanWithPolicy(productName, BillingPeriod.MONTHLY, planSetName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
assertTrue(busHandler.isCompleted(DELAY));
assertListenerStatus();
@@ -669,7 +620,6 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
@@ -678,18 +628,11 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -733,11 +676,7 @@ public class TestIntegrationInvoiceWithRepairLogic extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertTrue(bpSubscription.changePlanWithPolicy(productName, BillingPeriod.MONTHLY, planSetName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoInvoiceOffTag.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoInvoiceOffTag.java
index e8b8f87..728568e 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoInvoiceOffTag.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoInvoiceOffTag.java
@@ -28,10 +28,9 @@ import com.ning.billing.ObjectType;
import com.ning.billing.account.api.Account;
import com.ning.billing.api.TestApiListener.NextEvent;
import com.ning.billing.catalog.api.BillingPeriod;
-import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
-import com.ning.billing.subscription.api.user.SubscriptionData;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceUserApi;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
@@ -67,9 +66,6 @@ public class TestIntegrationWithAutoInvoiceOffTag extends TestIntegrationBase {
super.beforeMethod();
account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
assertNotNull(account);
-
- bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
productName = "Shotgun";
term = BillingPeriod.MONTHLY;
planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -82,12 +78,8 @@ public class TestIntegrationWithAutoInvoiceOffTag extends TestIntegrationBase {
add_AUTO_INVOICING_OFF_Tag(account.getId(), ObjectType.ACCOUNT);
// set next invoice to fail and create network
- busHandler.pushExpectedEvents(NextEvent.CREATE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
-
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE);
+ assertNotNull(bpEntitlement);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 0);
@@ -118,17 +110,14 @@ public class TestIntegrationWithAutoInvoiceOffTag extends TestIntegrationBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
// set next invoice to fail and create network
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1); // first invoice is generated immediately after creation can't reliably stop it
- add_AUTO_INVOICING_OFF_Tag(baseSubscription.getBundleId(), ObjectType.BUNDLE);
+ add_AUTO_INVOICING_OFF_Tag(bpEntitlement.getSubscription().getBundleId(), ObjectType.BUNDLE);
busHandler.pushExpectedEvents(NextEvent.PHASE);
clock.addDays(40); // DAY 40 out of trial
@@ -145,24 +134,16 @@ public class TestIntegrationWithAutoInvoiceOffTag extends TestIntegrationBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
// set next invoice to fail and create network
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
- final SubscriptionBundle bundle2 = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final SubscriptionData baseSubscription2 = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle2.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription2);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement2 = createBaseEntitlementAndCheckForCompletion(account.getId(), "whatever", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement2);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 2); // first invoice is generated immediately after creation can't reliably stop it
- add_AUTO_INVOICING_OFF_Tag(baseSubscription.getBundleId(), ObjectType.BUNDLE);
+ add_AUTO_INVOICING_OFF_Tag(bpEntitlement.getSubscription().getBundleId(), ObjectType.BUNDLE);
busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
clock.addDays(40); // DAY 40 out of trial
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoPayOff.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoPayOff.java
index 94ffa29..1ae2568 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoPayOff.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationWithAutoPayOff.java
@@ -32,6 +32,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceUserApi;
@@ -75,9 +76,6 @@ public class TestIntegrationWithAutoPayOff extends TestIntegrationBase {
super.beforeMethod();
account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
assertNotNull(account);
-
- bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
productName = "Shotgun";
term = BillingPeriod.MONTHLY;
planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
@@ -88,12 +86,9 @@ public class TestIntegrationWithAutoPayOff extends TestIntegrationBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
add_AUTO_PAY_OFF_Tag(account.getId(), ObjectType.ACCOUNT);
- busHandler.pushExpectedEvents(NextEvent.INVOICE);
- busHandler.pushExpectedEvents(NextEvent.CREATE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1);
@@ -136,12 +131,8 @@ public class TestIntegrationWithAutoPayOff extends TestIntegrationBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
add_AUTO_PAY_OFF_Tag(account.getId(), ObjectType.ACCOUNT);
- busHandler.pushExpectedEvents(NextEvent.INVOICE);
- busHandler.pushExpectedEvents(NextEvent.CREATE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1);
@@ -202,12 +193,8 @@ public class TestIntegrationWithAutoPayOff extends TestIntegrationBase {
clock.setTime(new DateTime(2012, 5, 1, 0, 3, 42, 0));
add_AUTO_PAY_OFF_Tag(account.getId(), ObjectType.ACCOUNT);
- busHandler.pushExpectedEvents(NextEvent.INVOICE);
- busHandler.pushExpectedEvents(NextEvent.CREATE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
Collection<Invoice> invoices = invoiceApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 1);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java
index 50c04d2..be8d091 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java
@@ -36,6 +36,7 @@ import com.ning.billing.beatrix.util.RefundChecker.ExpectedRefundCheck;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceItem;
@@ -48,6 +49,8 @@ import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
+import static org.testng.Assert.assertNotNull;
+
public class TestPaymentRefund extends TestIntegrationBase {
// Setup for all tests below
@@ -103,17 +106,17 @@ public class TestPaymentRefund extends TestIntegrationBase {
// set clock to the initial start date
clock.setTime(initialCreationDate);
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
invoiceItemCount = 0;
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- SubscriptionData subscription = subscriptionDataFromSubscription(createBaseEntitlementAndCheckForCompletion(bundle.getId(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
+
invoiceChecker.checkInvoice(account.getId(), ++invoiceItemCount, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
// No end date for the trial item (fixed price of zero), and CTD should be today (i.e. when the trial started)
- invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
+ invoiceChecker.checkChargedThroughDate(bpEntitlement.getId(), clock.getUTCToday(), callContext);
setDateAndCheckForCompletion(new DateTime(2012, 3, 2, 23, 59, 59, 0, testTimeZone), NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
invoice = invoiceChecker.checkInvoice(account.getId(), ++invoiceItemCount, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2),
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPublicBus.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPublicBus.java
index 4dfeb9c..5f7a1b3 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPublicBus.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPublicBus.java
@@ -30,6 +30,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.notification.plugin.api.ExtBusEvent;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
@@ -95,7 +96,6 @@ public class TestPublicBus extends TestIntegrationBase {
// set clock to the initial start date
clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever2", callContext);
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
@@ -104,14 +104,8 @@ public class TestPublicBus extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvent(NextEvent.CREATE);
- busHandler.pushExpectedEvent(NextEvent.INVOICE);
-
- SubscriptionData subscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
-
- assertNotNull(subscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
await().atMost(10, SECONDS).until(new Callable<Boolean>() {
@Override
@@ -120,9 +114,5 @@ public class TestPublicBus extends TestIntegrationBase {
return externalBusCount.get() == 4;
}
});
-
-
}
-
-
}
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestRepairIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestRepairIntegration.java
index 2f16774..b96c643 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestRepairIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestRepairIntegration.java
@@ -34,6 +34,8 @@ import com.ning.billing.catalog.api.PhaseType;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
+import com.ning.billing.entitlement.api.Entitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.subscription.api.user.SubscriptionEvents;
import com.ning.billing.subscription.api.SubscriptionTransitionType;
@@ -71,37 +73,19 @@ public class TestRepairIntegration extends TestIntegrationBase {
final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(25));
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
-
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.MONTHLY;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
- busHandler.pushExpectedEvent(NextEvent.CREATE);
- busHandler.pushExpectedEvent(NextEvent.INVOICE);
- final SubscriptionData baseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null), null, callContext));
- assertNotNull(baseSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
// MOVE CLOCK A LITTLE BIT-- STILL IN TRIAL
Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(3));
clock.addDeltaFromReality(it.toDurationMillis());
- busHandler.pushExpectedEvent(NextEvent.CREATE);
- busHandler.pushExpectedEvent(NextEvent.INVOICE);
- busHandler.pushExpectedEvent(NextEvent.PAYMENT);
- final SubscriptionData aoSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier("Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null), null, callContext));
- assertTrue(busHandler.isCompleted(DELAY));
-
- busHandler.pushExpectedEvent(NextEvent.CREATE);
- busHandler.pushExpectedEvent(NextEvent.INVOICE);
- busHandler.pushExpectedEvent(NextEvent.PAYMENT);
- final SubscriptionData aoSubscription2 = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- new PlanPhaseSpecifier("Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null), null, callContext));
- assertTrue(busHandler.isCompleted(DELAY));
-
+ final DefaultEntitlement aoEntitlement1 = addAOEntitlementAndCheckForCompletion(bpEntitlement.getId(), "Telescopic-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,NextEvent.CREATE, NextEvent.INVOICE, NextEvent.PAYMENT);
+ final DefaultEntitlement aoEntitlement2 = addAOEntitlementAndCheckForCompletion(bpEntitlement.getId(), "Laser-Scope", ProductCategory.ADD_ON, BillingPeriod.MONTHLY,NextEvent.CREATE, NextEvent.INVOICE, NextEvent.PAYMENT);
// MOVE CLOCK A LITTLE BIT MORE -- EITHER STAY IN TRIAL OR GET OUT
final int duration = inTrial ? 3 : 35;
@@ -119,17 +103,17 @@ public class TestRepairIntegration extends TestIntegrationBase {
}
final boolean ifRepair = false;
if (ifRepair) {
- BundleTimeline bundleRepair = repairApi.getBundleTimeline(bundle.getId(), callContext);
+ BundleTimeline bundleRepair = repairApi.getBundleTimeline(bpEntitlement.getSubscription().getBundleId(), callContext);
sortEventsOnBundle(bundleRepair);
// Quick check
- SubscriptionTimeline bpRepair = getSubscriptionRepair(baseSubscription.getId(), bundleRepair);
+ SubscriptionTimeline bpRepair = getSubscriptionRepair(bpEntitlement.getId(), bundleRepair);
assertEquals(bpRepair.getExistingEvents().size(), 2);
- final SubscriptionTimeline aoRepair = getSubscriptionRepair(aoSubscription.getId(), bundleRepair);
+ final SubscriptionTimeline aoRepair = getSubscriptionRepair(aoEntitlement1.getId(), bundleRepair);
assertEquals(aoRepair.getExistingEvents().size(), 2);
- final SubscriptionTimeline aoRepair2 = getSubscriptionRepair(aoSubscription2.getId(), bundleRepair);
+ final SubscriptionTimeline aoRepair2 = getSubscriptionRepair(aoEntitlement2.getId(), bundleRepair);
assertEquals(aoRepair2.getExistingEvents().size(), 2);
final DateTime bpChangeDate = clock.getUTCNow().minusDays(1);
@@ -140,9 +124,9 @@ public class TestRepairIntegration extends TestIntegrationBase {
final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Assault-Rifle", ProductCategory.BASE, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.TRIAL);
final NewEvent ne = createNewEvent(SubscriptionTransitionType.CHANGE, bpChangeDate, spec);
- bpRepair = createSubscriptionReapir(baseSubscription.getId(), des, Collections.singletonList(ne));
+ bpRepair = createSubscriptionReapir(bpEntitlement.getId(), des, Collections.singletonList(ne));
- bundleRepair = createBundleRepair(bundle.getId(), bundleRepair.getViewId(), Collections.singletonList(bpRepair));
+ bundleRepair = createBundleRepair(bpEntitlement.getSubscription().getBundleId(), bundleRepair.getViewId(), Collections.singletonList(bpRepair));
// TIME TO REPAIR
busHandler.pushExpectedEvent(NextEvent.INVOICE);
@@ -151,18 +135,19 @@ public class TestRepairIntegration extends TestIntegrationBase {
repairApi.repairBundle(bundleRepair, false, callContext);
assertTrue(busHandler.isCompleted(DELAY));
- final SubscriptionData newAoSubscription = subscriptionDataFromSubscription(subscriptionUserApi.getSubscriptionFromId(aoSubscription.getId(), callContext));
+
+ final SubscriptionData newAoSubscription = (SubscriptionData) aoEntitlement1.getSubscription();
assertEquals(newAoSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- final SubscriptionData newAoSubscription2 = subscriptionDataFromSubscription(subscriptionUserApi.getSubscriptionFromId(aoSubscription2.getId(), callContext));
+ final SubscriptionData newAoSubscription2 = (SubscriptionData) aoEntitlement2.getSubscription();
assertEquals(newAoSubscription2.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription2.getAllTransitions().size(), 2);
assertEquals(newAoSubscription2.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- final SubscriptionData newBaseSubscription = subscriptionDataFromSubscription(subscriptionUserApi.getSubscriptionFromId(baseSubscription.getId(), callContext));
+ final SubscriptionData newBaseSubscription = (SubscriptionData) bpEntitlement.getSubscription();
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestSubscription.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestSubscription.java
index 029a5bc..a6e8096 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestSubscription.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestSubscription.java
@@ -31,6 +31,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceItemType;
@@ -53,7 +54,6 @@ public class TestSubscription extends TestIntegrationBase {
// Set clock to the initial start date - we implicitly assume here that the account timezone is UTC
clock.setDeltaFromReality(today.toDateTimeAtCurrentTime(DateTimeZone.UTC).getMillis() - clock.getUTCNow().getMillis());
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
@@ -62,18 +62,12 @@ public class TestSubscription extends TestIntegrationBase {
//
// CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
//
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
assertEquals(invoiceUserApi.getInvoicesByAccount(account.getId(), callContext).size(), 1);
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(bpEntitlement.getSubscription().getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
// Move out of trials for interesting invoices adjustments
busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
@@ -90,12 +84,7 @@ public class TestSubscription extends TestIntegrationBase {
//
// FORCE AN IMMEDIATE CHANGE OF THE BILLING PERIOD
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertTrue(bpSubscription.changePlanWithPolicy(productName, BillingPeriod.MONTHLY, planSetName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
-
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.MONTHLY, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 3);
@@ -114,11 +103,7 @@ public class TestSubscription extends TestIntegrationBase {
//
// FORCE ANOTHER CHANGE
//
- busHandler.pushExpectedEvents(NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
- assertTrue(bpSubscription.changePlanWithPolicy(productName, BillingPeriod.ANNUAL, planSetName, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertEquals(subscriptionUserApi.getSubscriptionFromId(bpSubscription.getId(), callContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ changeEntitlementAndCheckForCompletion(bpEntitlement, productName, BillingPeriod.ANNUAL, ActionPolicy.IMMEDIATE, NextEvent.CHANGE, NextEvent.INVOICE, NextEvent.INVOICE_ADJUSTMENT);
invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
assertEquals(invoices.size(), 4);
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestTagApi.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestTagApi.java
index ff98762..6dd76b9 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestTagApi.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestTagApi.java
@@ -30,6 +30,7 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.DefaultEntitlement;
import com.ning.billing.subscription.api.user.SubscriptionData;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.subscription.api.user.SubscriptionBundle;
@@ -80,21 +81,13 @@ public class TestTagApi extends TestIntegrationBase {
//
// Create necessary logic to end up with an Invoice object on that account.
//
- final SubscriptionBundle bundle = subscriptionUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
final String productName = "Shotgun";
final BillingPeriod term = BillingPeriod.ANNUAL;
final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
- busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.INVOICE);
- final PlanPhaseSpecifier bpPlanPhaseSpecifier = new PlanPhaseSpecifier(productName, ProductCategory.BASE, term, planSetName, null);
- final SubscriptionData bpSubscription = subscriptionDataFromSubscription(subscriptionUserApi.createSubscription(bundle.getId(),
- bpPlanPhaseSpecifier,
- null,
- callContext));
- assertNotNull(bpSubscription);
- assertTrue(busHandler.isCompleted(DELAY));
- assertListenerStatus();
+ final DefaultEntitlement bpEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ assertNotNull(bpEntitlement);
final List<Invoice> invoices = invoiceUserApi.getInvoicesByAccount(account.getId(), callContext);
Assert.assertEquals(invoices.size(), 1);
osgi/killbill-osgi.iml 2(+1 -1)
diff --git a/osgi/killbill-osgi.iml b/osgi/killbill-osgi.iml
index e0c8736..e7e9b77 100644
--- a/osgi/killbill-osgi.iml
+++ b/osgi/killbill-osgi.iml
@@ -4,8 +4,8 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
diff --git a/osgi-bundles/killbill-osgi-all-bundles.iml b/osgi-bundles/killbill-osgi-all-bundles.iml
index d043fc2..9a514de 100644
--- a/osgi-bundles/killbill-osgi-all-bundles.iml
+++ b/osgi-bundles/killbill-osgi-all-bundles.iml
@@ -4,6 +4,7 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
diff --git a/osgi-bundles/libs/killbill/killbill-osgi-bundles-lib-killbill.iml b/osgi-bundles/libs/killbill/killbill-osgi-bundles-lib-killbill.iml
index 66797cd..7f58107 100644
--- a/osgi-bundles/libs/killbill/killbill-osgi-bundles-lib-killbill.iml
+++ b/osgi-bundles/libs/killbill/killbill-osgi-bundles-lib-killbill.iml
@@ -4,10 +4,10 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
diff --git a/osgi-bundles/tests/killbill-osgi-test-bundles.iml b/osgi-bundles/tests/killbill-osgi-test-bundles.iml
index e2309b3..eecd27e 100644
--- a/osgi-bundles/tests/killbill-osgi-test-bundles.iml
+++ b/osgi-bundles/tests/killbill-osgi-test-bundles.iml
@@ -4,6 +4,8 @@
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
+ <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+ <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/migration/TestMigration.java b/subscription/src/test/java/com/ning/billing/subscription/api/migration/TestMigration.java
index d5529aa..9dc7fc4 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/migration/TestMigration.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/migration/TestMigration.java
@@ -58,11 +58,11 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription subscription = subscriptions.get(0);
assertTrue(subscription.getStartDate().compareTo(startDate) == 0);
@@ -93,11 +93,11 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 2);
final Subscription baseSubscription = (subscriptions.get(0).getCurrentPlan().getProduct().getCategory() == ProductCategory.BASE) ?
@@ -141,12 +141,12 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
//assertEquals(bundle.getStartDate(), effectiveDate);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription subscription = subscriptions.get(0);
assertTrue(subscription.getStartDate().compareTo(startDate) == 0);
@@ -187,11 +187,11 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription subscription = subscriptions.get(0);
@@ -235,11 +235,11 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription subscription = subscriptions.get(0);
//assertDateWithin(subscription.getStartDate(), beforeMigration, afterMigration);
@@ -284,10 +284,10 @@ public class TestMigration extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
assertListenerStatus();
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundles.get(0).getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundles.get(0).getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final SubscriptionData subscription = (SubscriptionData) subscriptions.get(0);
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairBP.java b/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairBP.java
index 58a1faa..2d01bea 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairBP.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairBP.java
@@ -160,7 +160,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(dryRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
assertEquals(dryRunBaseSubscription.getBundleId(), bundle.getId());
@@ -190,7 +190,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expected) {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(realRunBaseSubscription.getAllTransitions().size(), 2);
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -244,7 +244,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
// CHECK WHAT"S GOING ON AFTER WE MOVE CLOCK-- FUTURE MOTIFICATION SHOULD KICK IN
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscriptionId, callContext);
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscriptionId, internalCallContext);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(subscription.getBundleId(), bundle.getId());
@@ -331,7 +331,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expectedEvents) {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(dryRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
assertEquals(dryRunBaseSubscription.getBundleId(), bundle.getId());
@@ -370,7 +370,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expectedEvents) {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(realRunBaseSubscription.getAllTransitions().size(), 2);
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -414,7 +414,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
final Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(32));
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscriptionId, callContext);
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscriptionId, internalCallContext);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(subscription.getBundleId(), bundle.getId());
@@ -502,7 +502,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expectedEvents) {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData dryRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(dryRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
assertEquals(dryRunBaseSubscription.getBundleId(), bundle.getId());
@@ -539,7 +539,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expectedEvents) {
testUtil.validateExistingEventForAssertion(e, events.get(index++));
}
- final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final SubscriptionData realRunBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(realRunBaseSubscription.getAllTransitions().size(), expectedTransitions);
assertEquals(realRunBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -579,7 +579,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
// SET CTD to BASE SUBSCRIPTION SP CANCEL OCCURS EOT
final DateTime newChargedThroughDate = baseSubscription.getStartDate().plusDays(30).plusMonths(1);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
final DateTime requestedChange = clock.getUTCNow();
baseSubscription.changePlan("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, requestedChange, callContext);
@@ -611,7 +611,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
repairApi.repairBundle(bRepair, dryRun, callContext);
assertTrue(testListener.isCompleted(5000));
- baseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(((SubscriptionData) baseSubscription).getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
assertEquals(baseSubscription.getBundleId(), bundle.getId());
@@ -692,7 +692,7 @@ public class TestRepairBP extends SubscriptionTestSuiteWithEmbeddedDB {
clock.setDeltaFromReality(1000);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
repairApi.repairBundle(bRepair, true, callContext);
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairWithAO.java b/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairWithAO.java
index d378f1c..29060f1 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairWithAO.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/timeline/TestRepairWithAO.java
@@ -140,17 +140,17 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
- SubscriptionData newAoSubscription2 = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription2.getId(), callContext);
+ SubscriptionData newAoSubscription2 = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription2.getId(), internalCallContext);
assertEquals(newAoSubscription2.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription2.getAllTransitions().size(), 2);
assertEquals(newAoSubscription2.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
- SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -181,17 +181,17 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newAoSubscription2 = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription2.getId(), callContext);
+ newAoSubscription2 = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription2.getId(), internalCallContext);
assertEquals(newAoSubscription2.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription2.getAllTransitions().size(), 2);
assertEquals(newAoSubscription2.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -274,12 +274,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
- SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -305,12 +305,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newAoSubscription.getAllTransitions().size(), 3);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -342,7 +342,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
// SET CTD to BASE SUBSCRIPTION SP CANCEL OCCURS EOT
final DateTime newChargedThroughDate = baseSubscription.getStartDate().plusDays(30).plusMonths(1);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
BundleTimeline bundleRepair = repairApi.getBundleTimeline(bundle.getId(), callContext);
testUtil.sortEventsOnBundle(bundleRepair);
@@ -395,12 +395,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
- SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -426,12 +426,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, bpRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 3);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -444,12 +444,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(7000));
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newAoSubscription.getAllTransitions().size(), 3);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newBaseSubscription.getAllTransitions().size(), 3);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
@@ -512,12 +512,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expected) {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
- SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ SubscriptionData newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -534,12 +534,12 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.CANCELLED);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION + 1);
- newBaseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ newBaseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(newBaseSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newBaseSubscription.getAllTransitions().size(), 2);
assertEquals(newBaseSubscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -601,7 +601,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expected) {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getStartDate(), aoSubscription.getStartDate());
@@ -620,7 +620,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
assertEquals(newAoSubscription.getStartDate(), aoRecreateDate);
@@ -694,7 +694,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
for (final ExistingEvent e : expected) {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- SubscriptionData newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ SubscriptionData newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 2);
@@ -711,7 +711,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
testUtil.validateExistingEventForAssertion(e, aoRepair.getExistingEvents().get(index++));
}
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(newAoSubscription.getState(), SubscriptionState.ACTIVE);
assertEquals(newAoSubscription.getAllTransitions().size(), 3);
@@ -737,7 +737,7 @@ public class TestRepairWithAO extends SubscriptionTestSuiteWithEmbeddedDB {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- newAoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ newAoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
currentPhase = newAoSubscription.getCurrentPhase();
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/transfer/TestTransfer.java b/subscription/src/test/java/com/ning/billing/subscription/api/transfer/TestTransfer.java
index b05bdda..911cf65 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/transfer/TestTransfer.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/transfer/TestTransfer.java
@@ -65,11 +65,11 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
migrationApi.migrate(toBeMigrated, callContext);
assertTrue(testListener.isCompleted(5000));
- final List<SubscriptionBundle> bundles = subscriptionApi.getBundlesForAccount(toBeMigrated.getAccountKey(), callContext);
+ final List<SubscriptionBundle> bundles = subscriptionInternalApi.getBundlesForAccount(toBeMigrated.getAccountKey(), internalCallContext);
assertEquals(bundles.size(), 1);
final SubscriptionBundle bundle = bundles.get(0);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(bundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(bundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription subscription = subscriptions.get(0);
testUtil.assertDateWithin(subscription.getStartDate(), beforeMigration.minusMonths(2), afterMigration.minusMonths(2));
@@ -96,7 +96,7 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
transferApi.transferBundle(bundle.getAccountId(), newAccountId, bundle.getExternalKey(), transferRequestedDate, false, true, callContext);
assertTrue(testListener.isCompleted(3000));
- final Subscription oldBaseSubscription = subscriptionApi.getBaseSubscription(bundle.getId(), callContext);
+ final Subscription oldBaseSubscription = subscriptionInternalApi.getBaseSubscription(bundle.getId(), internalCallContext);
assertTrue(oldBaseSubscription.getState() == SubscriptionState.CANCELLED);
// The MIGRATE_BILLING event should have been invalidated
assertEquals(subscriptionInternalApi.getBillingTransitions(oldBaseSubscription, internalCallContext).size(), 0);
@@ -136,15 +136,15 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
final DateTime afterTransferDate = clock.getUTCNow();
// CHECK OLD BASE IS CANCEL AT THE TRANSFER DATE
- final Subscription oldBaseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final Subscription oldBaseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertNotNull(oldBaseSubscription.getEndDate());
testUtil.assertDateWithin(oldBaseSubscription.getEndDate(), beforeTransferDate, afterTransferDate);
assertTrue(oldBaseSubscription.getEndDate().compareTo(transferRequestedDate) == 0);
// CHECK NEW BUNDLE EXIST, WITH ONE SUBSCRIPTION STARTING ON TRANSFER_DATE
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription newBaseSubscription = subscriptions.get(0);
@@ -186,14 +186,14 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(3000));
// CHECK OLD BASE IS CANCEL AT THE TRANSFER DATE
- final Subscription oldBaseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final Subscription oldBaseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertNotNull(oldBaseSubscription.getFutureEndDate());
assertTrue(oldBaseSubscription.getFutureEndDate().compareTo(ctd) == 0);
// CHECK NEW BUNDLE EXIST, WITH ONE SUBSCRIPTION STARTING ON TRANSFER_DATE
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription newBaseSubscription = subscriptions.get(0);
@@ -235,15 +235,15 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
final DateTime afterTransferDate = clock.getUTCNow();
// CHECK OLD BASE IS CANCEL AT THE TRANSFER DATE
- final Subscription oldBaseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final Subscription oldBaseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertNotNull(oldBaseSubscription.getEndDate());
testUtil.assertDateWithin(oldBaseSubscription.getEndDate(), beforeTransferDate, afterTransferDate);
assertTrue(oldBaseSubscription.getEndDate().compareTo(transferRequestedDate) == 0);
// CHECK NEW BUNDLE EXIST, WITH ONE SUBSCRIPTION STARTING ON TRANSFER_DATE
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription newBaseSubscription = subscriptions.get(0);
@@ -285,14 +285,14 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(3000));
// CHECK OLD BASE IS CANCEL AT THE TRANSFER DATE
- final Subscription oldBaseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ final Subscription oldBaseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertNotNull(oldBaseSubscription.getFutureEndDate());
assertTrue(oldBaseSubscription.getFutureEndDate().compareTo(ctd) == 0);
// CHECK NEW BUNDLE EXIST, WITH ONE SUBSCRIPTION STARTING ON TRANSFER_DATE
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
final Subscription newBaseSubscription = subscriptions.get(0);
@@ -322,7 +322,7 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
final DateTime newCtd = newBaseSubscription.getStartDate().plusYears(1);
subscriptionInternalApi.setChargedThroughDate(newBaseSubscription.getId(), newCtd, internalCallContext);
- final Subscription newBaseSubscriptionWithCtd = subscriptionApi.getSubscriptionFromId(newBaseSubscription.getId(), callContext);
+ final Subscription newBaseSubscriptionWithCtd = subscriptionInternalApi.getSubscriptionFromId(newBaseSubscription.getId(), internalCallContext);
final String newBaseProduct2 = "Pistol";
final BillingPeriod newBaseTerm2 = BillingPeriod.ANNUAL;
@@ -382,8 +382,8 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(3000));
// RETRIEVE NEW BUNDLE AND CHECK SUBSCRIPTIONS
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 3);
boolean foundBP = false;
boolean foundAO1 = false;
@@ -472,8 +472,8 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
transferApi.transferBundle(bundle.getAccountId(), newAccountId, bundle.getExternalKey(), transferRequestedDate, true, false, callContext);
assertTrue(testListener.isCompleted(3000));
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
}
@@ -499,7 +499,7 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
// CANCEL BP
- baseSubscription = subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
baseSubscription.cancel(clock.getUTCNow(), callContext);
// MOVE CLOCK one day AHEAD AND UNCANCEL BP
@@ -515,8 +515,8 @@ public class TestTransfer extends SubscriptionTestSuiteWithEmbeddedDB {
transferApi.transferBundle(bundle.getAccountId(), newAccountId, bundle.getExternalKey(), transferRequestedDate, true, false, callContext);
assertTrue(testListener.isCompleted(3000));
- final SubscriptionBundle newBundle = subscriptionApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), callContext);
- final List<Subscription> subscriptions = subscriptionApi.getSubscriptionsForBundle(newBundle.getId(), callContext);
+ final SubscriptionBundle newBundle = subscriptionInternalApi.getBundleForAccountAndKey(newAccountId, bundle.getExternalKey(), internalCallContext);
+ final List<Subscription> subscriptions = subscriptionInternalApi.getSubscriptionsForBundle(newBundle.getId(), internalCallContext);
assertEquals(subscriptions.size(), 1);
}
}
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiAddOn.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiAddOn.java
index 50368d5..a8cba5b 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiAddOn.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiAddOn.java
@@ -67,7 +67,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
aoSubscription.cancel(now, callContext);
assertTrue(testListener.isCompleted(5000));
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
@@ -111,25 +111,25 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
final DateTime newBPChargedThroughDate = TestSubscriptionHelper.addDuration(now, bpCtd);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newBPChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(1));
clock.addDeltaFromReality(it.toDurationMillis());
// CANCEL AO
aoSubscription.cancel(clock.getUTCNow(), callContext);
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(aoSubscription.isSubscriptionFutureCancelled());
// CANCEL BASE NOW
baseSubscription.cancel(clock.getUTCNow(), callContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(baseSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(baseSubscription.isSubscriptionFutureCancelled());
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
List<SubscriptionTransition> aoTransitions = aoSubscription.getAllTransitions();
assertEquals(aoTransitions.size(), 3);
assertEquals(aoTransitions.get(0).getTransitionType(), SubscriptionTransitionType.CREATE);
@@ -141,7 +141,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
aoSubscription.uncancel(callContext);
assertTrue(testListener.isCompleted(5000));
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
aoTransitions = aoSubscription.getAllTransitions();
assertEquals(aoTransitions.size(), 3);
assertEquals(aoTransitions.get(0).getTransitionType(), SubscriptionTransitionType.CREATE);
@@ -189,13 +189,13 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
// Why not just use clock.getUTCNow().plusMonths(1) ?
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(now, ctd);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
// FUTURE CANCELLATION
baseSubscription.cancel(now, callContext);
// REFETCH AO SUBSCRIPTION AND CHECK THIS IS ACTIVE
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(aoSubscription.isSubscriptionFutureCancelled());
@@ -209,7 +209,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
// REFETCH AO SUBSCRIPTION AND CHECK THIS IS CANCELLED
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
assertListenerStatus();
@@ -251,24 +251,24 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
// Why not just use clock.getUTCNow().plusMonths(1) ?
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(now, ctd);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
// FUTURE CANCELLATION
baseSubscription.cancel(now, callContext);
// REFETCH AO SUBSCRIPTION AND CHECK THIS IS ACTIVE
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(aoSubscription.isSubscriptionFutureCancelled());
testListener.reset();
testListener.pushExpectedEvent(NextEvent.UNCANCEL);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
baseSubscription.uncancel(callContext);
assertTrue(testListener.isCompleted(5000));
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertFalse(aoSubscription.isSubscriptionFutureCancelled());
@@ -276,13 +276,13 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(1));
clock.addDeltaFromReality(it.toDurationMillis());
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
baseSubscription.cancel(clock.getUTCNow(), callContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
assertEquals(baseSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(baseSubscription.isSubscriptionFutureCancelled());
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(aoSubscription.isSubscriptionFutureCancelled());
assertListenerStatus();
@@ -325,15 +325,15 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(now, ctd);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
// CHANGE IMMEDIATELY WITH TO BP WITH NON INCLUDED ADDON
final String newBaseProduct = "Assault-Rifle";
final BillingPeriod newBaseTerm = BillingPeriod.MONTHLY;
final String newBasePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
- final List<SubscriptionStatusDryRun> aoStatus = subscriptionApi.getDryRunChangePlanStatus(baseSubscription.getId(),
- newBaseProduct, now, callContext);
+ final List<SubscriptionStatusDryRun> aoStatus = subscriptionInternalApi.getDryRunChangePlanStatus(baseSubscription.getId(),
+ newBaseProduct, now, internalCallContext);
assertEquals(aoStatus.size(), 1);
assertEquals(aoStatus.get(0).getId(), aoSubscription.getId());
assertEquals(aoStatus.get(0).getProductName(), aoProduct);
@@ -349,7 +349,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
// REFETCH AO SUBSCRIPTION AND CHECK THIS CANCELLED
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
assertListenerStatus();
@@ -388,15 +388,15 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(now, ctd);
subscriptionInternalApi.setChargedThroughDate(baseSubscription.getId(), newChargedThroughDate, internalCallContext);
- baseSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(baseSubscription.getId(), callContext);
+ baseSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(baseSubscription.getId(), internalCallContext);
// CHANGE IMMEDIATELY WITH TO BP WITH NON AVAILABLE ADDON
final String newBaseProduct = "Pistol";
final BillingPeriod newBaseTerm = BillingPeriod.MONTHLY;
final String newBasePriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
- final List<SubscriptionStatusDryRun> aoStatus = subscriptionApi.getDryRunChangePlanStatus(baseSubscription.getId(),
- newBaseProduct, now, callContext);
+ final List<SubscriptionStatusDryRun> aoStatus = subscriptionInternalApi.getDryRunChangePlanStatus(baseSubscription.getId(),
+ newBaseProduct, now, internalCallContext);
assertEquals(aoStatus.size(), 1);
assertEquals(aoStatus.get(0).getId(), aoSubscription.getId());
assertEquals(aoStatus.get(0).getProductName(), aoProduct);
@@ -408,7 +408,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
baseSubscription.changePlan(newBaseProduct, newBaseTerm, newBasePriceList, now, callContext);
// REFETCH AO SUBSCRIPTION AND CHECK THIS IS ACTIVE
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.ACTIVE);
assertTrue(aoSubscription.isSubscriptionFutureCancelled());
@@ -421,7 +421,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
// REFETCH AO SUBSCRIPTION AND CHECK THIS CANCELLED
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
assertEquals(aoSubscription.getState(), SubscriptionState.CANCELLED);
assertListenerStatus();
@@ -527,7 +527,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
assertTrue(testListener.isCompleted(5000));
// CHECK EVERYTHING AGAIN
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
aoCurrentPlan = aoSubscription.getCurrentPlan();
assertNotNull(aoCurrentPlan);
@@ -539,7 +539,7 @@ public class TestUserApiAddOn extends SubscriptionTestSuiteWithEmbeddedDB {
assertNotNull(aoCurrentPhase);
assertEquals(aoCurrentPhase.getPhaseType(), PhaseType.EVERGREEN);
- aoSubscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(aoSubscription.getId(), callContext);
+ aoSubscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(aoSubscription.getId(), internalCallContext);
aoPendingTranstion = aoSubscription.getPendingTransition();
assertNull(aoPendingTranstion);
} catch (SubscriptionUserApiException e) {
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCancel.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCancel.java
index 5248360..7e0b299 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCancel.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCancel.java
@@ -114,7 +114,7 @@ public class TestUserApiCancel extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(expectedPhaseTrialChange, ctd);
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
assertEquals(subscription.getLastActiveProductName(), prod);
assertEquals(subscription.getLastActivePriceListName(), planSet);
@@ -234,7 +234,7 @@ public class TestUserApiCancel extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(expectedPhaseTrialChange, ctd);
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
// CANCEL EOT
subscription.cancel(clock.getUTCNow(), callContext);
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiChangePlan.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiChangePlan.java
index 0776848..5bd1c1f 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiChangePlan.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiChangePlan.java
@@ -126,7 +126,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
// RE READ SUBSCRIPTION + CHANGE PLAN
testListener.setNonExpectedMode();
testListener.pushExpectedEvent(NextEvent.CHANGE);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
subscription.changePlan(toProd, toTerm, toPlanSet, clock.getUTCNow(), callContext);
assertFalse(testListener.isCompleted(3000));
testListener.reset();
@@ -149,7 +149,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
currentPhase = subscription.getCurrentPhase();
checkChangePlan(subscription, toProd, ProductCategory.BASE, toTerm, PhaseType.DISCOUNT);
@@ -229,7 +229,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
// RE READ SUBSCRIPTION + CHECK CURRENT PHASE
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
PlanPhase currentPhase = subscription.getCurrentPhase();
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
@@ -309,7 +309,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(startDiscountPhase, ctd);
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
// CHANGE EOT
testListener.setNonExpectedMode();
@@ -358,7 +358,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
final Duration ctd = testUtil.getDurationMonth(1);
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(startDiscountPhase, ctd);
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
// CHANGE EOT
testListener.setNonExpectedMode();
@@ -407,7 +407,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusMonths(6));
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
currentPlan = subscription.getCurrentPlan();
assertNotNull(currentPlan);
@@ -464,7 +464,7 @@ public class TestUserApiChangePlan extends SubscriptionTestSuiteWithEmbeddedDB {
trialPhase = subscription.getCurrentPhase();
assertEquals(trialPhase.getPhaseType(), PhaseType.DISCOUNT);
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
final DateTime expectedNextPhaseDate = subscription.getStartDate().plusDays(30).plusMonths(6);
final SubscriptionTransition nextPhase = subscription.getPendingTransition();
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCreate.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCreate.java
index 84a8bbe..474088e 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCreate.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiCreate.java
@@ -57,8 +57,8 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
testListener.pushExpectedEvent(NextEvent.PHASE);
testListener.pushExpectedEvent(NextEvent.CREATE);
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext);
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext);
assertNotNull(subscription);
//
@@ -105,8 +105,8 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
testListener.pushExpectedEvent(NextEvent.CREATE);
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, PhaseType.EVERGREEN), clock.getUTCNow(), callContext);
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, PhaseType.EVERGREEN), clock.getUTCNow(), internalCallContext);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -143,9 +143,9 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
testListener.pushExpectedEvent(NextEvent.CREATE);
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
testUtil.getProductSpecifier(productName, planSetName, term, null),
- clock.getUTCNow(), callContext);
+ clock.getUTCNow(), internalCallContext);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
@@ -199,8 +199,8 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
testListener.pushExpectedEvent(NextEvent.CREATE);
// CREATE SUBSCRIPTION
- SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), callContext);
+ SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), internalCallContext);
assertNotNull(subscription);
PlanPhase currentPhase = subscription.getCurrentPhase();
@@ -223,7 +223,7 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
clock.addDeltaFromReality(it.toDurationMillis());
assertTrue(testListener.isCompleted(5000));
- subscription = (SubscriptionData) subscriptionApi.getSubscriptionFromId(subscription.getId(), callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
currentPhase = subscription.getCurrentPhase();
assertNotNull(currentPhase);
assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
@@ -243,8 +243,8 @@ public class TestUserApiCreate extends SubscriptionTestSuiteWithEmbeddedDB {
testListener.pushExpectedEvent(NextEvent.CREATE);
- final SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), callContext);
+ final SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), internalCallContext);
assertNotNull(subscription);
assertListenerStatus();
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiError.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiError.java
index e3cb0a3..c96ea8d 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiError.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiError.java
@@ -98,7 +98,7 @@ public class TestUserApiError extends SubscriptionTestSuiteNoDB {
public void testCreateSubscriptionAddOnNotAvailable() {
try {
final UUID accountId = UUID.randomUUID();
- final SubscriptionBundle aoBundle = subscriptionApi.createBundleForAccount(accountId, "myAOBundle", callContext);
+ final SubscriptionBundle aoBundle = subscriptionInternalApi.createBundleForAccount(accountId, "myAOBundle", internalCallContext);
testUtil.createSubscriptionWithBundle(aoBundle.getId(), "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_AO_NOT_AVAILABLE);
} catch (Exception e) {
@@ -111,7 +111,7 @@ public class TestUserApiError extends SubscriptionTestSuiteNoDB {
log.info("Starting testCreateSubscriptionAddOnIncluded");
try {
final UUID accountId = UUID.randomUUID();
- final SubscriptionBundle aoBundle = subscriptionApi.createBundleForAccount(accountId, "myAOBundle", callContext);
+ final SubscriptionBundle aoBundle = subscriptionInternalApi.createBundleForAccount(accountId, "myAOBundle", internalCallContext);
testUtil.createSubscriptionWithBundle(aoBundle.getId(), "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null);
tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_AO_ALREADY_INCLUDED);
} catch (Exception e) {
@@ -122,9 +122,9 @@ public class TestUserApiError extends SubscriptionTestSuiteNoDB {
private void tCreateSubscriptionInternal(@Nullable final UUID bundleId, @Nullable final String productName,
@Nullable final BillingPeriod term, final String planSet, final ErrorCode expected) {
try {
- subscriptionApi.createSubscription(bundleId,
+ subscriptionInternalApi.createSubscription(bundleId,
testUtil.getProductSpecifier(productName, planSet, term, null),
- clock.getUTCNow(), callContext);
+ clock.getUTCNow(), internalCallContext);
Assert.fail("Exception expected, error code: " + expected);
} catch (SubscriptionUserApiException e) {
assertEquals(e.getCode(), expected.getCode());
@@ -167,11 +167,11 @@ public class TestUserApiError extends SubscriptionTestSuiteNoDB {
Assert.fail();
} catch (SubscriptionError error) {
assertTrue(true);
- assertEquals(subscriptionApi.getSubscriptionFromId(subscription.getId(), tenantContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
+ assertEquals(subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.ANNUAL);
}
assertTrue(subscription.changePlanWithPolicy("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow(), ActionPolicy.IMMEDIATE, callContext));
- assertEquals(subscriptionApi.getSubscriptionFromId(subscription.getId(), tenantContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
+ assertEquals(subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext).getCurrentPlan().getBillingPeriod(), BillingPeriod.MONTHLY);
}
@Test(groups = "fast")
@@ -193,7 +193,7 @@ public class TestUserApiError extends SubscriptionTestSuiteNoDB {
final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(expectedPhaseTrialChange, ctd);
subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
- subscription = subscriptionApi.getSubscriptionFromId(subscription.getId(), tenantContext);
+ subscription = subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
subscription.cancel(clock.getUTCNow(), callContext);
try {
diff --git a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiRecreate.java b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiRecreate.java
index dd0a092..5d9f8c1 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiRecreate.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/api/user/TestUserApiRecreate.java
@@ -67,8 +67,8 @@ public abstract class TestUserApiRecreate extends SubscriptionTestSuiteWithEmbed
testListener.pushExpectedEvent(NextEvent.PHASE);
testListener.pushExpectedEvent(NextEvent.CREATE);
- SubscriptionData subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext);
+ SubscriptionData subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext);
assertNotNull(subscription);
assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION);
assertEquals(subscription.getBundleId(), bundle.getId());
@@ -84,8 +84,8 @@ public abstract class TestUserApiRecreate extends SubscriptionTestSuiteWithEmbed
try {
if (fromUserAPi) {
- subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext);
} else {
subscription.recreate(testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext);
}
@@ -109,8 +109,8 @@ public abstract class TestUserApiRecreate extends SubscriptionTestSuiteWithEmbed
}
if (fromUserAPi) {
- subscription = (SubscriptionData) subscriptionApi.createSubscription(bundle.getId(),
- testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext);
+ subscription = (SubscriptionData) subscriptionInternalApi.createSubscription(bundle.getId(),
+ testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext);
} else {
subscription.recreate(testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), callContext);
}
diff --git a/subscription/src/test/java/com/ning/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java b/subscription/src/test/java/com/ning/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
index f040af5..46aef16 100644
--- a/subscription/src/test/java/com/ning/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
+++ b/subscription/src/test/java/com/ning/billing/subscription/SubscriptionTestSuiteWithEmbeddedDB.java
@@ -114,7 +114,7 @@ public class SubscriptionTestSuiteWithEmbeddedDB extends GuicyKillbillTestSuiteW
this.catalog = subscriptionTestInitializer.initCatalog(catalogService);
this.accountData = subscriptionTestInitializer.initAccountData();
- this.bundle = subscriptionTestInitializer.initBundle(subscriptionInternalApi, callContext);
+ this.bundle = subscriptionTestInitializer.initBundle(subscriptionInternalApi, internalCallContext);
}
@AfterMethod(groups = "slow")