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();
}
Aggregations