use of org.killbill.billing.entitlement.api.BaseEntitlementWithAddOnsSpecifier in project killbill by killbill.
the class TestMigrationSubscriptions method testMigrationWithMultipleBundlesAndDifferentDates.
@Test(groups = "slow")
public void testMigrationWithMultipleBundlesAndDifferentDates() throws Exception {
clock.setDay(new LocalDate(2016, 1, 1));
final AccountData accountData = getAccountData(1);
final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
accountChecker.checkAccount(account.getId(), accountData, callContext);
// We set both entitlement and billing date with desired value
final LocalDate entitlementMigrationDateBundle1 = new LocalDate(2015, 12, 20);
final LocalDate billingMigrationDateBundle1 = new LocalDate(2016, 2, 1);
// We set both entitlement and billing date with desired value
final LocalDate entitlementMigrationDateBundle2 = new LocalDate(2015, 12, 20);
final LocalDate billingMigrationDateBundle2 = new LocalDate(2016, 3, 1);
final PlanPhaseSpecifier baseSpec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN);
final PlanPhaseSpecifier addOnSpec1 = new PlanPhaseSpecifier("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN);
final String externalKey = "baseExternalKey";
EntitlementSpecifier baseEntitlementSpecifier = new DefaultEntitlementSpecifier(baseSpec, null);
EntitlementSpecifier addOnEntitlementSpecifier1 = new DefaultEntitlementSpecifier(addOnSpec1, null);
final List<EntitlementSpecifier> specifierList = new ArrayList<EntitlementSpecifier>();
specifierList.add(baseEntitlementSpecifier);
specifierList.add(addOnEntitlementSpecifier1);
busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK, NextEvent.BLOCK);
BaseEntitlementWithAddOnsSpecifier baseEntitlementWithAddOnsSpecifierBundle1 = buildBaseEntitlementWithAddOnsSpecifier(entitlementMigrationDateBundle1, billingMigrationDateBundle1, externalKey, specifierList);
List<BaseEntitlementWithAddOnsSpecifier> baseEntitlementWithAddOnsSpecifierList = new ArrayList<BaseEntitlementWithAddOnsSpecifier>();
BaseEntitlementWithAddOnsSpecifier baseEntitlementWithAddOnsSpecifierBundle2 = buildBaseEntitlementWithAddOnsSpecifier(entitlementMigrationDateBundle2, billingMigrationDateBundle2, externalKey, specifierList);
baseEntitlementWithAddOnsSpecifierList.add(baseEntitlementWithAddOnsSpecifierBundle1);
baseEntitlementWithAddOnsSpecifierList.add(baseEntitlementWithAddOnsSpecifierBundle2);
final List<Entitlement> baseEntitlements = entitlementApi.createBaseEntitlementsWithAddOns(account.getId(), baseEntitlementWithAddOnsSpecifierList, ImmutableList.<PluginProperty>of(), callContext);
assertListenerStatus();
Assert.assertEquals(baseEntitlements.get(0).getState(), EntitlementState.ACTIVE);
Assert.assertEquals(baseEntitlements.get(1).getState(), EntitlementState.ACTIVE);
// Billing starts straight on EVERGREEN for Bundle 1 after 1 month
clock.addMonths(1);
busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.CREATE, NextEvent.INVOICE, NextEvent.NULL_INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
assertListenerStatus();
// Billing starts straight on EVERGREEN for Bundle 2 after 2 months
clock.addMonths(1);
busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.CREATE, NextEvent.INVOICE, NextEvent.NULL_INVOICE, NextEvent.NULL_INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
assertListenerStatus();
// Next month we should still get one single invoice and payment / invoice payment
clock.addMonths(1);
busHandler.pushExpectedEvents(NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
assertListenerStatus();
}
use of org.killbill.billing.entitlement.api.BaseEntitlementWithAddOnsSpecifier in project killbill by killbill.
the class TestMigrationSubscriptions method testSimpleMigrationBundle.
//
// Scenario: On 2016-1-1, we decide to migrate a bundle (one BP and one AO). We migrate straight to EVERGREEN phase. The scenario is very similar to previous one
// but with an additional AO (by using the createBaseEntitlementWithAddOns api).
//
// Note that while convenient to migrate a bundle at once (BP + AOS), one could do several calls for each subscription. The advantage of the later approach is that
// the granularity in terms of alignments for when things start and which phase are skipped can be better controlled.
//
@Test(groups = "slow")
public void testSimpleMigrationBundle() throws Exception {
clock.setDay(new LocalDate(2016, 1, 1));
final AccountData accountData = getAccountData(1);
final Account account = createAccountWithNonOsgiPaymentMethod(accountData);
accountChecker.checkAccount(account.getId(), accountData, callContext);
// We set both entitlement and billing date with desired value
final LocalDate entitlementMigrationDate = new LocalDate(2015, 12, 20);
final LocalDate billingMigrationDate = new LocalDate(2016, 2, 1);
final PlanPhaseSpecifier baseSpec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN);
final PlanPhaseSpecifier addOnSpec1 = new PlanPhaseSpecifier("Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, PhaseType.EVERGREEN);
final String externalKey = "baseExternalKey";
EntitlementSpecifier baseEntitlementSpecifier = new DefaultEntitlementSpecifier(baseSpec, null);
EntitlementSpecifier addOnEntitlementSpecifier1 = new DefaultEntitlementSpecifier(addOnSpec1, null);
final List<EntitlementSpecifier> specifierList = new ArrayList<EntitlementSpecifier>();
specifierList.add(baseEntitlementSpecifier);
specifierList.add(addOnEntitlementSpecifier1);
busHandler.pushExpectedEvents(NextEvent.BLOCK, NextEvent.BLOCK);
BaseEntitlementWithAddOnsSpecifier baseEntitlementWithAddOnsSpecifier = buildBaseEntitlementWithAddOnsSpecifier(entitlementMigrationDate, billingMigrationDate, externalKey, specifierList);
List<BaseEntitlementWithAddOnsSpecifier> baseEntitlementWithAddOnsSpecifierList = new ArrayList<BaseEntitlementWithAddOnsSpecifier>();
baseEntitlementWithAddOnsSpecifierList.add(baseEntitlementWithAddOnsSpecifier);
final List<Entitlement> baseEntitlements = entitlementApi.createBaseEntitlementsWithAddOns(account.getId(), baseEntitlementWithAddOnsSpecifierList, ImmutableList.<PluginProperty>of(), callContext);
assertListenerStatus();
Assert.assertEquals(baseEntitlements.get(0).getState(), EntitlementState.ACTIVE);
// Billing starts straight on EVERGREEN
clock.addMonths(1);
busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.CREATE, NextEvent.INVOICE, NextEvent.NULL_INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT);
assertListenerStatus();
}
Aggregations