Search in sources :

Example 26 with SubscriptionBaseBundle

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);
}
Also used : SubscriptionBase(org.killbill.billing.subscription.api.SubscriptionBase) ImmutableAccountData(org.killbill.billing.account.api.ImmutableAccountData) SubscriptionBaseBundle(org.killbill.billing.subscription.api.user.SubscriptionBaseBundle) Plan(org.killbill.billing.catalog.api.Plan) UUID(java.util.UUID) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime) Catalog(org.killbill.billing.catalog.api.Catalog) Test(org.testng.annotations.Test)

Aggregations

SubscriptionBaseBundle (org.killbill.billing.subscription.api.user.SubscriptionBaseBundle)26 DateTime (org.joda.time.DateTime)17 SubscriptionBase (org.killbill.billing.subscription.api.SubscriptionBase)16 DefaultSubscriptionBase (org.killbill.billing.subscription.api.user.DefaultSubscriptionBase)10 UUID (java.util.UUID)9 SubscriptionBaseApiException (org.killbill.billing.subscription.api.user.SubscriptionBaseApiException)9 ArrayList (java.util.ArrayList)8 Test (org.testng.annotations.Test)8 InternalCallContext (org.killbill.billing.callcontext.InternalCallContext)7 BillingPeriod (org.killbill.billing.catalog.api.BillingPeriod)7 Plan (org.killbill.billing.catalog.api.Plan)7 ImmutableAccountData (org.killbill.billing.account.api.ImmutableAccountData)6 PlanPhasePriceOverride (org.killbill.billing.catalog.api.PlanPhasePriceOverride)6 LinkedList (java.util.LinkedList)4 AccountApiException (org.killbill.billing.account.api.AccountApiException)4 CatalogApiException (org.killbill.billing.catalog.api.CatalogApiException)4 WithEntitlementPlugin (org.killbill.billing.entitlement.api.EntitlementPluginExecution.WithEntitlementPlugin)4 EntitlementContext (org.killbill.billing.entitlement.plugin.api.EntitlementContext)4 DefaultSubscriptionBaseBundle (org.killbill.billing.subscription.api.user.DefaultSubscriptionBaseBundle)4 ImmutableList (com.google.common.collect.ImmutableList)3