Search in sources :

Example 26 with MockCatalog

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

the class TestCasePhase method testWildCardProduct.

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

Example 27 with MockCatalog

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

the class TestBillingApi method beforeMethod.

@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
    super.beforeMethod();
    final SubscriptionBaseBundle bundle = Mockito.mock(SubscriptionBaseBundle.class);
    Mockito.when(bundle.getId()).thenReturn(bunId);
    final List<SubscriptionBaseBundle> bundles = ImmutableList.<SubscriptionBaseBundle>of(bundle);
    effectiveSubscriptionTransitions = new LinkedList<EffectiveSubscriptionInternalEvent>();
    final DateTime subscriptionStartDate = clock.getUTCNow().minusDays(3);
    subscription = new MockSubscription(subId, bunId, null, subscriptionStartDate, subscriptionStartDate);
    final List<SubscriptionBase> subscriptions = ImmutableList.<SubscriptionBase>of(subscription);
    Mockito.when(subscriptionInternalApi.getBundlesForAccount(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(bundles);
    Mockito.when(subscriptionInternalApi.getSubscriptionsForBundle(Mockito.<UUID>any(), Mockito.<DryRunArguments>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscriptions);
    Mockito.when(subscriptionInternalApi.getSubscriptionFromId(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscription);
    Mockito.when(subscriptionInternalApi.getBundleFromId(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(bundle);
    Mockito.when(subscriptionInternalApi.getBaseSubscription(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(subscription);
    Mockito.when(subscriptionInternalApi.getBillingTransitions(Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(effectiveSubscriptionTransitions);
    Mockito.when(subscriptionInternalApi.getAllTransitions(Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(effectiveSubscriptionTransitions);
    catalog = ((MockCatalog) catalogService.getCurrentCatalog(true, true, internalCallContext));
    // TODO The MockCatalog module returns two different things for full vs current catalog
    Mockito.when(catalogService.getFullCatalog(true, true, internalCallContext)).thenReturn(catalog);
    // Set a default alignment
    catalog.setBillingAlignment(BillingAlignment.ACCOUNT);
    // Cleanup mock daos
    ((MockBlockingStateDao) blockingStateDao).clear();
    ((MockTagDao) tagDao).clear();
}
Also used : SubscriptionBase(org.killbill.billing.subscription.api.SubscriptionBase) MockCatalog(org.killbill.billing.catalog.MockCatalog) MockTagDao(org.killbill.billing.util.tag.dao.MockTagDao) EffectiveSubscriptionInternalEvent(org.killbill.billing.events.EffectiveSubscriptionInternalEvent) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) MockSubscription(org.killbill.billing.mock.MockSubscription) MockBlockingStateDao(org.killbill.billing.entitlement.dao.MockBlockingStateDao) DateTime(org.joda.time.DateTime) BeforeMethod(org.testng.annotations.BeforeMethod)

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