Search in sources :

Example 71 with BillingEvent

use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.

the class TestBlockingCalculator method testCreateNewReenableEvent.

@Test(groups = "fast")
public void testCreateNewReenableEvent() throws CatalogApiException {
    final DateTime now = clock.getUTCNow();
    final BillingEvent event = new MockBillingEvent();
    final BillingEvent result = blockingCalculator.createNewReenableEvent(now, event, null, internalCallContext);
    assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal());
    assertEquals(result.getEffectiveDate(), now);
    assertEquals(result.getPlanPhase(), event.getPlanPhase());
    assertEquals(result.getPlan(), event.getPlan());
    assertEquals(result.getFixedPrice(), event.getFixedPrice());
    assertEquals(result.getRecurringPrice(null), event.getRecurringPrice(null));
    assertEquals(result.getCurrency(), event.getCurrency());
    assertEquals(result.getDescription(), "");
    assertEquals(result.getBillingPeriod(), event.getBillingPeriod());
    assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED);
    // TODO - ugly, fragile
    assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1));
}
Also used : BillingEvent(org.killbill.billing.junction.BillingEvent) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 72 with BillingEvent

use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.

the class TestBlockingCalculator method testEventsToRemoveClosedBetweenFollow.

// Closed with no previous event but in-between events and following
// -----[------Y-----]-------Z-------------
@Test(groups = "fast")
public void testEventsToRemoveClosedBetweenFollow() {
    final DateTime now = clock.getUTCNow();
    final List<DisabledDuration> disabledDuration = new ArrayList<BlockingCalculator.DisabledDuration>();
    final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>();
    disabledDuration.add(new DisabledDuration(now, now.plusDays(2)));
    final BillingEvent e2 = createRealEvent(now.plusDays(1), subscription1);
    final BillingEvent e3 = createRealEvent(now.plusDays(3), subscription1);
    billingEvents.add(e2);
    billingEvents.add(e3);
    final SortedSet<BillingEvent> results = blockingCalculator.eventsToRemove(disabledDuration, billingEvents, subscription1);
    assertEquals(results.size(), 1);
    assertEquals(results.first(), e2);
}
Also used : DisabledDuration(org.killbill.billing.junction.plumbing.billing.BlockingCalculator.DisabledDuration) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BillingEvent(org.killbill.billing.junction.BillingEvent) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 73 with BillingEvent

use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.

the class TestBlockingCalculator method testEventsToRemoveClosedBetwn.

// Closed with no previous event but in-between events
// -----[------Y-----]---------------------
@Test(groups = "fast")
public void testEventsToRemoveClosedBetwn() {
    final DateTime now = clock.getUTCNow();
    final List<DisabledDuration> disabledDuration = new ArrayList<BlockingCalculator.DisabledDuration>();
    final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>();
    disabledDuration.add(new DisabledDuration(now, now.plusDays(2)));
    final BillingEvent e2 = createRealEvent(now.plusDays(1), subscription1);
    billingEvents.add(e2);
    final SortedSet<BillingEvent> results = blockingCalculator.eventsToRemove(disabledDuration, billingEvents, subscription1);
    assertEquals(results.size(), 1);
    assertEquals(results.first(), e2);
}
Also used : DisabledDuration(org.killbill.billing.junction.plumbing.billing.BlockingCalculator.DisabledDuration) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BillingEvent(org.killbill.billing.junction.BillingEvent) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 74 with BillingEvent

use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.

the class TestBlockingCalculator method testEventsToRemoveOpenFollow.

// Open with no previous event (only following)
// -----[----X-----------------------------
@Test(groups = "fast")
public void testEventsToRemoveOpenFollow() {
    final DateTime now = clock.getUTCNow();
    final List<DisabledDuration> disabledDuration = new ArrayList<BlockingCalculator.DisabledDuration>();
    final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>();
    disabledDuration.add(new DisabledDuration(now, null));
    final BillingEvent e1 = createRealEvent(now.plusDays(1), subscription1);
    billingEvents.add(e1);
    final SortedSet<BillingEvent> results = blockingCalculator.eventsToRemove(disabledDuration, billingEvents, subscription1);
    assertEquals(results.size(), 1);
    assertEquals(results.first(), e1);
}
Also used : DisabledDuration(org.killbill.billing.junction.plumbing.billing.BlockingCalculator.DisabledDuration) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BillingEvent(org.killbill.billing.junction.BillingEvent) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 75 with BillingEvent

use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.

the class TestBlockingCalculator method testEventsToRemoveClosedPrevBetw.

// Closed duration with a previous event and in-between event
// --X--[------Y-----]---------------------
@Test(groups = "fast")
public void testEventsToRemoveClosedPrevBetw() {
    final DateTime now = clock.getUTCNow();
    final List<DisabledDuration> disabledDuration = new ArrayList<BlockingCalculator.DisabledDuration>();
    final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>();
    disabledDuration.add(new DisabledDuration(now, now.plusDays(2)));
    final BillingEvent e1 = createRealEvent(now.minusDays(1), subscription1);
    final BillingEvent e2 = createRealEvent(now.plusDays(1), subscription1);
    billingEvents.add(e1);
    billingEvents.add(e2);
    final SortedSet<BillingEvent> results = blockingCalculator.eventsToRemove(disabledDuration, billingEvents, subscription1);
    assertEquals(results.size(), 1);
    assertEquals(results.first(), e2);
}
Also used : DisabledDuration(org.killbill.billing.junction.plumbing.billing.BlockingCalculator.DisabledDuration) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) BillingEvent(org.killbill.billing.junction.BillingEvent) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

BillingEvent (org.killbill.billing.junction.BillingEvent)98 Test (org.testng.annotations.Test)82 DateTime (org.joda.time.DateTime)52 LocalDate (org.joda.time.LocalDate)49 Plan (org.killbill.billing.catalog.api.Plan)42 PlanPhase (org.killbill.billing.catalog.api.PlanPhase)41 MockPlan (org.killbill.billing.catalog.MockPlan)40 MockPlanPhase (org.killbill.billing.catalog.MockPlanPhase)40 BigDecimal (java.math.BigDecimal)36 ArrayList (java.util.ArrayList)36 UUID (java.util.UUID)35 MockBillingEventSet (org.killbill.billing.invoice.MockBillingEventSet)35 BillingEventSet (org.killbill.billing.junction.BillingEventSet)33 Invoice (org.killbill.billing.invoice.api.Invoice)32 DefaultInvoice (org.killbill.billing.invoice.model.DefaultInvoice)32 TreeSet (java.util.TreeSet)30 InvoiceItem (org.killbill.billing.invoice.api.InvoiceItem)27 FixedPriceInvoiceItem (org.killbill.billing.invoice.model.FixedPriceInvoiceItem)26 DefaultPrice (org.killbill.billing.catalog.DefaultPrice)25 MockInternationalPrice (org.killbill.billing.catalog.MockInternationalPrice)25