Search in sources :

Example 11 with DefaultPrice

use of org.killbill.billing.catalog.DefaultPrice in project killbill by killbill.

the class TestFixedAndRecurringInvoiceItemGenerator method testProcessFixedBillingEventsWithCancellationOnNextDay.

@Test(groups = "fast")
public void testProcessFixedBillingEventsWithCancellationOnNextDay() throws InvoiceApiException {
    final LocalDate targetDate = new LocalDate("2016-01-08");
    final UUID invoiceId = UUID.randomUUID();
    final BillingEventSet events = new MockBillingEventSet();
    final BigDecimal fixedPriceAmount = BigDecimal.TEN;
    final MockInternationalPrice fixedPrice = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount, Currency.USD));
    final Plan plan = new MockPlan("my-plan");
    final PlanPhase phase = new MockPlanPhase(null, fixedPrice, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
    final BillingEvent event1 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-08"), plan, phase, fixedPriceAmount, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 1L, SubscriptionBaseTransitionType.CREATE);
    events.add(event1);
    final BillingEvent event2 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-09"), plan, phase, null, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 2L, SubscriptionBaseTransitionType.CANCEL);
    events.add(event2);
    final List<InvoiceItem> proposedItems = new ArrayList<InvoiceItem>();
    fixedAndRecurringInvoiceItemGenerator.processFixedBillingEvents(invoiceId, account.getId(), events, targetDate, Currency.USD, proposedItems, internalCallContext);
    assertEquals(proposedItems.size(), 1);
    assertEquals(proposedItems.get(0).getInvoiceItemType(), InvoiceItemType.FIXED);
    assertEquals(proposedItems.get(0).getAmount().compareTo(fixedPriceAmount), 0);
}
Also used : FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) RecurringInvoiceItem(org.killbill.billing.invoice.model.RecurringInvoiceItem) InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) RepairAdjInvoiceItem(org.killbill.billing.invoice.model.RepairAdjInvoiceItem) ItemAdjInvoiceItem(org.killbill.billing.invoice.model.ItemAdjInvoiceItem) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) ArrayList(java.util.ArrayList) MockPlan(org.killbill.billing.catalog.MockPlan) Plan(org.killbill.billing.catalog.api.Plan) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) DateTime(org.joda.time.DateTime) MockPlan(org.killbill.billing.catalog.MockPlan) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) BillingEventSet(org.killbill.billing.junction.BillingEventSet) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent) BillingEvent(org.killbill.billing.junction.BillingEvent) UUID(java.util.UUID) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) Test(org.testng.annotations.Test)

Example 12 with DefaultPrice

use of org.killbill.billing.catalog.DefaultPrice in project killbill by killbill.

the class TestFixedAndRecurringInvoiceItemGenerator method testProcessFixedBillingEventsWithMultipleChangeOnSameDay.

