use of org.killbill.billing.catalog.DefaultProduct in project killbill by killbill.
the class StandaloneCatalogMapper method toStandaloneCatalog.
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog, @Nullable URI catalogURI) {
final StandaloneCatalog result = new StandaloneCatalog();
result.setCatalogName(catalogName);
result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate());
result.setProducts(toDefaultProducts(pluginCatalog.getProducts()));
result.setPlans(toDefaultPlans(pluginCatalog.getPlans()));
result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList()));
result.setRecurringBillingMode(recurringBillingMode);
result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies()));
result.setUnits(toDefaultUnits(pluginCatalog.getUnits()));
result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules()));
for (final Product cur : pluginCatalog.getProducts()) {
final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName());
if (target != null) {
((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable()));
((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded()));
}
}
result.initialize(result, catalogURI);
return result;
}
use of org.killbill.billing.catalog.DefaultProduct in project killbill by killbill.
the class StandaloneCatalogMapper method toDefaultProduct.
private Product toDefaultProduct(@Nullable final Product input) {
if (input == null) {
return null;
}
if (tmpDefaultProducts != null) {
final Product existingProduct = tmpDefaultProducts.get(input.getName());
if (existingProduct == null)
throw new IllegalStateException("Unknown product " + input.getName());
return existingProduct;
}
final DefaultProduct result = new DefaultProduct();
result.setCatalogName(catalogName);
result.setCatagory(input.getCategory());
result.setName(input.getName());
return result;
}
use of org.killbill.billing.catalog.DefaultProduct in project killbill by killbill.
the class TestCasePhase method testOrder.
@Test(groups = "fast")
public void testOrder() throws CatalogApiException {
final MockCatalog cat = new MockCatalog();
final DefaultProduct product = cat.getCurrentProduct(0);
final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist();
final DefaultCaseResult cr0 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, PhaseType.EVERGREEN, Result.FOO);
final DefaultCaseResult cr1 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, PhaseType.EVERGREEN, Result.BAR);
final DefaultCaseResult cr2 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, PhaseType.EVERGREEN, Result.TINKYWINKY);
final DefaultCaseResult cr3 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, PhaseType.EVERGREEN, Result.DIPSY);
final DefaultCaseResult cr4 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, PhaseType.EVERGREEN, Result.LALA);
final Result r1 = DefaultCasePhase.getResult(new DefaultCaseResult[] { cr0, cr1, cr2, cr3, cr4 }, new PlanPhaseSpecifier(product.getName(), BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN), cat);
Assert.assertEquals(Result.FOO, r1);
final Result r2 = DefaultCasePhase.getResult(new DefaultCaseResult[] { cr0, cr1, cr2, cr3, cr4 }, new PlanPhaseSpecifier(product.getName(), BillingPeriod.ANNUAL, priceList.getName(), PhaseType.EVERGREEN), cat);
Assert.assertEquals(Result.DIPSY, r2);
}
use of org.killbill.billing.catalog.DefaultProduct in project killbill by killbill.
the class TestCase method testWildCardProduct.
@Test(groups = "fast")
public void testWildCardProduct() throws CatalogApiException {
final MockCatalog cat = new MockCatalog();
final DefaultProduct product = cat.getCurrentProduct(0);
final DefaultPriceList priceList = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
final DefaultCaseResult cr = new DefaultCaseResult(null, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, Result.FOO);
assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), cat);
assertion(Result.FOO, cr, cat.getCurrentProduct(1).getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), cat);
assertionNull(cr, product.getName(), ProductCategory.BASE, BillingPeriod.ANNUAL, priceList.getName(), cat);
assertionException(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, "dipsy", cat);
}
use of org.killbill.billing.catalog.DefaultProduct in project killbill by killbill.
the class TestCase method testWildCardBillingPeriod.
@Test(groups = "fast")
public void testWildCardBillingPeriod() throws CatalogApiException {
final MockCatalog cat = new MockCatalog();
final DefaultProduct product = cat.getCurrentProduct(0);
final DefaultPriceList priceList = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
final DefaultCaseResult cr = new DefaultCaseResult(product, ProductCategory.BASE, null, priceList, Result.FOO);
assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), cat);
assertionNull(cr, cat.getCurrentProduct(1).getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), cat);
assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.ANNUAL, priceList.getName(), cat);
assertionException(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, "dipsy", cat);
}
Aggregations