use of org.killbill.billing.catalog.DefaultPriceList in project killbill by killbill.
the class TestPlanRules method testExistingPriceListIsKept.
@Test(groups = "fast")
public void testExistingPriceListIsKept() throws CatalogApiException {
final DefaultProduct product1 = cat.getCurrentProduct(0);
final DefaultPriceList priceList1 = (DefaultPriceList) cat.findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
final PlanPhaseSpecifier from = new PlanPhaseSpecifier(product1.getName(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
final PlanSpecifier to = new PlanSpecifier(product1.getName(), BillingPeriod.ANNUAL, priceList1.getName());
PlanChangeResult result = null;
try {
result = ((DefaultPlanRules) cat.getPlanRules()).getPlanChangeResult(from, to);
} catch (IllegalPlanChange e) {
Assert.fail("We should not have triggered this error");
} catch (CatalogApiException e) {
Assert.fail("", e);
}
Assert.assertEquals(result.getPolicy(), BillingActionPolicy.END_OF_TERM);
Assert.assertEquals(result.getAlignment(), PlanAlignmentChange.START_OF_SUBSCRIPTION);
Assert.assertEquals(result.getNewPriceList(), priceList1);
}
use of org.killbill.billing.catalog.DefaultPriceList in project killbill by killbill.
the class DefaultPlanRules method findPriceList.
private DefaultPriceList findPriceList(final PlanSpecifier specifier) throws CatalogApiException {
DefaultPriceList result = DefaultCasePriceList.getResult(priceListCase, specifier, root);
if (result == null) {
final String priceListName = specifier.getPlanName() != null ? root.findPlan(specifier.getPlanName()).getPriceList().getName() : specifier.getPriceListName();
result = (DefaultPriceList) root.findPriceList(priceListName);
}
return result;
}
Aggregations