@Test(groups = "fast")
public void testProcessFixedBillingEventsWithMultipleChangeOnSameDay() throws InvoiceApiException {
    final LocalDate targetDate = new LocalDate("2016-01-08");
    final UUID invoiceId = UUID.randomUUID();
    final BillingEventSet events = new MockBillingEventSet();
    final BigDecimal fixedPriceAmount1 = BigDecimal.TEN;
    final MockInternationalPrice fixedPrice1 = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount1, Currency.USD));
    final Plan plan1 = new MockPlan("my-plan1");
    final PlanPhase planPhase1 = new MockPlanPhase(null, fixedPrice1, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
    final BillingEvent event1 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-08"), plan1, planPhase1, fixedPriceAmount1, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 1L, SubscriptionBaseTransitionType.CREATE);
    events.add(event1);
    final BigDecimal fixedPriceAmount2 = null;
    final MockInternationalPrice fixedPrice2 = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount2, Currency.USD));
    final Plan plan2 = new MockPlan("my-plan2");
    final PlanPhase planPhase2 = new MockPlanPhase(null, fixedPrice2, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
    final BillingEvent event2 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-08"), plan2, planPhase2, fixedPriceAmount2, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 2L, SubscriptionBaseTransitionType.CHANGE);
    events.add(event2);
    final BigDecimal fixedPriceAmount3 = BigDecimal.ONE;
    final MockInternationalPrice fixedPrice3 = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount3, Currency.USD));
    final Plan plan3 = new MockPlan("my-plan3");
    final PlanPhase planPhase3 = new MockPlanPhase(null, fixedPrice3, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
    final BillingEvent event3 = invoiceUtil.createMockBillingEvent(account, subscription, new DateTime("2016-01-08"), plan3, planPhase3, fixedPriceAmount3, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 3L, SubscriptionBaseTransitionType.CHANGE);
    events.add(event3);
    final List<InvoiceItem> proposedItems = new ArrayList<InvoiceItem>();
    fixedAndRecurringInvoiceItemGenerator.processFixedBillingEvents(invoiceId, account.getId(), events, targetDate, Currency.USD, proposedItems, internalCallContext);
    assertEquals(proposedItems.size(), 1);
    assertEquals(proposedItems.get(0).getInvoiceItemType(), InvoiceItemType.FIXED);
    assertEquals(proposedItems.get(0).getAmount().compareTo(fixedPriceAmount3), 0);
}
Also used : FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) RecurringInvoiceItem(org.killbill.billing.invoice.model.RecurringInvoiceItem) InvoiceItem(org.killbill.billing.invoice.api.InvoiceItem) RepairAdjInvoiceItem(org.killbill.billing.invoice.model.RepairAdjInvoiceItem) ItemAdjInvoiceItem(org.killbill.billing.invoice.model.ItemAdjInvoiceItem) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) ArrayList(java.util.ArrayList) MockPlan(org.killbill.billing.catalog.MockPlan) Plan(org.killbill.billing.catalog.api.Plan) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) DateTime(org.joda.time.DateTime) MockPlan(org.killbill.billing.catalog.MockPlan) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) BillingEventSet(org.killbill.billing.junction.BillingEventSet) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) DefaultBillingEvent(org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent) BillingEvent(org.killbill.billing.junction.BillingEvent) UUID(java.util.UUID) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) Test(org.testng.annotations.Test)

Example 13 with DefaultPrice

use of org.killbill.billing.catalog.DefaultPrice in project killbill by killbill.

the class TestFixedAndRecurringInvoiceItemGeneratorWithOptimization method testFixedPrice.

