protected BillingEvent createMockBillingEvent(final int bcd, final DateTime effectiveDate, final BillingPeriod billingPeriod, final List<Usage> usages) { final BillingEvent result = Mockito.mock(BillingEvent.class); Mockito.when(result.getCurrency()).thenReturn(Currency.BTC); Mockito.when(result.getBillCycleDayLocal()).thenReturn(bcd); Mockito.when(result.getEffectiveDate()).thenReturn(effectiveDate); Mockito.when(result.getBillingPeriod()).thenReturn(billingPeriod); final Account account = Mockito.mock(Account.class); Mockito.when(account.getId()).thenReturn(accountId); final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class); Mockito.when(subscription.getId()).thenReturn(subscriptionId); Mockito.when(subscription.getBundleId()).thenReturn(bundleId); Mockito.when(result.getSubscription()).thenReturn(subscription); final Product product = Mockito.mock(Product.class); Mockito.when(product.getName()).thenReturn(productName); final Plan plan = Mockito.mock(Plan.class); Mockito.when(plan.getName()).thenReturn(planName); Mockito.when(plan.getProduct()).thenReturn(product); Mockito.when(result.getPlan()).thenReturn(plan); final PlanPhase phase = Mockito.mock(PlanPhase.class); Mockito.when(phase.getName()).thenReturn(phaseName); Mockito.when(result.getPlanPhase()).thenReturn(phase); Mockito.when(result.getUsages()).thenReturn(usages); return result; }
protected BillingEvent createNewReenableEvent(final DateTime odEventTime, final BillingEvent previousEvent, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException { // All fields are populated with the event state from before the blocking period, for invoice to resume invoicing final int billCycleDay = previousEvent.getBillCycleDayLocal(); final SubscriptionBase subscription = previousEvent.getSubscription(); final DateTime effectiveDate = odEventTime; final PlanPhase planPhase = previousEvent.getPlanPhase(); final BigDecimal fixedPrice = previousEvent.getFixedPrice(); final Plan plan = previousEvent.getPlan(); final Currency currency = previousEvent.getCurrency(); final String description = ""; final BillingPeriod billingPeriod = previousEvent.getBillingPeriod(); final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.END_BILLING_DISABLED; final Long totalOrdering = globaltotalOrder.getAndIncrement(); return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice, currency, billingPeriod, billCycleDay, description, totalOrdering, type, catalog, false); }
final BillingPeriod billingPeriod = thisEvent.getBillingPeriod(); if (billingPeriod != BillingPeriod.NO_BILLING_PERIOD) { final LocalDate startDate = internalCallContext.toLocalDate(thisEvent.getEffectiveDate());