@Test(groups = "fast") public void testZeroDollarEvents() throws InvoiceApiException, CatalogApiException { final Plan plan = new MockPlan(); final PlanPhase planPhase = createMockMonthlyPlanPhase(ZERO); final BillingEventSet events = new MockBillingEventSet(); final LocalDate targetDate = invoiceUtil.buildDate(2011, 1, 1); events.add(createBillingEvent(UUID.randomUUID(), UUID.randomUUID(), targetDate, plan, planPhase, 1)); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getInvoiceItems().size(), 1); assertEquals(invoice.getInvoiceItems().get(0).getAmount().compareTo(BigDecimal.ZERO), 0); }
@Test(groups = "fast") public void testProcessFixedBillingEventsWithCancellationOnSameDay() 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-08"), 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); assertTrue(proposedItems.isEmpty()); }
@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); }
public UUID generateRegularInvoice(final Account account, final BigDecimal fixedPrice, final BigDecimal recurringPrice, final LocalDate targetDate, final CallContext callContext) throws Exception { final SubscriptionBase subscription = Mockito.mock(SubscriptionBase.class); Mockito.when(subscription.getId()).thenReturn(UUID.randomUUID()); Mockito.when(subscription.getBundleId()).thenReturn(new UUID(0L, 0L)); final BillingEventSet events = new MockBillingEventSet(); final Plan plan = MockPlan.createBicycleNoTrialEvergreen1USD(); final PlanPhase planPhase = MockPlanPhase.create1USDMonthlyEvergreen(); final DateTime effectiveDate = new DateTime().minusDays(1); final Currency currency = Currency.USD; events.add(createMockBillingEvent(account, subscription, effectiveDate, plan, planPhase, fixedPrice, recurringPrice, currency, BillingPeriod.MONTHLY, 1, BillingMode.IN_ADVANCE, "", 1L, SubscriptionBaseTransitionType.CREATE)); Mockito.when(billingApi.getBillingEventsForAccountAndUpdateAccountBCD(Mockito.<UUID>any(), Mockito.<DryRunArguments>any(), Mockito.<InternalCallContext>any())).thenReturn(events); final InternalCallContext context = internalCallContextFactory.createInternalCallContext(account.getId(), callContext); Invoice invoice = generateInvoice(account.getId(), targetDate, new DryRunFutureDateArguments(), context); Assert.assertNotNull(invoice); List<InvoiceModelDao> invoices = invoiceDao.getInvoicesByAccount(false, context); Assert.assertEquals(invoices.size(), 0); invoice = generateInvoice(account.getId(), targetDate, null, context); Assert.assertNotNull(invoice); invoices = invoiceDao.getInvoicesByAccount(false, context); Assert.assertEquals(invoices.size(), 1); return invoice.getId(); }
@Test(groups = "fast", expectedExceptions = {InvoiceApiException.class}) public void testTargetDateRestrictionFailure() throws InvoiceApiException, CatalogApiException { final LocalDate targetDate = clock.getUTCToday().plusMonths(60); final BillingEventSet events = new MockBillingEventSet(); final Plan plan1 = new MockPlan(); final PlanPhase phase1 = createMockMonthlyPlanPhase(null, ZERO, PhaseType.TRIAL); events.add(createBillingEvent(UUID.randomUUID(), UUID.randomUUID(), clock.getUTCToday(), plan1, phase1, 1)); generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); }
final Currency currency = Currency.USD; final BigDecimal fixedPrice = null; events.add(invoiceUtil.createMockBillingEvent(account, subscription, effectiveDate, plan, planPhase, fixedPrice, BigDecimal.ONE, currency, BillingPeriod.MONTHLY, 1, BillingMode.IN_ADVANCE, "", 1L, SubscriptionBaseTransitionType.CREATE));
@Test(groups = "fast") public void testEndDateIsCorrect() throws InvoiceApiException, CatalogApiException { final Plan plan = new MockPlan(); final PlanPhase planPhase = createMockMonthlyPlanPhase(ONE); final BillingEventSet events = new MockBillingEventSet(); final LocalDate startDate = clock.getUTCToday().minusDays(1); final LocalDate targetDate = startDate.plusDays(1); events.add(createBillingEvent(UUID.randomUUID(), UUID.randomUUID(), startDate, plan, planPhase, startDate.getDayOfMonth())); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); final RecurringInvoiceItem item = (RecurringInvoiceItem) invoice.getInvoiceItems().get(0); // end date of the invoice item should be equal to exactly one month later (rounded) assertEquals(item.getEndDate(), startDate.plusMonths(1)); }
@Test(groups = "fast") public void testWithSingleThirtyDaysEvent() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final SubscriptionBase sub = createSubscription(); final LocalDate startDate = invoiceUtil.buildDate(2011, 9, 1); final Plan plan = new MockPlan(); final BigDecimal rate1 = TEN; final PlanPhase phase = createMockThirtyDaysPlanPhase(rate1); final BillingEvent event = createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan, phase, 1); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 10, 3); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 2); assertEquals(invoice.getBalance(), KillBillMoney.of(TWENTY, invoice.getCurrency())); assertEquals(invoice.getInvoiceItems().get(0).getSubscriptionId(), sub.getId()); assertEquals(invoice.getInvoiceItems().get(0).getInvoiceItemType(), InvoiceItemType.RECURRING); assertEquals(invoice.getInvoiceItems().get(0).getStartDate(), new LocalDate(2011, 9, 1)); assertEquals(invoice.getInvoiceItems().get(0).getEndDate(), new LocalDate(2011, 10, 1)); assertEquals(invoice.getInvoiceItems().get(1).getInvoiceItemType(), InvoiceItemType.RECURRING); assertEquals(invoice.getInvoiceItems().get(1).getStartDate(), new LocalDate(2011, 10, 1)); assertEquals(invoice.getInvoiceItems().get(1).getEndDate(), new LocalDate(2011, 10, 31)); }
@Test(groups = "fast") public void testWithSingleMonthlyEvent() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final SubscriptionBase sub = createSubscription(); final LocalDate startDate = invoiceUtil.buildDate(2011, 9, 1); final Plan plan = new MockPlan(); final BigDecimal rate1 = TEN; final PlanPhase phase = createMockMonthlyPlanPhase(rate1); final BillingEvent event = createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan, phase, 1); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 10, 3); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 2); assertEquals(invoice.getBalance(), KillBillMoney.of(TWENTY, invoice.getCurrency())); assertEquals(invoice.getInvoiceItems().get(0).getSubscriptionId(), sub.getId()); assertEquals(invoice.getInvoiceItems().get(0).getInvoiceItemType(), InvoiceItemType.RECURRING); assertEquals(invoice.getInvoiceItems().get(0).getStartDate(), new LocalDate(2011, 9, 1)); assertEquals(invoice.getInvoiceItems().get(0).getEndDate(), new LocalDate(2011, 10, 1)); assertEquals(invoice.getInvoiceItems().get(1).getInvoiceItemType(), InvoiceItemType.RECURRING); assertEquals(invoice.getInvoiceItems().get(1).getStartDate(), new LocalDate(2011, 10, 1)); assertEquals(invoice.getInvoiceItems().get(1).getEndDate(), new LocalDate(2011, 11, 1)); }
@Test(groups = "fast") public void testSimpleWithSingleDiscountEvent() throws Exception { final UUID accountId = UUID.randomUUID(); final SubscriptionBase sub = createSubscription(); final Plan plan = new MockPlan("Plan with a single discount phase"); final PlanPhase phaseEvergreen = createMockMonthlyPlanPhase(EIGHT, PhaseType.DISCOUNT); final int bcdLocal = 16; final LocalDate startDate = invoiceUtil.buildDate(2012, 7, 16); final BillingEventSet events = new MockBillingEventSet(); events.add(createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan, phaseEvergreen, bcdLocal)); // Set a target date of today (start date) final LocalDate targetDate = startDate; final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 1); assertEquals(invoice.getInvoiceItems().get(0).getStartDate(), invoiceUtil.buildDate(2012, 7, 16)); assertEquals(invoice.getInvoiceItems().get(0).getEndDate(), invoiceUtil.buildDate(2012, 8, 16)); }
@Test(groups = "fast") public void testMixedModeLifeCycle() throws InvoiceApiException, CatalogApiException { // create a SubscriptionBase with a fixed price and recurring price final Plan plan1 = new MockPlan(); final BigDecimal monthlyRate = FIVE; final BigDecimal fixedCost = TEN; final PlanPhase phase1 = createMockMonthlyPlanPhase(monthlyRate, fixedCost, PhaseType.TRIAL); final BillingEventSet events = new MockBillingEventSet(); final UUID subscriptionId = UUID.randomUUID(); final UUID bundleId = UUID.randomUUID(); final LocalDate startDate = new LocalDate(2011, 1, 1); final BillingEvent event1 = createBillingEvent(subscriptionId, bundleId, startDate, plan1, phase1, 1); events.add(event1); // ensure both components are invoiced final InvoiceWithMetadata invoiceWithMetadata1 = generator.generateInvoice(account, events, null, null, startDate, Currency.USD, internalCallContext); final Invoice invoice1 = invoiceWithMetadata1.getInvoice(); assertNotNull(invoice1); assertEquals(invoice1.getNumberOfItems(), 2); assertEquals(invoice1.getBalance(), KillBillMoney.of(FIFTEEN, invoice1.getCurrency())); final List<Invoice> invoiceList = new ArrayList<Invoice>(); invoiceList.add(invoice1); // move forward in time one billing period final LocalDate currentDate = startDate.plusMonths(1); // ensure that only the recurring price is invoiced final InvoiceWithMetadata invoiceWithMetadata2 = generator.generateInvoice(account, events, invoiceList, null, currentDate, Currency.USD, internalCallContext); final Invoice invoice2 = invoiceWithMetadata2.getInvoice(); assertNotNull(invoice2); assertEquals(invoice2.getNumberOfItems(), 1); assertEquals(invoice2.getBalance(), KillBillMoney.of(FIVE, invoice2.getCurrency())); }
@Test(groups = "fast") public void testWithSingleMonthlyEventWithLeadingProRation() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final SubscriptionBase sub = createSubscription(); final LocalDate startDate = invoiceUtil.buildDate(2011, 9, 1); final Plan plan = new MockPlan(); final BigDecimal rate = TEN; final PlanPhase phase = createMockMonthlyPlanPhase(rate); final BillingEvent event = createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan, phase, 15); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 10, 3); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 2); final BigDecimal expectedNumberOfBillingCycles; expectedNumberOfBillingCycles = ONE.add(FOURTEEN.divide(THIRTY_ONE, KillBillMoney.ROUNDING_METHOD)); final BigDecimal expectedAmount = KillBillMoney.of(expectedNumberOfBillingCycles.multiply(rate), invoice.getCurrency()); assertEquals(invoice.getBalance(), expectedAmount); }
@Test(groups = "fast") public void testOnePlan_TwoMonthlyPhases_ChangeImmediate() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final Plan plan1 = new MockPlan(); final BigDecimal rate1 = FIVE; final PlanPhase phase1 = createMockMonthlyPlanPhase(rate1); final SubscriptionBase sub = createSubscription(); final BillingEvent event1 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 9, 1), plan1, phase1, 1); events.add(event1); final BigDecimal rate2 = TEN; final PlanPhase phase2 = createMockMonthlyPlanPhase(rate2); final BillingEvent event2 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 10, 15), plan1, phase2, 15); events.add(event2); final LocalDate targetDate = invoiceUtil.buildDate(2011, 12, 3); final UUID accountId = UUID.randomUUID(); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 4); final BigDecimal numberOfCyclesEvent1; numberOfCyclesEvent1 = ONE.add(FOURTEEN.divide(THIRTY_ONE, KillBillMoney.ROUNDING_METHOD)); final BigDecimal numberOfCyclesEvent2 = TWO; BigDecimal expectedValue; expectedValue = numberOfCyclesEvent1.multiply(rate1); expectedValue = expectedValue.add(numberOfCyclesEvent2.multiply(rate2)); expectedValue = KillBillMoney.of(expectedValue, invoice.getCurrency()); assertEquals(invoice.getBalance(), expectedValue); }
"testEvent1", 1L, SubscriptionBaseTransitionType.CREATE); final BillingEventSet events = new MockBillingEventSet(); events.add(event1); recurringPrice.getPrice(currency), currency, BillingPeriod.MONTHLY, 31, BillingMode.IN_ADVANCE, "testEvent2", 2L, SubscriptionBaseTransitionType.CHANGE); events.add(event2);
@Test(groups = "fast") public void testSimpleWithTimeZone() throws InvoiceApiException, CatalogApiException { final SubscriptionBase sub = createSubscription(); final Plan plan = new MockPlan(); final BigDecimal rate = TEN; final PlanPhase phase = createMockMonthlyPlanPhase(rate); // Start date was the 16 local, but was the 17 UTC final int bcdLocal = 16; final LocalDate startDate = invoiceUtil.buildDate(2012, 7, bcdLocal); final BillingEventSet events = new MockBillingEventSet(); final BillingEvent event = createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan, phase, bcdLocal); events.add(event); // Target date is the next BCD, in local time final LocalDate targetDate = invoiceUtil.buildDate(2012, 8, bcdLocal); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 2); assertEquals(invoice.getInvoiceItems().get(0).getStartDate(), invoiceUtil.buildDate(2012, 7, 16)); assertEquals(invoice.getInvoiceItems().get(0).getEndDate(), invoiceUtil.buildDate(2012, 8, 16)); assertEquals(invoice.getInvoiceItems().get(1).getStartDate(), invoiceUtil.buildDate(2012, 8, 16)); assertEquals(invoice.getInvoiceItems().get(1).getEndDate(), invoiceUtil.buildDate(2012, 9, 16)); }
@Test(groups = "fast") public void testOnePlan_ThreeMonthlyPhases_ChangeEOT() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final Plan plan1 = new MockPlan(); final BigDecimal rate1 = FIVE; final PlanPhase phase1 = createMockMonthlyPlanPhase(rate1); final SubscriptionBase sub = createSubscription(); final BillingEvent event1 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 9, 1), plan1, phase1, 1); events.add(event1); final BigDecimal rate2 = TEN; final PlanPhase phase2 = createMockMonthlyPlanPhase(rate2); final BillingEvent event2 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 10, 1), plan1, phase2, 1); events.add(event2); final BigDecimal rate3 = THIRTY; final PlanPhase phase3 = createMockMonthlyPlanPhase(rate3); final BillingEvent event3 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 11, 1), plan1, phase3, 1); events.add(event3); final LocalDate targetDate = invoiceUtil.buildDate(2011, 12, 3); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 4); assertEquals(invoice.getBalance(), KillBillMoney.of(rate1.add(rate2).add(TWO.multiply(rate3)), invoice.getCurrency())); }
@Test(groups = "fast") public void testTwoMonthlySubscriptionsWithAlignedBillingDates() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final Plan plan1 = new MockPlan(); final BigDecimal rate1 = FIVE; final PlanPhase phase1 = createMockMonthlyPlanPhase(rate1); final Plan plan2 = new MockPlan(); final BigDecimal rate2 = TEN; final PlanPhase phase2 = createMockMonthlyPlanPhase(rate2); final SubscriptionBase sub = createSubscription(); final BillingEvent event1 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 9, 1), plan1, phase1, 1); events.add(event1); final BillingEvent event2 = createBillingEvent(sub.getId(), sub.getBundleId(), invoiceUtil.buildDate(2011, 10, 1), plan2, phase2, 1); events.add(event2); final LocalDate targetDate = invoiceUtil.buildDate(2011, 10, 3); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); assertEquals(invoice.getNumberOfItems(), 2); assertEquals(invoice.getBalance(), KillBillMoney.of(rate1.add(rate2), invoice.getCurrency())); }
@Test(groups = "fast") public void testSingleEventWithExistingInvoice() throws InvoiceApiException, CatalogApiException { final BillingEventSet events = new MockBillingEventSet(); final SubscriptionBase sub = createSubscription(); final LocalDate startDate = invoiceUtil.buildDate(2011, 9, 1); final Plan plan1 = new MockPlan(); final BigDecimal rate = FIVE; final PlanPhase phase1 = createMockMonthlyPlanPhase(rate); final BillingEvent event1 = createBillingEvent(sub.getId(), sub.getBundleId(), startDate, plan1, phase1, 1); events.add(event1); LocalDate targetDate = invoiceUtil.buildDate(2011, 12, 1); final InvoiceWithMetadata invoiceWithMetadata1 = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, internalCallContext); final List<Invoice> existingInvoices = new ArrayList<Invoice>(); final Invoice invoice1 = invoiceWithMetadata1.getInvoice(); existingInvoices.add(invoice1); targetDate = invoiceUtil.buildDate(2011, 12, 3); final InvoiceWithMetadata invoiceWithMetadata2 = generator.generateInvoice(account, events, existingInvoices, null, targetDate, Currency.USD, internalCallContext); final Invoice invoice2 = invoiceWithMetadata2.getInvoice(); assertNull(invoice2); }
@Test(groups = "slow") public void testInvoiceForFreeTrial() throws InvoiceApiException, CatalogApiException { final Currency currency = Currency.USD; final DefaultPrice price = new DefaultPrice(BigDecimal.ZERO, Currency.USD); final MockInternationalPrice fixedPrice = new MockInternationalPrice(price); final MockPlanPhase phase = new MockPlanPhase(null, fixedPrice); final MockPlan plan = new MockPlan(phase); final SubscriptionBase subscription = getZombieSubscription(); final DateTime effectiveDate = invoiceUtil.buildDate(2011, 1, 1).toDateTimeAtStartOfDay(); final BillingEvent event = invoiceUtil.createMockBillingEvent(null, subscription, effectiveDate, plan, phase, fixedPrice.getPrice(currency), null, currency, BillingPeriod.MONTHLY, 15, BillingMode.IN_ADVANCE, "testEvent", 1L, SubscriptionBaseTransitionType.CREATE); final BillingEventSet events = new MockBillingEventSet(); events.add(event); final LocalDate targetDate = invoiceUtil.buildDate(2011, 1, 15); final InvoiceWithMetadata invoiceWithMetadata = generator.generateInvoice(account, events, null, null, targetDate, Currency.USD, context); final Invoice invoice = invoiceWithMetadata.getInvoice(); assertNotNull(invoice); }