@Test(groups = "fast")
public void testFixedPrice() throws InvoiceApiException {
    final BillingEventSet events = new MockBillingEventSet();
    final BigDecimal fixedPriceAmount = BigDecimal.TEN;
    final MockInternationalPrice fixedPrice = new MockInternationalPrice(new DefaultPrice(fixedPriceAmount, Currency.USD));
    final Plan plan = new MockPlan("my-plan");
    final PlanPhase phase = new MockPlanPhase(null, fixedPrice, BillingPeriod.NO_BILLING_PERIOD, PhaseType.TRIAL);
    final DateTime startDate = new DateTime("2020-01-01");
    final BillingEvent event = invoiceUtil.createMockBillingEvent(account, subscription, startDate, plan, phase, fixedPriceAmount, null, Currency.USD, BillingPeriod.NO_BILLING_PERIOD, 1, BillingMode.IN_ADVANCE, "Billing Event Desc", 1L, SubscriptionBaseTransitionType.CREATE);
    events.add(event);
    // Only look for older invoices 1 month from NOW (we assume targetDate = NOW as time pass normally)
    final Period maxInvoiceLimit = new Period("P1m");
    // Initial invoicing (targetDate1  = startDate)
    // There is no existing invoice
    // => Should generate the item
    // 2020-01-01
    final LocalDate targetDate1 = startDate.toLocalDate();
    final LocalDate cuttoffDate1 = targetDate1.minus(maxInvoiceLimit);
    final AccountInvoices existingInvoices1 = new AccountInvoicesExp(cuttoffDate1, null, ImmutableList.of());
    final InvoiceGeneratorResult result1 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices1, targetDate1, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result1.getItems().size(), 1);
    assertEquals(result1.getItems().get(0).getInvoiceItemType(), InvoiceItemType.FIXED);
    assertEquals(result1.getItems().get(0).getStartDate().compareTo(new LocalDate("2020-01-01")), 0);
    // One month after invoicing, optimization does not kick-in yet
    // There is an existing invoice
    // => Should not regenerate the item
    // 2020-02-01
    final LocalDate targetDate2 = startDate.toLocalDate().plusMonths(1);
    final LocalDate cuttoffDate2 = targetDate2.minus(maxInvoiceLimit);
    final Invoice invoice = new DefaultInvoice(account.getId(), clock.getUTCToday(), targetDate2, account.getCurrency());
    invoice.addInvoiceItem(new FixedPriceInvoiceItem(UUID.randomUUID(), clock.getUTCNow(), invoice.getId(), account.getId(), subscription.getBundleId(), subscription.getId(), null, event.getPlan().getName(), event.getPlanPhase().getName(), null, "Buggy fixed item", startDate.toLocalDate(), fixedPriceAmount, account.getCurrency()));
    final AccountInvoices existingInvoices2 = new AccountInvoicesExp(cuttoffDate2, null, ImmutableList.of(invoice));
    final InvoiceGeneratorResult result2 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices2, targetDate2, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result2.getItems().size(), 0);
    // Two month after invoicing, optimization *does* not kick-in
    // There is no existing invoice (optimization removed it)
    // => Should not regenerate the item
    // 2020-03-01;
    final LocalDate targetDate3 = startDate.toLocalDate().plusMonths(2);
    final LocalDate cuttoffDate3 = targetDate3.minus(maxInvoiceLimit);
    final AccountInvoices existingInvoices3 = new AccountInvoicesExp(cuttoffDate3, null, ImmutableList.of());
    final InvoiceGeneratorResult result3 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices3, targetDate3, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result3.getItems().size(), 0);
}
Also used : SubscriptionFutureNotificationDates(org.killbill.billing.invoice.generator.InvoiceWithMetadata.SubscriptionFutureNotificationDates) AccountInvoices(org.killbill.billing.invoice.optimizer.InvoiceOptimizerBase.AccountInvoices) Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) Period(org.joda.time.Period) BillingPeriod(org.killbill.billing.catalog.api.BillingPeriod) FixedPriceInvoiceItem(org.killbill.billing.invoice.model.FixedPriceInvoiceItem) MockPlan(org.killbill.billing.catalog.MockPlan) Plan(org.killbill.billing.catalog.api.Plan) InvoiceGeneratorResult(org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceGeneratorResult) LocalDate(org.joda.time.LocalDate) BigDecimal(java.math.BigDecimal) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) DateTime(org.joda.time.DateTime) AccountInvoicesExp(org.killbill.billing.invoice.optimizer.InvoiceOptimizerExp.AccountInvoicesExp) MockPlan(org.killbill.billing.catalog.MockPlan) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) BillingEventSet(org.killbill.billing.junction.BillingEventSet) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) BillingEvent(org.killbill.billing.junction.BillingEvent) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) UUID(java.util.UUID) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) Test(org.testng.annotations.Test)

Example 14 with DefaultPrice

use of org.killbill.billing.catalog.DefaultPrice in project killbill by killbill.

the class TestFixedAndRecurringInvoiceItemGeneratorWithOptimization method testRecurringInArrear.

