@Test(groups = "fast")
  public void testCalculateBCDForAOWithBPCancelledBundleAligned() throws Exception {
    final DateTimeZone accountTimeZone = DateTimeZone.UTC;
    final DateTime bpStartDateUTC = new DateTime(2012, 7, 16, 21, 0, 0, DateTimeZone.UTC);
    final int expectedBCDUTC = 16;

    // Create a Bundle associated with a subscription
    final SubscriptionBaseBundle bundle = Mockito.mock(SubscriptionBaseBundle.class);
    final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class);
    Mockito.when(subscription.getStartDate()).thenReturn(bpStartDateUTC);

    // subscription.getCurrentPlan() will return null as expected (cancelled BP)
    Mockito.when(
            subscriptionInternalApi.getBaseSubscription(
                Mockito.<UUID>any(), Mockito.<InternalTenantContext>any()))
        .thenReturn(subscription);

    // Create a the base plan associated with that subscription
    final Plan plan = Mockito.mock(Plan.class);
    Mockito.when(plan.dateOfFirstRecurringNonZeroCharge(bpStartDateUTC, null))
        .thenReturn(bpStartDateUTC);
    final Catalog catalog = Mockito.mock(Catalog.class);
    Mockito.when(
            catalog.findPlan(Mockito.anyString(), Mockito.<DateTime>any(), Mockito.<DateTime>any()))
        .thenReturn(plan);
    Mockito.when(subscription.getLastActivePlan()).thenReturn(plan);

    final Account account = Mockito.mock(Account.class);
    Mockito.when(account.getTimeZone()).thenReturn(accountTimeZone);
    final Integer billCycleDayLocal =
        billCycleDayCalculator.calculateBcdForAlignment(
            BillingAlignment.BUNDLE,
            bundle,
            subscription,
            account,
            catalog,
            null,
            internalCallContext);

    Assert.assertEquals(billCycleDayLocal, (Integer) expectedBCDUTC);
  }
  private void verifyBCDCalculation(
      final DateTimeZone accountTimeZone, final DateTime startDateUTC, final int bcdLocal)
      throws AccountApiException, CatalogApiException {
    final BillCycleDayCalculator billCycleDayCalculator =
        new BillCycleDayCalculator(
            Mockito.mock(CatalogService.class), Mockito.mock(SubscriptionBaseInternalApi.class));

    final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class);
    Mockito.when(subscription.getStartDate()).thenReturn(startDateUTC);

    final Plan plan = Mockito.mock(Plan.class);
    Mockito.when(plan.dateOfFirstRecurringNonZeroCharge(startDateUTC, null))
        .thenReturn(startDateUTC);

    final Account account = Mockito.mock(Account.class);
    Mockito.when(account.getTimeZone()).thenReturn(accountTimeZone);

    final Integer bcd =
        billCycleDayCalculator.calculateBcdFromSubscription(
            subscription, plan, account, Mockito.mock(Catalog.class), internalCallContext);
    Assert.assertEquals(bcd, (Integer) bcdLocal);
  }