For IntelliJ IDEA and
Android Studio


@Test(groups = "fast") public void testCreateNewEventsOpenPrev() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<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, catalogInternalApi.getFullCatalog(true, true, internalCallContext), 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); }
@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)); }
@Test(groups = "fast") public void testCreateNewEventsOpenPrevFollow() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, null)); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), 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); }
@Test(groups = "fast") public void testCreateNewEventsClosedPrevBetwNext() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, now.plusDays(2))); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(3), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), internalCallContext); assertEquals(results.size(), 2); 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); assertEquals(results.last().getEffectiveDate(), now.plusDays(2)); assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null)); assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED); }
protected BillingEvent createNewReenableEvent(final DateTime odEventTime, final BillingEvent previousEvent, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException { // All fields are populated with the event state from before the blocking period, for invoice to resume invoicing final int billCycleDay = previousEvent.getBillCycleDayLocal(); final SubscriptionBase subscription = previousEvent.getSubscription(); final DateTime effectiveDate = odEventTime; final PlanPhase planPhase = previousEvent.getPlanPhase(); final BigDecimal fixedPrice = previousEvent.getFixedPrice(); final Plan plan = previousEvent.getPlan(); final Currency currency = previousEvent.getCurrency(); final String description = ""; final BillingPeriod billingPeriod = previousEvent.getBillingPeriod(); final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.END_BILLING_DISABLED; final Long totalOrdering = globaltotalOrder.getAndIncrement(); return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice, currency, billingPeriod, billCycleDay, description, totalOrdering, type, catalog, false); }
@Test(groups = "fast") public void testCreateNewEventsClosedPrev() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, now.plusDays(2))); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), internalCallContext); assertEquals(results.size(), 2); 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); assertEquals(results.last().getEffectiveDate(), now.plusDays(2)); assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null)); assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED); }
@Test(groups = "fast") public void testCreateNewDisableEvent() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final BillingEvent event = new MockBillingEvent(); final BillingEvent result = blockingCalculator.createNewDisableEvent(now, event, null); assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal()); assertEquals(result.getEffectiveDate(), now); assertEquals(result.getPlanPhase(), event.getPlanPhase()); assertEquals(result.getPlan(), event.getPlan()); assertNull(result.getFixedPrice()); assertNull(result.getRecurringPrice(null)); assertEquals(result.getCurrency(), event.getCurrency()); assertEquals(result.getDescription(), ""); assertEquals(result.getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD); assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.START_BILLING_DISABLED); // TODO - ugly, fragile assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1)); }
@Test(groups = "fast") public void testCreateNewEventsClosedPrevBetw() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, now.plusDays(2))); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), internalCallContext); assertEquals(results.size(), 2); 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); assertEquals(results.last().getEffectiveDate(), now.plusDays(2)); assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null)); assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED); }
@Test(groups = "fast") public void testCreateNewEventsOpenPrev() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<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, catalogInternalApi.getFullCatalog(true, true, internalCallContext), 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); }
@Test(groups = "fast") public void testCreateNewEventsOpenPrevFollow() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, null)); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), 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); }
@Test(groups = "fast") public void testCreateNewDisableEvent() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final BillingEvent event = new MockBillingEvent(); final BillingEvent result = blockingCalculator.createNewDisableEvent(now, event, null); assertEquals(result.getBillCycleDayLocal(), event.getBillCycleDayLocal()); assertEquals(result.getEffectiveDate(), now); assertEquals(result.getPlanPhase(), event.getPlanPhase()); assertEquals(result.getPlan(), event.getPlan()); assertNull(result.getFixedPrice()); assertNull(result.getRecurringPrice(null)); assertEquals(result.getCurrency(), event.getCurrency()); assertEquals(result.getDescription(), ""); assertEquals(result.getBillingPeriod(), BillingPeriod.NO_BILLING_PERIOD); assertEquals(result.getTransitionType(), SubscriptionBaseTransitionType.START_BILLING_DISABLED); // TODO - ugly, fragile assertEquals(result.getTotalOrdering(), (Long) (BlockingCalculator.getGlobalTotalOrder().get() - 1)); }
@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)); }
protected BillingEvent createNewReenableEvent(final DateTime odEventTime, final BillingEvent previousEvent, final Catalog catalog, final InternalTenantContext context) throws CatalogApiException { // All fields are populated with the event state from before the blocking period, for invoice to resume invoicing final int billCycleDay = previousEvent.getBillCycleDayLocal(); final SubscriptionBase subscription = previousEvent.getSubscription(); final DateTime effectiveDate = odEventTime; final PlanPhase planPhase = previousEvent.getPlanPhase(); final BigDecimal fixedPrice = previousEvent.getFixedPrice(); final Plan plan = previousEvent.getPlan(); final Currency currency = previousEvent.getCurrency(); final String description = ""; final BillingPeriod billingPeriod = previousEvent.getBillingPeriod(); final SubscriptionBaseTransitionType type = SubscriptionBaseTransitionType.END_BILLING_DISABLED; final Long totalOrdering = globaltotalOrder.getAndIncrement(); return new DefaultBillingEvent(subscription, effectiveDate, true, plan, planPhase, fixedPrice, currency, billingPeriod, billCycleDay, description, totalOrdering, type, catalog, false); }
@Test(groups = "fast") public void testCreateNewEventsClosedPrev() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, now.plusDays(2))); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), internalCallContext); assertEquals(results.size(), 2); 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); assertEquals(results.last().getEffectiveDate(), now.plusDays(2)); assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null)); assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED); }
@Test(groups = "fast") public void testCreateNewEventsClosedPrevBetw() throws CatalogApiException { final DateTime now = clock.getUTCNow(); final List<DisabledDuration> disabledDuration = new ArrayList<DisabledDuration>(); final SortedSet<BillingEvent> billingEvents = new TreeSet<BillingEvent>(); disabledDuration.add(new DisabledDuration(now, now.plusDays(2))); billingEvents.add(createRealEvent(now.minusDays(1), subscription1)); billingEvents.add(createRealEvent(now.plusDays(1), subscription1)); final SortedSet<BillingEvent> results = blockingCalculator.createNewEvents(disabledDuration, billingEvents, catalogInternalApi.getFullCatalog(true, true, internalCallContext), internalCallContext); assertEquals(results.size(), 2); 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); assertEquals(results.last().getEffectiveDate(), now.plusDays(2)); assertEquals(results.last().getRecurringPrice(null), billingEvents.first().getRecurringPrice(null)); assertEquals(results.last().getTransitionType(), SubscriptionBaseTransitionType.END_BILLING_DISABLED); }