@Test(groups = "fast")
public void testRecurringInArrear() throws InvoiceApiException {
    final DateTime startDate = new DateTime("2020-01-01");
    final BillingEventSet events = new MockBillingEventSet();
    final BigDecimal amount = BigDecimal.TEN;
    final MockInternationalPrice price = new MockInternationalPrice(new DefaultPrice(amount, account.getCurrency()));
    final MockPlan plan = new MockPlan("my-plan");
    plan.setRecurringBillingMode(BillingMode.IN_ARREAR);
    final PlanPhase planPhase = new MockPlanPhase(price, null, BillingPeriod.MONTHLY, PhaseType.EVERGREEN);
    final BillingEvent event = invoiceUtil.createMockBillingEvent(account, subscription, startDate, plan, planPhase, null, amount, account.getCurrency(), planPhase.getRecurring().getBillingPeriod(), 1, BillingMode.IN_ARREAR, "Billing Event Desc", 1L, SubscriptionBaseTransitionType.CREATE);
    events.add(event);
    // Only look for older invoices 1 month from NOW (we assume targetDate = NOW as time pass normally)
    final Period maxInvoiceLimit = new Period("P1m");
    // Initial invoicing (targetDate1  = startDate)
    // There is nothing to invoice// => Should generate the item
    // 2020-01-01
    final LocalDate targetDate1 = startDate.toLocalDate();
    final LocalDate cuttoffDate1 = targetDate1.minus(maxInvoiceLimit);
    final AccountInvoices existingInvoices1 = new AccountInvoicesExp(cuttoffDate1, null, ImmutableList.of());
    final InvoiceGeneratorResult result1 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices1, targetDate1, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result1.getItems().size(), 0);
    // Initial invoicing (targetDate2  = startDate + 1 month)
    // There is no existing invoice
    // => Should generate the item
    // 2020-02-01
    final LocalDate targetDate2 = startDate.plusMonths(1).toLocalDate();
    final LocalDate cuttoffDate2 = targetDate2.minus(maxInvoiceLimit);
    final AccountInvoices existingInvoices2 = new AccountInvoicesExp(cuttoffDate2, null, ImmutableList.of());
    final InvoiceGeneratorResult result2 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices2, targetDate2, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result2.getItems().get(0).getInvoiceItemType(), InvoiceItemType.RECURRING);
    assertEquals(result2.getItems().get(0).getStartDate().compareTo(new LocalDate("2020-01-01")), 0);
    assertEquals(result2.getItems().get(0).getEndDate().compareTo(new LocalDate("2020-02-01")), 0);
    // 2020-03-01
    final LocalDate targetDate3 = startDate.plusMonths(2).toLocalDate();
    final LocalDate cuttoffDate3 = targetDate3.minus(maxInvoiceLimit);
    final Invoice invoice3 = new DefaultInvoice(account.getId(), clock.getUTCToday(), targetDate3, account.getCurrency());
    invoice3.addInvoiceItem(new RecurringInvoiceItem(UUID.randomUUID(), startDate.plusMonths(1), invoice3.getId(), account.getId(), subscription.getBundleId(), subscription.getId(), null, event.getPlan().getName(), event.getPlanPhase().getName(), null, startDate.toLocalDate(), startDate.plusMonths(1).toLocalDate(), amount, amount, account.getCurrency()));
    final AccountInvoices existingInvoices3 = new AccountInvoicesExp(cuttoffDate3, null, ImmutableList.of(invoice3));
    final InvoiceGeneratorResult result3 = fixedAndRecurringInvoiceItemGenerator.generateItems(account, UUID.randomUUID(), events, existingInvoices3, targetDate3, account.getCurrency(), new HashMap<UUID, SubscriptionFutureNotificationDates>(), null, internalCallContext);
    assertEquals(result3.getItems().get(0).getInvoiceItemType(), InvoiceItemType.RECURRING);
    assertEquals(result3.getItems().get(0).getStartDate().compareTo(new LocalDate("2020-02-01")), 0);
    assertEquals(result3.getItems().get(0).getEndDate().compareTo(new LocalDate("2020-03-01")), 0);
}
Also used : SubscriptionFutureNotificationDates(org.killbill.billing.invoice.generator.InvoiceWithMetadata.SubscriptionFutureNotificationDates) AccountInvoices(org.killbill.billing.invoice.optimizer.InvoiceOptimizerBase.AccountInvoices) Invoice(org.killbill.billing.invoice.api.Invoice) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) RecurringInvoiceItem(org.killbill.billing.invoice.model.RecurringInvoiceItem) Period(org.joda.time.Period) BillingPeriod(org.killbill.billing.catalog.api.BillingPeriod) InvoiceGeneratorResult(org.killbill.billing.invoice.generator.InvoiceItemGenerator.InvoiceGeneratorResult) LocalDate(org.joda.time.LocalDate) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) AccountInvoicesExp(org.killbill.billing.invoice.optimizer.InvoiceOptimizerExp.AccountInvoicesExp) MockPlan(org.killbill.billing.catalog.MockPlan) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) BillingEventSet(org.killbill.billing.junction.BillingEventSet) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) BillingEvent(org.killbill.billing.junction.BillingEvent) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) UUID(java.util.UUID) DefaultInvoice(org.killbill.billing.invoice.model.DefaultInvoice) Test(org.testng.annotations.Test)

