Search in sources :

Example 1 with MockCatalog

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

the class TestDefaultSubscriptionTransferApi method beforeMethod.

@Override
@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
    super.beforeMethod();
    final NonEntityDao nonEntityDao = Mockito.mock(NonEntityDao.class);
    final SubscriptionDao dao = Mockito.mock(SubscriptionDao.class);
    final CatalogService catalogService = new MockCatalogService(new MockCatalog(), cacheControllerDispatcher);
    final SubscriptionBaseApiService apiService = Mockito.mock(SubscriptionBaseApiService.class);
    final SubscriptionBaseTimelineApi timelineApi = Mockito.mock(SubscriptionBaseTimelineApi.class);
    transferApi = new DefaultSubscriptionBaseTransferApi(clock, dao, timelineApi, catalogService, apiService, internalCallContextFactory);
}
Also used : MockCatalog(org.killbill.billing.catalog.MockCatalog) NonEntityDao(org.killbill.billing.util.dao.NonEntityDao) SubscriptionBaseTimelineApi(org.killbill.billing.subscription.api.timeline.SubscriptionBaseTimelineApi) MockCatalogService(org.killbill.billing.catalog.MockCatalogService) CatalogService(org.killbill.billing.catalog.api.CatalogService) SubscriptionBaseApiService(org.killbill.billing.subscription.api.SubscriptionBaseApiService) SubscriptionDao(org.killbill.billing.subscription.engine.dao.SubscriptionDao) MockCatalogService(org.killbill.billing.catalog.MockCatalogService) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 2 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog 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 3 with MockCatalog

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

the class TestPlanRules method beforeMethod.

@BeforeMethod(groups = "fast")
public void beforeMethod() {
    cat = new MockCatalog();
    final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[0];
    final DefaultCaseChangePlanPolicy casePolicy = new DefaultCaseChangePlanPolicy().setPolicy(BillingActionPolicy.END_OF_TERM);
    final DefaultCaseChangePlanAlignment caseAlignment = new DefaultCaseChangePlanAlignment().setAlignment(PlanAlignmentChange.START_OF_SUBSCRIPTION);
    final DefaultCasePriceList casePriceList = new DefaultCasePriceList().setToPriceList(priceList2);
    cat.getPlanRules().setChangeCase(new DefaultCaseChangePlanPolicy[] { casePolicy }).setChangeAlignmentCase(new DefaultCaseChangePlanAlignment[] { caseAlignment }).setPriceListCase(new DefaultCasePriceList[] { casePriceList });
}
Also used : MockCatalog(org.killbill.billing.catalog.MockCatalog) DefaultPriceList(org.killbill.billing.catalog.DefaultPriceList) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 4 with MockCatalog

use of org.killbill.billing.catalog.MockCatalog 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 MockCatalog

use of org.killbill.billing.catalog.MockCatalog 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

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