@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 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); }
assertEquals(events.get(3).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(3).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(3).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(5).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(4).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(5).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(4).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), service); assertEquals(events.get(4).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(8).getSubscriptionEventType(), SubscriptionEventType.RESUME_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(4).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(5).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(6).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(7).getServiceName(), service); assertEquals(events.get(8).getServiceName(), service);
assertEquals(events.get(5).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), service); assertEquals(events.get(4).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(5).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(8).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(3).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(4).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(5).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(6).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(7).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(8).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(3).getSubscriptionEventType(), SubscriptionEventType.STOP_ENTITLEMENT); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(3).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName());
assertEquals(events.get(9).getSubscriptionEventType(), SubscriptionEventType.STOP_BILLING); assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), EntitlementOrderingBase.ENT_BILLING_SERVICE_NAME); assertEquals(events.get(3).getServiceName(), overdueService); assertEquals(events.get(4).getServiceName(), overdueService); assertEquals(events.get(5).getServiceName(), overdueService); assertEquals(events.get(6).getServiceName(), overdueService); assertEquals(events.get(7).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(8).getServiceName(), overdueService); assertEquals(events.get(9).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME);
assertEquals(events.get(0).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(1).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(2).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(3).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(4).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(5).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(6).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(7).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(8).getServiceName(), KILLBILL_SERVICES.ENTITLEMENT_SERVICE.getServiceName()); assertEquals(events.get(9).getServiceName(), EntitlementOrderingBase.BILLING_SERVICE_NAME); assertEquals(events.get(10).getServiceName(), overdueService);
Assert.assertEquals(subscription.getSubscriptionEvents().get(0).getServiceName(), "entitlement-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(0).getServiceStateName(), "ENT_STARTED"); Assert.assertNull(subscription.getSubscriptionEvents().get(0).getPrevPhase()); Assert.assertEquals(subscription.getSubscriptionEvents().get(0).getNextPhase().getName(), "shotgun-annual-trial"); Assert.assertEquals(subscription.getSubscriptionEvents().get(1).getServiceName(), "billing-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(1).getServiceStateName(), "START_BILLING"); Assert.assertNull(subscription.getSubscriptionEvents().get(1).getPrevPhase()); Assert.assertEquals(subscription.getSubscriptionEvents().get(1).getNextPhase().getName(), "shotgun-annual-trial"); Assert.assertEquals(subscription.getSubscriptionEvents().get(2).getServiceName(), "entitlement+billing-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(2).getServiceStateName(), "PHASE"); Assert.assertEquals(subscription.getSubscriptionEvents().get(2).getPrevPhase().getName(), "shotgun-annual-trial"); Assert.assertEquals(subscription.getSubscriptionEvents().get(2).getNextPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(3).getServiceName(), "entitlement-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(3).getServiceStateName(), "ENT_BLOCKED"); Assert.assertEquals(subscription.getSubscriptionEvents().get(3).getPrevPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(3).getNextPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(4).getServiceName(), "billing-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(4).getServiceStateName(), "ENT_BLOCKED"); Assert.assertEquals(subscription.getSubscriptionEvents().get(4).getPrevPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(4).getNextPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(5).getServiceName(), "entitlement-service"); Assert.assertEquals(subscription.getSubscriptionEvents().get(5).getServiceStateName(), "ENT_CLEAR"); Assert.assertEquals(subscription.getSubscriptionEvents().get(5).getPrevPhase().getName(), "shotgun-annual-evergreen"); Assert.assertEquals(subscription.getSubscriptionEvents().get(5).getNextPhase().getName(), "shotgun-annual-evergreen");
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; }