Example 15 with DefaultPrice

use of org.killbill.billing.catalog.DefaultPrice in project killbill by killbill.

the class TestBillingEventSetJson method testTestBillingEventSetJsonSerialization.

@Test(groups = "fast")
public void testTestBillingEventSetJsonSerialization() throws Exception {
    final LocalDate startDate = new LocalDate(2019, 9, 26);
    final UUID subscriptionId = UUID.randomUUID();
    final UUID bundleId = UUID.randomUUID();
    final Currency currency = Currency.USD;
    final SubscriptionBase sub = Mockito.mock(SubscriptionBase.class);
    Mockito.when(sub.getId()).thenReturn(subscriptionId);
    Mockito.when(sub.getBundleId()).thenReturn(bundleId);
    final MockBillingEventSet billingEventSet = new MockBillingEventSet();
    final Plan plan = new MockPlan("Test");
    final MockInternationalPrice recurringPrice = new MockInternationalPrice(new DefaultPrice(THIRTEEN, Currency.USD));
    final PlanPhase planPhase = new MockPlanPhase(recurringPrice, null, BillingPeriod.MONTHLY, PhaseType.EVERGREEN);
    final DateTime effectiveDate1 = startDate.toDateTimeAtStartOfDay();
    final BillingEvent event1 = invoiceUtil.createMockBillingEvent(null, sub, effectiveDate1, plan, planPhase, planPhase.getFixed().getPrice() == null ? null : planPhase.getFixed().getPrice().getPrice(currency), planPhase.getRecurring().getRecurringPrice() == null ? null : planPhase.getRecurring().getRecurringPrice().getPrice(currency), currency, planPhase.getRecurring().getBillingPeriod(), 1, BillingMode.IN_ADVANCE, "Test", 1, SubscriptionBaseTransitionType.CREATE);
    billingEventSet.add(event1);
    final DateTime effectiveDate2 = startDate.toDateTimeAtStartOfDay().plusDays(10);
    final BillingEvent event2 = invoiceUtil.createMockBillingEvent(null, sub, effectiveDate2, plan, planPhase, planPhase.getFixed().getPrice() == null ? null : planPhase.getFixed().getPrice().getPrice(currency), planPhase.getRecurring().getRecurringPrice() == null ? null : planPhase.getRecurring().getRecurringPrice().getPrice(currency), currency, planPhase.getRecurring().getBillingPeriod(), 1, BillingMode.IN_ADVANCE, "Test", 1, SubscriptionBaseTransitionType.CHANGE);
    billingEventSet.add(event2);
    final BillingEventSetJson json = new BillingEventSetJson(billingEventSet);
    final String asJson = testMapper.writeValueAsString(json);
    final BillingEventSetJson res = testMapper.readValue(asJson, BillingEventSetJson.class);
    assertFalse(res.isAutoInvoiceOff());
    assertFalse(res.isAutoInvoiceDraft());
    assertFalse(res.isAutoInvoiceReuseDraft());
    assertEquals(res.getSubscriptionEvents().size(), 1);
    final SubscriptionBillingEventJson res1 = res.getSubscriptionEvents().get(0);
    assertEquals(res1.getSubscriptionId(), subscriptionId);
    assertEquals(res1.getEvents().size(), 2);
    final BillingEventJson billingEvent1 = res1.getEvents().get(0);
    assertEquals(billingEvent1.getBcdLocal(), 1);
    assertEquals(billingEvent1.getPlanName(), "Test");
    assertEquals(billingEvent1.getPhaseName(), "Test-evergreen");
    assertEquals(billingEvent1.getEffDate().compareTo(effectiveDate1), 0);
    assertNull(billingEvent1.getFixedPrice());
    assertEquals(billingEvent1.getRecurringPrice().compareTo(new BigDecimal("13.0")), 0);
    assertEquals(billingEvent1.getTransitionType(), SubscriptionBaseTransitionType.CREATE);
    // Our Mock implementation returns null
    assertNull(billingEvent1.getCatalogEffDt());
}
Also used : MockBillingEventSet(org.killbill.billing.invoice.MockBillingEventSet) SubscriptionBillingEventJson(org.killbill.billing.invoice.dao.serialization.BillingEventSetJson.SubscriptionBillingEventJson) BillingEventJson(org.killbill.billing.invoice.dao.serialization.BillingEventSetJson.BillingEventJson) SubscriptionBillingEventJson(org.killbill.billing.invoice.dao.serialization.BillingEventSetJson.SubscriptionBillingEventJson) MockPlan(org.killbill.billing.catalog.MockPlan) Plan(org.killbill.billing.catalog.api.Plan) LocalDate(org.joda.time.LocalDate) MockInternationalPrice(org.killbill.billing.catalog.MockInternationalPrice) DateTime(org.joda.time.DateTime) BigDecimal(java.math.BigDecimal) SubscriptionBase(org.killbill.billing.subscription.api.SubscriptionBase) MockPlan(org.killbill.billing.catalog.MockPlan) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) Currency(org.killbill.billing.catalog.api.Currency) PlanPhase(org.killbill.billing.catalog.api.PlanPhase) MockPlanPhase(org.killbill.billing.catalog.MockPlanPhase) BillingEvent(org.killbill.billing.junction.BillingEvent) UUID(java.util.UUID) DefaultPrice(org.killbill.billing.catalog.DefaultPrice) Test(org.testng.annotations.Test)

