final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(entitlement.getId(), callContext); Assert.assertEquals(subscription.getEffectiveStartDate(), startDate); Assert.assertEquals(subscription.getEffectiveEndDate(), transferDay); Assert.assertEquals(subscription.getBillingStartDate(), startDate); Assert.assertEquals(subscription.getBillingEndDate(), transferDay); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(entitlement.getId(), callContext); Assert.assertEquals(subscription.getEffectiveStartDate(), transferDay); Assert.assertNull(subscription.getEffectiveEndDate()); Assert.assertEquals(subscription.getBillingStartDate(), transferDay); Assert.assertNull(subscription.getBillingEndDate());
assertEquals(subscription.getEffectiveEndDate().compareTo(new LocalDate(2016, 7, 13)), 0); assertEquals(subscription.getBillingEndDate().compareTo(new LocalDate(2016, 7, 10)), 0);
assertEquals(subscription.getEffectiveEndDate().compareTo(new LocalDate(2016, 5, 18)), 0); assertEquals(subscription.getBillingEndDate().compareTo(new LocalDate(2016, 5, 15)), 0);
@Test(groups = "slow") public void testCancelFutureSubscription() throws AccountApiException, EntitlementApiException, SubscriptionApiException { final LocalDate initialDate = new LocalDate(2013, 8, 7); clock.setDay(initialDate); final Account account = createAccount(getAccountData(7)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, null); final LocalDate futureDate = new LocalDate(2013, 9, 1); // No CREATE event as this is set in the future final UUID createdEntitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), futureDate, futureDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement createdEntitlement = entitlementApi.getEntitlementForId(createdEntitlementId, callContext); assertEquals(createdEntitlement.getEffectiveStartDate().compareTo(futureDate), 0); assertEquals(createdEntitlement.getEffectiveEndDate(), null); final Entitlement baseEntitlement = entitlementApi.getEntitlementForId(createdEntitlement.getId(), callContext); assertEquals(baseEntitlement.getEffectiveStartDate().compareTo(futureDate), 0); assertEquals(baseEntitlement.getEffectiveEndDate(), null); final Entitlement cancelledEntitlement = baseEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.IMMEDIATE, null, callContext); assertEquals(cancelledEntitlement.getEffectiveEndDate().compareTo(futureDate), 0); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(cancelledEntitlement.getId(), callContext); assertEquals(subscription.getEffectiveEndDate().compareTo(futureDate), 0); assertListenerStatus(); }
assertEquals(firstbundle.getSubscriptions().get(0).getEffectiveStartDate(), new LocalDate(2013, 8, 7)); assertEquals(firstbundle.getSubscriptions().get(0).getBillingStartDate(), new LocalDate(2013, 8, 7)); assertEquals(firstbundle.getSubscriptions().get(0).getEffectiveEndDate(), new LocalDate(2013, 8, 10)); assertEquals(firstbundle.getSubscriptions().get(0).getBillingEndDate(), new LocalDate(2013, 8, 10)); assertEquals(secondbundle.getSubscriptions().get(0).getEffectiveStartDate(), new LocalDate(2013, 8, 11)); assertEquals(secondbundle.getSubscriptions().get(0).getBillingStartDate(), new LocalDate(2013, 8, 11)); assertNull(secondbundle.getSubscriptions().get(0).getEffectiveEndDate()); assertNull(secondbundle.getSubscriptions().get(0).getBillingEndDate()); assertEquals(secondbundle.getOriginalCreatedDate().compareTo(firstbundle.getCreatedDate()), 0); assertEquals(firstbundle.getSubscriptions().get(0).getEffectiveStartDate(), new LocalDate(2013, 8, 7)); assertEquals(firstbundle.getSubscriptions().get(0).getBillingStartDate(), new LocalDate(2013, 8, 7)); assertEquals(firstbundle.getSubscriptions().get(0).getEffectiveEndDate(), new LocalDate(2013, 8, 10)); assertEquals(firstbundle.getSubscriptions().get(0).getBillingEndDate(), new LocalDate(2013, 8, 10)); assertEquals(secondbundle.getSubscriptions().get(0).getEffectiveStartDate(), new LocalDate(2013, 8, 11)); assertEquals(secondbundle.getSubscriptions().get(0).getBillingStartDate(), new LocalDate(2013, 8, 11)); assertEquals(secondbundle.getSubscriptions().get(0).getEffectiveEndDate(), new LocalDate(2013, 8, 14)); assertEquals(secondbundle.getSubscriptions().get(0).getBillingEndDate(), new LocalDate(2013, 8, 14)); assertEquals(secondbundle.getOriginalCreatedDate().compareTo(firstbundle.getCreatedDate()), 0); assertEquals(thirdBundle.getSubscriptions().get(0).getEffectiveStartDate(), new LocalDate(2013, 8, 14)); assertEquals(thirdBundle.getSubscriptions().get(0).getBillingStartDate(), new LocalDate(2013, 8, 14)); assertNull(thirdBundle.getSubscriptions().get(0).getEffectiveEndDate()); assertNull(thirdBundle.getSubscriptions().get(0).getBillingEndDate()); assertEquals(thirdBundle.getOriginalCreatedDate().compareTo(firstbundle.getCreatedDate()), 0);
@Test(groups = "slow") public void testCancelSubscriptionInTrialWith_START_OF_TERM() throws Exception { final LocalDate initialDate = new LocalDate(2015, 9, 1); clock.setDay(initialDate); final Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(1)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, null); busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE); final UUID createdEntitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), initialDate, initialDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement createdEntitlement = entitlementApi.getEntitlementForId(createdEntitlementId, callContext); assertEquals(createdEntitlement.getEffectiveStartDate().compareTo(initialDate), 0); assertEquals(createdEntitlement.getEffectiveEndDate(), null); assertListenerStatus(); // Move clock a bit to make sure START_OF_TERM brings us back to initialDate clock.addDays(5); busHandler.pushExpectedEvents(NextEvent.CANCEL, NextEvent.BLOCK, NextEvent.NULL_INVOICE); final Entitlement cancelledEntitlement = createdEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.START_OF_TERM, null, callContext); assertListenerStatus(); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(cancelledEntitlement.getId(), callContext); assertEquals(subscription.getEffectiveEndDate().compareTo(new LocalDate(2015, 9, 6)), 0); assertEquals(subscription.getBillingEndDate().compareTo(initialDate), 0); }
assertEquals(result1.getEffectiveEndDate().compareTo(new LocalDate(2013, 8, 14)), 0); assertEquals(result1.getLastActiveProduct().getName(), "Shotgun"); assertEquals(result1.getState(), EntitlementState.ACTIVE); assertEquals(result2.getEffectiveEndDate().compareTo(new LocalDate(2013, 8, 14)), 0); assertEquals(result2.getLastActiveProduct().getName(), "Shotgun"); assertEquals(result2.getState(), EntitlementState.CANCELLED);
assertEquals(cancelledBaseSubscription.getEffectiveEndDate(), new LocalDate(2012, 6, 05)); assertEquals(cancelledBaseSubscription.getBillingEndDate(), new LocalDate(2012, 6, 30)); assertEquals(cancelledAddon1.getEffectiveEndDate(), new LocalDate(2012, 6, 05)); assertEquals(cancelledAddon1.getBillingEndDate(), new LocalDate(2012, 6, 30));
@Test(groups = "slow") public void testCancelSubscriptionAfterTrialWith_START_OF_TERM() throws Exception { final LocalDate initialDate = new LocalDate(2015, 8, 1); clock.setDay(initialDate); Account account = createAccountWithNonOsgiPaymentMethod(getAccountData(0)); final PlanPhaseSpecifier spec = new PlanPhaseSpecifier("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, null); busHandler.pushExpectedEvents(NextEvent.CREATE, NextEvent.BLOCK, NextEvent.INVOICE); final UUID createdEntitlementId = entitlementApi.createBaseEntitlement(account.getId(), new DefaultEntitlementSpecifier(spec), account.getExternalKey(), initialDate, initialDate, false, true, ImmutableList.<PluginProperty>of(), callContext); final Entitlement createdEntitlement = entitlementApi.getEntitlementForId(createdEntitlementId, callContext); assertEquals(createdEntitlement.getEffectiveStartDate().compareTo(initialDate), 0); assertEquals(createdEntitlement.getEffectiveEndDate(), null); assertListenerStatus(); // Move out of trial : 2015-8-31 busHandler.pushExpectedEvents(NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT, NextEvent.INVOICE_PAYMENT); clock.addDays(30); assertListenerStatus(); // SUBSCRIPTION alignment: no account BCD account = accountUserApi.getAccountById(account.getId(), callContext); Assert.assertEquals(account.getBillCycleDayLocal().intValue(), 0); // Move clock a bit to make sure START_OF_TERM brings us back to last Phase date : 2015-9-5 clock.addDays(5); busHandler.pushExpectedEvents(NextEvent.CANCEL, NextEvent.BLOCK, NextEvent.INVOICE); final Entitlement cancelledEntitlement = createdEntitlement.cancelEntitlementWithPolicyOverrideBillingPolicy(EntitlementActionPolicy.IMMEDIATE, BillingActionPolicy.START_OF_TERM, null, callContext); assertListenerStatus(); final Subscription subscription = subscriptionApi.getSubscriptionForEntitlementId(cancelledEntitlement.getId(), callContext); assertEquals(subscription.getEffectiveEndDate().compareTo(new LocalDate(2015, 9, 5)), 0); assertEquals(subscription.getBillingEndDate().compareTo(new LocalDate(2015, 8, 31)), 0); }
this.cancelledDate = subscription.getEffectiveEndDate(); this.chargedThroughDate = subscription.getChargedThroughDate(); this.billingStartDate = subscription.getBillingStartDate();