use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.
the class TestBlockingCalculator method testCreateNewEventsOpenPrev.
// Open ended duration with a previous event
// --X--[----------------------------------
@Test(groups = "fast")
public void testCreateNewEventsOpenPrev() throws CatalogApiException {
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));
billingEvents.add(createRealEvent(now.minusDays(1), subscription1));
final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, subscription1, internalCallContext);
assertEquals(results.size(), 1);
assertEquals(results.first().getEffectiveDate(), now);
assertNull(results.first().getFixedPrice());
assertNull(results.first().getRecurringPrice(null));
assertEquals(results.first().getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD);
assertEquals(results.first().getTransitionType(), SubscriptionBaseTransitionType.START_BILLING_DISABLED);
}
use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.
the class TestBlockingCalculator method createBillingEvent.
private BillingEvent createBillingEvent(final SubscriptionBase subscription) {
final BillingEvent result = Mockito.mock(BillingEvent.class);
Mockito.when(result.getSubscription()).thenReturn(subscription);
Mockito.when(result.compareTo(Mockito.<BillingEvent>any())).thenReturn(1);
return result;
}
use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.
the class TestBlockingCalculator method testCreateNewEventsClosedBetwn.
// Closed with no previous event but in-between events
// -----[------Y-----]---------------------
@Test(groups = "fast")
public void testCreateNewEventsClosedBetwn() throws CatalogApiException {
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)));
billingEvents.add(createRealEvent(now.plusDays(1), subscription1));
final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, subscription1, internalCallContext);
assertEquals(results.size(), 1);
assertEquals(results.last().getEffectiveDate(), now.plusDays(2));
assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null));
assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED);
}
use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.
the class TestBlockingCalculator method testEventsToRemoveOpenPrevFollow.
// Open with previous and following events
// --X--[----Y-----------------------------
@Test(groups = "fast")
public void testEventsToRemoveOpenPrevFollow() {
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.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);
}
use of org.killbill.billing.junction.BillingEvent in project killbill by killbill.
the class TestBlockingCalculator method testEventsToRemoveClosedPrev.
// Closed duration with a single previous event
// --X--[------------]---------------------
@Test(groups = "fast")
public void testEventsToRemoveClosedPrev() {
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);
billingEvents.add(e1);
final SortedSet<BillingEvent> results = blockingCalculator.eventsToRemove(disabledDuration, billingEvents, subscription1);
assertEquals(results.size(), 0);
}
Aggregations