@Override public boolean apply(final SubscriptionEvent event) { return event.getSubscriptionEventType() != null && // We want events coming from the blocking states table... ObjectType.BLOCKING_STATES.equals(event.getSubscriptionEventType().getObjectType()) && // ...that are for any service but entitlement !ENTITLEMENT_SERVICE_NAME.equals(event.getServiceName()); } }
private void checkSubscriptionEventAuditLog(final List<SubscriptionEvent> transitions, final int idx, final SubscriptionEventType expectedType) { assertEquals(transitions.get(idx).getSubscriptionEventType(), expectedType); final List<AuditLog> auditLogs = auditUserApi.getAuditLogs(transitions.get(idx).getId(), transitions.get(idx).getSubscriptionEventType().getObjectType(), AuditLevel.FULL, callContext); assertEquals(auditLogs.size(), 1); assertEquals(auditLogs.get(0).getChangeType(), ChangeType.INSERT); } }
private static List<AuditLog> getAuditLogsForSubscriptionEvent(final SubscriptionEvent subscriptionEvent, @Nullable final AccountAuditLogs accountAuditLogs) { if (accountAuditLogs == null) { return null; } final ObjectType subscriptionEventObjectType = subscriptionEvent.getSubscriptionEventType().getObjectType(); if (subscriptionEventObjectType == ObjectType.SUBSCRIPTION_EVENT) { return accountAuditLogs.getAuditLogsForSubscriptionEvent(subscriptionEvent.getId()); } else if (subscriptionEventObjectType == ObjectType.BLOCKING_STATES) { return accountAuditLogs.getAuditLogsForBlockingState(subscriptionEvent.getId()); } throw new IllegalStateException("Unepxected objectType " + subscriptionEventObjectType + " for SubscriptionEvent " + subscriptionEvent.getId()); }
@Test(groups = "fast", invocationCount = 10) public void testPausePostPhase_0_17_X() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, true, now.plusDays(40))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testPausePostPhase() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, true, now.plusDays(40))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testPauseAccountAtPhase() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(UUID.randomUUID(), BlockingStateType.ACCOUNT, "stuff", "svc1", true, true, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testPauseAtPhase() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, true, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testPauseAtStart() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, true, now)); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PHASE); }
@Test(groups = "fast", invocationCount = 10) public void testPauseResumeAtPhase() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, true, now.plusDays(30))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", false, false, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 7); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); Assert.assertEquals(allEvents.get(5).getSubscriptionEventType(), SubscriptionEventType.RESUME_ENTITLEMENT); Assert.assertEquals(allEvents.get(6).getSubscriptionEventType(), SubscriptionEventType.RESUME_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testDifferentTypesOfBlockingSameService() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(UUID.randomUUID(), BlockingStateType.ACCOUNT, "stuff", "svc1", false, true, now.plusDays(10))); // Same service blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", true, false, now.plusDays(15))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc1", false, false, now.plusDays(20))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.ACCOUNT, "stuff", "svc1", false, false, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 8); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.RESUME_BILLING); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(5).getSubscriptionEventType(), SubscriptionEventType.RESUME_ENTITLEMENT); Assert.assertEquals(allEvents.get(6).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(7).getSubscriptionEventType(), SubscriptionEventType.SERVICE_STATE_CHANGE); }
@Test(groups = "fast", invocationCount = 10) public void test_ENT_STATE_IsNotInterpreted() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, "svc1", false, false, now.plusDays(1))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_CANCELLED, "svc1", false, false, now.plusDays(2))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 5); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.SERVICE_STATE_CHANGE); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.SERVICE_STATE_CHANGE); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PHASE); }
@Test(groups = "fast", invocationCount = 10) public void testIgnore_ENTITLEMENT_SERVICE_NAME_WithNoFlag() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now.plusDays(1))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 3); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); }
private void testPauseAccountAtPhaseAndPauseOtherSubscriptionFutureStarted(final UUID subscriptionId1, final UUID subscriptionId2) throws Exception { final DateTime now = clock.getUTCNow(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(subscriptionId2, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(UUID.randomUUID(), BlockingStateType.ACCOUNT, "stuff", "svc1", true, true, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); allEvents.add(createEvent(subscriptionId2, SubscriptionEventType.START_BILLING, now.plusDays(40))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 8); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PHASE); if (subscriptionId1.compareTo(subscriptionId2) >= 0) { Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(5).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(6).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); } else { Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(5).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); Assert.assertEquals(allEvents.get(6).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); } Assert.assertEquals(allEvents.get(7).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); }
@Test(groups = "fast", invocationCount = 10) public void testDifferentTypesOfBlockingDifferentServices() throws Exception { final DateTime now = clock.getUTCNow(); final UUID subscriptionId1 = UUID.randomUUID(); final Collection<BlockingState> blockingStates = new LinkedList<BlockingState>(); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, DefaultEntitlementApi.ENT_STATE_START, KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName(), false, false, now)); blockingStates.add(createBlockingState(UUID.randomUUID(), BlockingStateType.ACCOUNT, "stuff", "svc1", false, true, now.plusDays(10))); // Different service blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc2", true, false, now.plusDays(15))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.SUBSCRIPTION, "stuff", "svc2", false, false, now.plusDays(20))); blockingStates.add(createBlockingState(subscriptionId1, BlockingStateType.ACCOUNT, "stuff", "svc1", false, false, now.plusDays(30))); final LinkedList<SubscriptionEvent> allEvents = new LinkedList<SubscriptionEvent>(); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.START_BILLING, now)); allEvents.add(createEvent(subscriptionId1, SubscriptionEventType.PHASE, now.plusDays(30))); computeEvents(allEvents, blockingStates); Assert.assertEquals(allEvents.size(), 7); Assert.assertEquals(allEvents.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(allEvents.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(allEvents.get(2).getSubscriptionEventType(), SubscriptionEventType.PAUSE_BILLING); Assert.assertEquals(allEvents.get(3).getSubscriptionEventType(), SubscriptionEventType.PAUSE_ENTITLEMENT); Assert.assertEquals(allEvents.get(4).getSubscriptionEventType(), SubscriptionEventType.RESUME_ENTITLEMENT); Assert.assertEquals(allEvents.get(5).getSubscriptionEventType(), SubscriptionEventType.PHASE); Assert.assertEquals(allEvents.get(6).getSubscriptionEventType(), SubscriptionEventType.RESUME_BILLING); }
private void subscriptionBundleChecker(final List<SubscriptionBundle> bundles, final LocalDate billingStartDate, final Entitlement entitlement, final int idx) { Assert.assertEquals(bundles.get(idx).getId(), entitlement.getBundleId()); Assert.assertEquals(bundles.get(idx).getSubscriptions().size(), 1); Assert.assertEquals(bundles.get(idx).getSubscriptions().get(0).getId(), entitlement.getId()); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().size(), 3); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(0).getEffectiveDate(), entitlement.getEffectiveStartDate()); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(1).getEffectiveDate(), billingStartDate); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getEffectiveDate(), new LocalDate(2013, 9, 6)); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); }
private void subscriptionBundleChecker(final List<SubscriptionBundle> bundles, final LocalDate initialDate, final Entitlement entitlement, final int idx) { Assert.assertEquals(bundles.get(idx).getId(), entitlement.getBundleId()); Assert.assertEquals(bundles.get(idx).getSubscriptions().size(), 1); Assert.assertEquals(bundles.get(idx).getSubscriptions().get(0).getId(), entitlement.getId()); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().size(), 4); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(0).getEffectiveDate(), initialDate); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(1).getEffectiveDate(), initialDate); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getEffectiveDate(), initialDate); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getSubscriptionEventType(), SubscriptionEventType.SERVICE_STATE_CHANGE); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getServiceName(), "service"); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(2).getServiceStateName(), "stateName"); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(3).getEffectiveDate(), new LocalDate(2013, 9, 6)); Assert.assertEquals(bundles.get(idx).getTimeline().getSubscriptionEvents().get(3).getSubscriptionEventType(), SubscriptionEventType.PHASE); }
@Test(groups = "slow") public void testSubscriptionCreationWithFutureDate() throws AccountApiException, SubscriptionApiException, EntitlementApiException { final String externalKey = "vritti"; final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); //2013-08-07 final LocalDate effectiveDate = initialDate.plusMonths(1); // Create entitlement and check each field final UUID entitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), externalKey, effectiveDate, effectiveDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement entitlement = entitlementApi.getEntitlementForId(entitlementId, callContext); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(entitlement.getId(), callContext); final List<SubscriptionEvent> events = subscription.getSubscriptionEvents(); assertEquals(events.size(), 3); assertEquals(events.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); assertEquals(events.get(0).getEffectiveDate().compareTo(effectiveDate), 0); assertEquals(events.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); assertEquals(events.get(1).getEffectiveDate().compareTo(effectiveDate), 0); assertEquals(events.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); assertEquals(events.get(2).getEffectiveDate().compareTo(effectiveDate.plusMonths(1)), 0); assertListenerStatus(); }
assertEquals(events.size(), 4); assertEquals(events.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); assertEquals(events.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); assertEquals(events.get(2).getSubscriptionEventType(), SubscriptionEventType.STOP_ENTITLEMENT); assertEquals(events.get(3).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING);
assertEquals(events.get(3).getEffectiveDate().compareTo(new LocalDate(tr3.getEffectiveTransitionTime(), accountTimeZone)), 0); assertEquals(events.get(0).getSubscriptionEventType(), SubscriptionEventType.START_ENTITLEMENT); assertEquals(events.get(1).getSubscriptionEventType(), SubscriptionEventType.START_BILLING); assertEquals(events.get(2).getSubscriptionEventType(), SubscriptionEventType.PHASE); assertEquals(events.get(3).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING);
public EventSubscriptionJson(final SubscriptionEvent subscriptionEvent, @Nullable final AccountAuditLogs accountAuditLogs) { super(toAuditLogJson(getAuditLogsForSubscriptionEvent(subscriptionEvent, accountAuditLogs))); final BillingPeriod billingPeriod = subscriptionEvent.getNextBillingPeriod() != null ? subscriptionEvent.getNextBillingPeriod() : subscriptionEvent.getPrevBillingPeriod(); final Plan plan = subscriptionEvent.getNextPlan() != null ? subscriptionEvent.getNextPlan() : subscriptionEvent.getPrevPlan(); final Product product = subscriptionEvent.getNextProduct() != null ? subscriptionEvent.getNextProduct() : subscriptionEvent.getPrevProduct(); final PriceList priceList = subscriptionEvent.getNextPriceList() != null ? subscriptionEvent.getNextPriceList() : subscriptionEvent.getPrevPriceList(); final PlanPhase phase = subscriptionEvent.getNextPhase() != null ? subscriptionEvent.getNextPhase() : subscriptionEvent.getPrevPhase(); this.eventId = subscriptionEvent.getId(); this.billingPeriod = billingPeriod; this.effectiveDate = subscriptionEvent.getEffectiveDate(); this.plan = plan != null ? plan.getName() : null; this.product = product != null ? product.getName() : null; this.priceList = priceList != null ? priceList.getName() : null; this.eventType = subscriptionEvent.getSubscriptionEventType(); this.isBlockedBilling = subscriptionEvent.isBlockedBilling(); this.isBlockedEntitlement = subscriptionEvent.isBlockedEntitlement(); this.serviceName = subscriptionEvent.getServiceName(); this.serviceStateName = subscriptionEvent.getServiceStateName(); this.phase = phase != null ? phase.getName() : null; }