use of org.killbill.billing.catalog.api.PlanSpecifier in project killbill by killbill.
the class TestStandaloneCatalogWithPriceOverride method testCreatePlanNoProduct.
@Test(groups = "slow")
public void testCreatePlanNoProduct() throws Exception {
final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class);
final StaticCatalog standaloneCatalogWithPriceOverride = new StandaloneCatalogWithPriceOverride(catalog, priceOverride, internalCallContext.getTenantRecordId(), internalCallContextFactory);
try {
final PlanSpecifier specWithNullProduct = new PlanSpecifier(null, BillingPeriod.ANNUAL, "DEFAULT");
standaloneCatalogWithPriceOverride.createOrFindCurrentPlan(specWithNullProduct, null);
Assert.fail();
} catch (final CatalogApiException e) {
Assert.assertEquals(e.getCode(), ErrorCode.CAT_NULL_PRODUCT_NAME.getCode());
}
}
use of org.killbill.billing.catalog.api.PlanSpecifier in project killbill by killbill.
the class TestLoadRules method test.
@Test(groups = "fast")
public void test() throws Exception {
final URI uri = new URI(Resources.getResource("WeaponsHireSmall.xml").toExternalForm());
final StandaloneCatalog catalog = XMLLoader.getObjectFromUri(uri, StandaloneCatalog.class);
Assert.assertNotNull(catalog);
final DefaultPlanRules rules = catalog.getPlanRules();
final PlanSpecifier specifier = new PlanSpecifier("Laser-Scope", BillingPeriod.MONTHLY, "DEFAULT");
final PlanAlignmentCreate alignment = rules.getPlanCreateAlignment(specifier, catalog);
Assert.assertEquals(alignment, PlanAlignmentCreate.START_OF_SUBSCRIPTION);
final PlanSpecifier specifier2 = new PlanSpecifier("Extra-Ammo", BillingPeriod.MONTHLY, "DEFAULT");
final PlanAlignmentCreate alignment2 = rules.getPlanCreateAlignment(specifier2, catalog);
Assert.assertEquals(alignment2, PlanAlignmentCreate.START_OF_BUNDLE);
}
use of org.killbill.billing.catalog.api.PlanSpecifier 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 = cat.findCurrentPriceList(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 = cat.getPlanRules().planChange(from, to, cat);
} 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.api.PlanSpecifier in project killbill by killbill.
the class TestPlanRules method testBaseCase.
@Test(groups = "fast")
public void testBaseCase() throws CatalogApiException {
final DefaultProduct product1 = cat.getCurrentProduct(0);
final DefaultProduct product2 = cat.getCurrentProduct(1);
final DefaultPriceList priceList1 = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[0];
final PlanPhaseSpecifier from = new PlanPhaseSpecifier(product1.getName(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
final PlanSpecifier to = new PlanSpecifier(product2.getName(), BillingPeriod.MONTHLY, null);
PlanChangeResult result = null;
try {
result = cat.getPlanRules().planChange(from, to, cat);
} 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(), priceList2);
}
use of org.killbill.billing.catalog.api.PlanSpecifier in project killbill by killbill.
the class TestCase method assertionException.
protected void assertionException(final DefaultCaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final StandaloneCatalog cat) {
try {
cr.getResult(new PlanSpecifier(productName, bp, priceListName), cat);
Assert.fail("Expecting an exception");
} catch (CatalogApiException e) {
Assert.assertEquals(e.getCode(), ErrorCode.CAT_PRICE_LIST_NOT_FOUND.getCode());
}
}
Aggregations