Aggregations

DefaultPrice (org.killbill.billing.catalog.DefaultPrice)38 MockInternationalPrice (org.killbill.billing.catalog.MockInternationalPrice)34 MockPlanPhase (org.killbill.billing.catalog.MockPlanPhase)34 MockPlan (org.killbill.billing.catalog.MockPlan)33 Test (org.testng.annotations.Test)32 LocalDate (org.joda.time.LocalDate)30 BillingEvent (org.killbill.billing.junction.BillingEvent)30 Plan (org.killbill.billing.catalog.api.Plan)28 PlanPhase (org.killbill.billing.catalog.api.PlanPhase)28 BigDecimal (java.math.BigDecimal)27 MockBillingEventSet (org.killbill.billing.invoice.MockBillingEventSet)26 BillingEventSet (org.killbill.billing.junction.BillingEventSet)25 Invoice (org.killbill.billing.invoice.api.Invoice)23 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)23 RecurringInvoiceItem (org.killbill.billing.invoice.model.RecurringInvoiceItem)22 AccountInvoices (org.killbill.billing.invoice.optimizer.InvoiceOptimizerBase.AccountInvoices)22 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)19 RepairAdjInvoiceItem (org.killbill.billing.invoice.model.RepairAdjInvoiceItem)19 DefaultBillingEvent (org.killbill.billing.junction.plumbing.billing.DefaultBillingEvent)19 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)18