Search in sources :

Example 1 with MockBlockingStateDao

use of org.killbill.billing.entitlement.dao.MockBlockingStateDao 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)

Example 2 with MockBlockingStateDao

use of org.killbill.billing.entitlement.dao.MockBlockingStateDao in project killbill by killbill.

the class TestBlockingChecker method beforeMethod.

@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
    super.beforeMethod();
    final UUID accountId = UUID.randomUUID();
    account = Mockito.mock(Account.class);
    Mockito.when(account.getId()).thenReturn(accountId);
    bundle = Mockito.mock(SubscriptionBaseBundle.class);
    Mockito.when(bundle.getAccountId()).thenReturn(accountId);
    final UUID bundleId = UUID.randomUUID();
    Mockito.when(bundle.getId()).thenReturn(bundleId);
    Mockito.when(bundle.getExternalKey()).thenReturn("key");
    subscription = Mockito.mock(SubscriptionBase.class);
    Mockito.when(subscription.getId()).thenReturn(UUID.randomUUID());
    Mockito.when(subscription.getBundleId()).thenReturn(bundleId);
    try {
        Mockito.when(subscriptionInternalApi.getBundleFromId(Mockito.<UUID>any(), Mockito.<InternalTenantContext>any())).thenReturn(bundle);
    } catch (SubscriptionBaseApiException e) {
        Assert.fail(e.toString());
    }
    // Cleanup mock daos
    ((MockBlockingStateDao) blockingStateDao).clear();
}
Also used : SubscriptionBase(org.killbill.billing.subscription.api.SubscriptionBase) Account(org.killbill.billing.account.api.Account) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) MockBlockingStateDao(org.killbill.billing.entitlement.dao.MockBlockingStateDao) UUID(java.util.UUID) SubscriptionBaseApiException(org.killbill.billing.subscription.api.user.SubscriptionBaseApiException) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

MockBlockingStateDao (org.killbill.billing.entitlement.dao.MockBlockingStateDao)2 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)2 SubscriptionBaseBundle (org.killbill.billing.subscription.api.user.SubscriptionBaseBundle)2 BeforeMethod (org.testng.annotations.BeforeMethod)2 UUID (java.util.UUID)1 DateTime (org.joda.time.DateTime)1 Account (org.killbill.billing.account.api.Account)1 MockCatalog (org.killbill.billing.catalog.MockCatalog)1 EffectiveSubscriptionInternalEvent (org.killbill.billing.events.EffectiveSubscriptionInternalEvent)1 MockSubscription (org.killbill.billing.mock.MockSubscription)1 SubscriptionBaseApiException (org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)1 MockTagDao (org.killbill.billing.util.tag.dao.MockTagDao)1