Search in sources :

Example 1 with MockTagDao

use of org.killbill.billing.util.tag.dao.MockTagDao in project killbill by killbill.

the class TestBillingApi method beforeMethod.

@BeforeMethod(groups = "fast")
public void beforeMethod() throws Exception {
    if (hasFailed()) {
        return;
    }
    super.beforeMethod();
    final SubscriptionBaseBundle bundle = Mockito.mock(SubscriptionBaseBundle.class);
    Mockito.when(bundle.getId()).thenReturn(bunId);
    final List<SubscriptionBaseBundle> bundles = ImmutableList.<SubscriptionBaseBundle>of(bundle);
    billingTransitions = new LinkedList<SubscriptionBillingEvent>();
    effectiveSubscriptionTransitions = new LinkedList<EffectiveSubscriptionInternalEvent>();
    final DateTime subscriptionStartDate = clock.getUTCNow().minusDays(3);
    subscription = new MockSubscription(subId, bunId, null, null, subscriptionStartDate, subscriptionStartDate);
    final List<SubscriptionBase> subscriptions = ImmutableList.<SubscriptionBase>of(subscription);
    // Mockito.when(subscription.getBillingAlignment(Mockito.<PlanPhaseSpecifier>any(), Mockito.<DateTime>any(), Mockito.<Catalog>any())).thenReturn(BillingAlignment.ACCOUNT);
    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.getSubscriptionsForAccount(Mockito.<VersionedCatalog>any(), Mockito.<LocalDate>any(), Mockito.<InternalTenantContext>any())).thenReturn(ImmutableMap.<UUID, List<SubscriptionBase>>builder().put(bunId, subscriptions).build());
    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.getSubscriptionBillingEvents(Mockito.<VersionedCatalog>any(), Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(billingTransitions);
    Mockito.when(subscriptionInternalApi.getAllTransitions(Mockito.<SubscriptionBase>any(), Mockito.<InternalTenantContext>any())).thenReturn(effectiveSubscriptionTransitions);
    final VersionedCatalog versionedCatalog = catalogService.getFullCatalog(true, true, internalCallContext);
    catalog = (MockCatalog) Iterables.getLast(versionedCatalog.getVersions());
    Mockito.when(catalogService.getFullCatalog(true, true, internalCallContext)).thenReturn(versionedCatalog);
    // Set a default alignment
    ((MockSubscription) subscription).setBillingAlignment(BillingAlignment.ACCOUNT);
    // Cleanup mock daos
    ((MockBlockingStateDao) blockingStateDao).clear();
    ((MockTagDao) tagDao).clear();
}
Also used : EffectiveSubscriptionInternalEvent(org.killbill.billing.events.EffectiveSubscriptionInternalEvent) MockSubscription(org.killbill.billing.mock.MockSubscription) MockBlockingStateDao(org.killbill.billing.entitlement.dao.MockBlockingStateDao) DateTime(org.joda.time.DateTime) SubscriptionBase(org.killbill.billing.subscription.api.SubscriptionBase) VersionedCatalog(org.killbill.billing.catalog.api.VersionedCatalog) MockTagDao(org.killbill.billing.util.tag.dao.MockTagDao) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) SubscriptionBillingEvent(org.killbill.billing.subscription.api.user.SubscriptionBillingEvent) DefaultSubscriptionBillingEvent(org.killbill.billing.subscription.api.user.DefaultSubscriptionBillingEvent) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

DateTime (org.joda.time.DateTime)1 VersionedCatalog (org.killbill.billing.catalog.api.VersionedCatalog)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 DefaultSubscriptionBillingEvent (org.killbill.billing.subscription.api.user.DefaultSubscriptionBillingEvent)1 SubscriptionBaseBundle (org.killbill.billing.subscription.api.user.SubscriptionBaseBundle)1 SubscriptionBillingEvent (org.killbill.billing.subscription.api.user.SubscriptionBillingEvent)1 MockTagDao (org.killbill.billing.util.tag.dao.MockTagDao)1 BeforeMethod (org.testng.annotations.BeforeMethod)1