Search in sources :

Example 1 with DefaultProduct

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;
}
Also used : DefaultProduct(org.killbill.billing.catalog.DefaultProduct) StandaloneCatalog(org.killbill.billing.catalog.StandaloneCatalog) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) Product(org.killbill.billing.catalog.api.Product)

Example 2 with DefaultProduct

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;
}
Also used : DefaultProduct(org.killbill.billing.catalog.DefaultProduct) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) Product(org.killbill.billing.catalog.api.Product)

Example 3 with DefaultProduct

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);
}
Also used : PlanPhaseSpecifier(org.killbill.billing.catalog.api.PlanPhaseSpecifier) MockCatalog(org.killbill.billing.catalog.MockCatalog) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) DefaultPriceList(org.killbill.billing.catalog.DefaultPriceList) Test(org.testng.annotations.Test)

Example 4 with DefaultProduct

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);
}
Also used : MockCatalog(org.killbill.billing.catalog.MockCatalog) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) DefaultPriceList(org.killbill.billing.catalog.DefaultPriceList) Test(org.testng.annotations.Test)

Example 5 with DefaultProduct

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);
}
Also used : MockCatalog(org.killbill.billing.catalog.MockCatalog) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) DefaultPriceList(org.killbill.billing.catalog.DefaultPriceList) Test(org.testng.annotations.Test)

Aggregations

DefaultProduct (org.killbill.billing.catalog.DefaultProduct)29 Test (org.testng.annotations.Test)27 DefaultPriceList (org.killbill.billing.catalog.DefaultPriceList)26 MockCatalog (org.killbill.billing.catalog.MockCatalog)24 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)4 PlanSpecifier (org.killbill.billing.catalog.api.PlanSpecifier)4 StandaloneCatalog (org.killbill.billing.catalog.StandaloneCatalog)2 CatalogApiException (org.killbill.billing.catalog.api.CatalogApiException)2 IllegalPlanChange (org.killbill.billing.catalog.api.IllegalPlanChange)2 PlanChangeResult (org.killbill.billing.catalog.api.PlanChangeResult)2 Product (org.killbill.billing.catalog.api.Product)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 URI (java.net.URI)1 DefaultDuration (org.killbill.billing.catalog.DefaultDuration)1 DefaultFixed (org.killbill.billing.catalog.DefaultFixed)1 DefaultInternationalPrice (org.killbill.billing.catalog.DefaultInternationalPrice)1 DefaultMutableStaticCatalog (org.killbill.billing.catalog.DefaultMutableStaticCatalog)1 DefaultPlan (org.killbill.billing.catalog.DefaultPlan)1 DefaultPlanPhase (org.killbill.billing.catalog.DefaultPlanPhase)1 DefaultPrice (org.killbill.billing.catalog.DefaultPrice)1