use of org.killbill.billing.catalog.api.PlanAlignmentCreate in project killbill by killbill.
the class PlanAligner method getTimedPhaseOnCreate.
private List<TimedPhase> getTimedPhaseOnCreate(final DateTime subscriptionStartDate, final DateTime bundleStartDate, final Plan plan, @Nullable final PhaseType initialPhase, final SubscriptionCatalog catalog, final DateTime catalogEffectiveDate, final InternalTenantContext context) throws CatalogApiException, SubscriptionBaseApiException {
final PlanSpecifier planSpecifier = new PlanSpecifier(plan.getName());
final DateTime planStartDate;
final PlanAlignmentCreate alignment = catalog.planCreateAlignment(planSpecifier, catalogEffectiveDate, subscriptionStartDate);
switch(alignment) {
case START_OF_SUBSCRIPTION:
planStartDate = subscriptionStartDate;
break;
case START_OF_BUNDLE:
planStartDate = bundleStartDate;
break;
default:
throw new SubscriptionBaseError(String.format("Unknown PlanAlignmentCreate %s", alignment));
}
return getPhaseAlignments(plan, initialPhase, planStartDate);
}
use of org.killbill.billing.catalog.api.PlanAlignmentCreate in project killbill by killbill.
the class TestUserApiAddOn method testAddonCreateWithSubscriptionAlign.
@Test(groups = "slow")
public void testAddonCreateWithSubscriptionAlign() throws SubscriptionBaseApiException, CatalogApiException {
final String aoProduct = "Laser-Scope";
final BillingPeriod aoTerm = BillingPeriod.MONTHLY;
final String aoPriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
// This is just to double check our test catalog gives us what we want before we start the test
final PlanSpecifier planSpecifier = new PlanSpecifier(aoProduct, aoTerm, aoPriceList);
final DateTime utcNow = clock.getUTCNow();
final PlanAlignmentCreate alignment = catalog.planCreateAlignment(planSpecifier, utcNow, utcNow);
assertEquals(alignment, PlanAlignmentCreate.START_OF_SUBSCRIPTION);
testAddonCreateInternal(aoProduct, aoTerm, aoPriceList, alignment);
}
use of org.killbill.billing.catalog.api.PlanAlignmentCreate in project killbill by killbill.
the class PlanAligner method getTimedPhaseOnCreate.
private List<TimedPhase> getTimedPhaseOnCreate(final DateTime subscriptionStartDate, final DateTime bundleStartDate, final Plan plan, @Nullable final PhaseType initialPhase, final DateTime effectiveDate, final InternalTenantContext context) throws CatalogApiException, SubscriptionBaseApiException {
final Catalog catalog = catalogService.getFullCatalog(true, true, context);
final PlanSpecifier planSpecifier = new PlanSpecifier(plan.getName());
final DateTime planStartDate;
final PlanAlignmentCreate alignment = catalog.planCreateAlignment(planSpecifier, effectiveDate);
switch(alignment) {
case START_OF_SUBSCRIPTION:
planStartDate = subscriptionStartDate;
break;
case START_OF_BUNDLE:
planStartDate = bundleStartDate;
break;
default:
throw new SubscriptionBaseError(String.format("Unknown PlanAlignmentCreate %s", alignment));
}
return getPhaseAlignments(plan, initialPhase, planStartDate);
}
use of org.killbill.billing.catalog.api.PlanAlignmentCreate in project killbill by killbill.
the class TestLoadRules method test.
@Test(groups = "fast")
public void test() throws Exception {
final StandaloneCatalog catalog = getCatalog("WeaponsHireSmall.xml");
Assert.assertNotNull(catalog);
final DefaultPlanRules rules = (DefaultPlanRules) catalog.getPlanRules();
final PlanSpecifier specifier = new PlanSpecifier("Laser-Scope", BillingPeriod.MONTHLY, "DEFAULT");
final PlanAlignmentCreate alignment = rules.getPlanCreateAlignment(specifier);
Assert.assertEquals(alignment, PlanAlignmentCreate.START_OF_SUBSCRIPTION);
final PlanSpecifier specifier2 = new PlanSpecifier("Extra-Ammo", BillingPeriod.MONTHLY, "DEFAULT");
final PlanAlignmentCreate alignment2 = rules.getPlanCreateAlignment(specifier2);
Assert.assertEquals(alignment2, PlanAlignmentCreate.START_OF_BUNDLE);
}
use of org.killbill.billing.catalog.api.PlanAlignmentCreate in project killbill by killbill.
the class TestUserApiAddOn method testAddonCreateWithBundleAlign.
@Test(groups = "slow")
public void testAddonCreateWithBundleAlign() throws CatalogApiException, SubscriptionBaseApiException {
final String aoProduct = "Telescopic-Scope";
final BillingPeriod aoTerm = BillingPeriod.MONTHLY;
final String aoPriceList = PriceListSet.DEFAULT_PRICELIST_NAME;
// This is just to double check our test catalog gives us what we want before we start the test
final PlanSpecifier planSpecifier = new PlanSpecifier(aoProduct, aoTerm, aoPriceList);
final DateTime utcNow = clock.getUTCNow();
final PlanAlignmentCreate alignment = catalog.planCreateAlignment(planSpecifier, utcNow, utcNow);
assertEquals(alignment, PlanAlignmentCreate.START_OF_BUNDLE);
testAddonCreateInternal(aoProduct, aoTerm, aoPriceList, alignment);
}
Aggregations