use of org.killbill.billing.subscription.api.user.SubscriptionBaseBundle in project killbill by killbill.
the class TestBillCycleDayCalculator method testCalculateBCDForAOWithBPCancelledBundleAligned.
@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);
// Create a the base plan associated with that subscription
final Plan plan = Mockito.mock(Plan.class);
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);
Mockito.when(subscription.getDateOfFirstRecurringNonZeroCharge()).thenReturn(bpStartDateUTC);
final ImmutableAccountData account = Mockito.mock(ImmutableAccountData.class);
Mockito.when(account.getTimeZone()).thenReturn(accountTimeZone);
final Integer billCycleDayLocal = BillCycleDayCalculator.calculateBcdForAlignment(new HashMap<UUID, Integer>(), subscription, subscription, BillingAlignment.BUNDLE, account.getTimeZone(), 0);
Assert.assertEquals(billCycleDayLocal, (Integer) expectedBCDUTC);
}
Aggregations