Search in sources :

Example 6 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog in project killbill by killbill.

the class TestCase method testCaseOrder.

@Test
public void testCaseOrder() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();
    final DefaultProduct product = cat.getCurrentProduct(0);
    final DefaultPriceList priceList = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final DefaultCaseResult cr0 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, Result.FOO);
    final DefaultCaseResult cr1 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, Result.BAR);
    final DefaultCaseResult cr2 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, Result.DIPSY);
    final DefaultCaseResult cr3 = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, Result.LALA);
    final Result r1 = DefaultCase.getResult(new DefaultCaseResult[] { cr0, cr1, cr2, cr3 }, new PlanSpecifier(product.getName(), BillingPeriod.MONTHLY, priceList.getName()), cat);
    Assert.assertEquals(r1, Result.FOO);
    final Result r2 = DefaultCase.getResult(new DefaultCaseResult[] { cr0, cr1, cr2 }, new PlanSpecifier(product.getName(), BillingPeriod.ANNUAL, priceList.getName()), cat);
    Assert.assertEquals(r2, Result.DIPSY);
}
Also used : MockCatalog(org.killbill.billing.catalog.MockCatalog) DefaultProduct(org.killbill.billing.catalog.DefaultProduct) DefaultPriceList(org.killbill.billing.catalog.DefaultPriceList) PlanSpecifier(org.killbill.billing.catalog.api.PlanSpecifier) Test(org.testng.annotations.Test)

Example 7 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog in project killbill by killbill.

the class TestCaseChange method testBasic.

@Test(groups = "fast")
public void testBasic() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();
    final DefaultProduct product1 = cat.getCurrentProduct(0);
    final DefaultPriceList priceList1 = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final DefaultProduct product2 = cat.getCurrentProduct(2);
    final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
    final DefaultCaseChangeResult cr = new DefaultCaseChangeResult(product1, product2, ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1, priceList2, PhaseType.EVERGREEN, Result.FOO);
    assertion(Result.FOO, cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, cat.getCurrentProduct(1).getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), cat.getCurrentProduct(1).getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.ANNUAL, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.ANNUAL, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionException(cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, cat.getCurrentProduct(1).getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionException(cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), cat.getCurrentProduct(1).getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.TRIAL, 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 8 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog in project killbill by killbill.

the class TestCaseChange method testWildCardFromPriceList.

@Test(groups = "fast")
public void testWildCardFromPriceList() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();
    final DefaultProduct product1 = cat.getCurrentProduct(0);
    final DefaultPriceList priceList1 = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final DefaultProduct product2 = cat.getCurrentProduct(2);
    final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
    final DefaultCaseChangeResult cr = new DefaultCaseChangeResult(product1, product2, ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, null, priceList2, PhaseType.EVERGREEN, Result.FOO);
    assertion(Result.FOO, cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, cat.getCurrentProduct(1).getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), cat.getCurrentProduct(1).getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.ANNUAL, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.ANNUAL, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertion(Result.FOO, cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.EVERGREEN, cat);
    assertionException(cr, product1.getName(), product2.getName(), BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), cat.getCurrentProduct(1).getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product1.getName(), product2.getName(), ProductCategory.BASE, ProductCategory.BASE, BillingPeriod.MONTHLY, BillingPeriod.MONTHLY, priceList1.getName(), priceList2.getName(), PhaseType.TRIAL, 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 9 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog in project killbill by killbill.

the class TestCasePhase method testWildCardPriceList.

@Test(groups = "fast")
public void testWildCardPriceList() {
    final MockCatalog cat = new MockCatalog();
    final DefaultProduct product = cat.getCurrentProduct(0);
    final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist();
    final DefaultCaseResult cr = new DefaultCaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, null, PhaseType.EVERGREEN, Result.FOO);
    assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, cat.getCurrentProduct(1).getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, product.getName(), ProductCategory.BASE, BillingPeriod.ANNUAL, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, "dipsy", PhaseType.EVERGREEN, cat);
    assertionNull(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.TRIAL, 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 10 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog in project killbill by killbill.

the class TestCasePhase method testWildCardBillingPeriod.

@Test(groups = "fast")
public void testWildCardBillingPeriod() {
    final MockCatalog cat = new MockCatalog();
    final DefaultProduct product = cat.getCurrentProduct(0);
    final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist();
    final DefaultCaseResult cr = new DefaultCaseResult(product, ProductCategory.BASE, null, priceList, PhaseType.EVERGREEN, Result.FOO);
    assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertionNull(cr, cat.getCurrentProduct(1).getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.ANNUAL, priceList.getName(), PhaseType.EVERGREEN, cat);
    assertionException(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, "dipsy", PhaseType.EVERGREEN, cat);
    assertionNull(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.TRIAL, 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

MockCatalog (org.killbill.billing.catalog.MockCatalog)27 DefaultPriceList (org.killbill.billing.catalog.DefaultPriceList)25 DefaultProduct (org.killbill.billing.catalog.DefaultProduct)24 Test (org.testng.annotations.Test)24 BeforeMethod (org.testng.annotations.BeforeMethod)3 PlanPhaseSpecifier (org.killbill.billing.catalog.api.PlanPhaseSpecifier)2 PlanSpecifier (org.killbill.billing.catalog.api.PlanSpecifier)2 DateTime (org.joda.time.DateTime)1 MockCatalogService (org.killbill.billing.catalog.MockCatalogService)1 CatalogService (org.killbill.billing.catalog.api.CatalogService)1 MockBlockingStateDao (org.killbill.billing.entitlement.dao.MockBlockingStateDao)1 EffectiveSubscriptionInternalEvent (org.killbill.billing.events.EffectiveSubscriptionInternalEvent)1 MockSubscription (org.killbill.billing.mock.MockSubscription)1 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)1 SubscriptionBaseApiService (org.killbill.billing.subscription.api.SubscriptionBaseApiService)1 SubscriptionBaseTimelineApi (org.killbill.billing.subscription.api.timeline.SubscriptionBaseTimelineApi)1 SubscriptionBaseBundle (org.killbill.billing.subscription.api.user.SubscriptionBaseBundle)1 SubscriptionDao (org.killbill.billing.subscription.engine.dao.SubscriptionDao)1 NonEntityDao (org.killbill.billing.util.dao.NonEntityDao)1 MockTagDao (org.killbill.billing.util.tag.dao.MockTagDao)1