private void checkChangePlan(final DefaultSubscriptionBase subscription, final String expProduct, final ProductCategory expCategory, final BillingPeriod expBillingPeriod, final PhaseType expPhase) { final Plan currentPlan = subscription.getCurrentPlan(); assertNotNull(currentPlan); assertEquals(currentPlan.getProduct().getName(), expProduct); assertEquals(currentPlan.getProduct().getCategory(), expCategory); assertEquals(currentPlan.getBillingPeriod(), expBillingPeriod); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), expPhase); }
assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.MONTHLY); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.MONTHLY); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
@Test(groups = "slow") public void testCancelSubscriptionEOTWithNoChargeThroughDate() throws SubscriptionBaseApiException { final String prod = "Shotgun"; final BillingPeriod term = BillingPeriod.MONTHLY; final String planSet = PriceListSet.DEFAULT_PRICELIST_NAME; // CREATE final DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, prod, term, planSet); PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); // NEXT PHASE final DateTime expectedPhaseTrialChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), trialPhase.getDuration()); testUtil.checkNextPhaseChange(subscription, 1, expectedPhaseTrialChange); // MOVE TO NEXT PHASE testListener.pushExpectedEvent(NextEvent.PHASE); final Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(31)); clock.addDeltaFromReality(it.toDurationMillis()); assertListenerStatus(); trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.EVERGREEN); testListener.pushExpectedEvent(NextEvent.CANCEL); // CANCEL subscription.cancel(callContext); assertListenerStatus(); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNull(currentPhase); testUtil.checkNextPhaseChange(subscription, 0, null); assertListenerStatus(); }
PlanPhase currentPhase = subscription.getCurrentPhase(); assertEquals(currentPhase.getPhaseType(), PhaseType.TRIAL); currentPhase = subscription.getCurrentPhase(); testListener.isCompleted(3000);
assertNotNull(subscription); PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.TRIAL); clock.addDeltaFromReality(it.toDurationMillis()); assertListenerStatus(); currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT); currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
@Test(groups = "slow") public void testCreateWithInitialPhase() throws SubscriptionBaseApiException { final DateTime init = clock.getUTCNow(); final String productName = "Shotgun"; final BillingPeriod term = BillingPeriod.MONTHLY; final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME; testListener.pushExpectedEvent(NextEvent.CREATE); final DefaultSubscriptionBase subscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(bundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, PhaseType.EVERGREEN), clock.getUTCNow(), internalCallContext); assertNotNull(subscription); assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION); //assertEquals(subscription.getAccount(), account.getId()); assertEquals(subscription.getBundleId(), bundle.getId()); testUtil.assertDateWithin(subscription.getStartDate(), init, clock.getUTCNow()); testUtil.assertDateWithin(subscription.getBundleStartDate(), init, clock.getUTCNow()); final Plan currentPlan = subscription.getCurrentPlan(); assertNotNull(currentPlan); assertEquals(currentPlan.getProduct().getName(), productName); assertEquals(currentPlan.getProduct().getCategory(), ProductCategory.BASE); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.MONTHLY); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN); assertListenerStatus(); }
assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.MONTHLY); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.TRIAL);
private void tChangePlanBundleAlignEOTWithNoChargeThroughDate(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet, final String toProd, final BillingPeriod toTerm, final String toPlanSet) { try { // CREATE final DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, fromProd, fromTerm, fromPlanSet); // MOVE TO NEXT PHASE PlanPhase currentPhase = subscription.getCurrentPhase(); testListener.pushExpectedEvent(NextEvent.PHASE); final Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(31)); clock.addDeltaFromReality(it.toDurationMillis()); final DateTime futureNow = clock.getUTCNow(); final DateTime nextExpectedPhaseChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), currentPhase.getDuration()); assertTrue(futureNow.isAfter(nextExpectedPhaseChange)); assertListenerStatus(); // CHANGE PLAN testListener.pushExpectedEvent(NextEvent.CHANGE); subscription.changePlan(toProd, toTerm, toPlanSet, callContext); assertListenerStatus(); // CHECK CHANGE PLAN currentPhase = subscription.getCurrentPhase(); checkChangePlan(subscription, toProd, ProductCategory.BASE, toTerm, PhaseType.EVERGREEN); assertListenerStatus(); } catch (SubscriptionBaseApiException e) { Assert.fail(e.getMessage()); } }
@Test(groups = "slow") public void testCorrectPhaseAlignmentOnChange() throws SubscriptionBaseApiException { DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, "Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME); PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.ANNUAL); trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.DISCOUNT);
@Test(groups = "slow") public void testMultipleChangeLastIMM() throws SubscriptionBillingApiException, SubscriptionBaseApiException { DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, "Assault-Rifle", BillingPeriod.MONTHLY, "gunclubDiscount"); final PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.ANNUAL); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT);
@Test(groups = "slow") public void testMultipleChangeLastEOT() throws SubscriptionBillingApiException, SubscriptionBaseApiException { DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, "Assault-Rifle", BillingPeriod.ANNUAL, "gunclubDiscount"); final PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.ANNUAL); PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.ANNUAL); currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT); assertEquals(currentPlan.getBillingPeriod(), BillingPeriod.ANNUAL); currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
assertEquals(aoCurrentPlan.getBillingPeriod(), aoTerm); PlanPhase aoCurrentPhase = aoSubscription.getCurrentPhase(); assertNotNull(aoCurrentPhase); assertEquals(aoCurrentPhase.getPhaseType(), PhaseType.DISCOUNT); assertEquals(aoCurrentPlan.getBillingPeriod(), aoTerm); aoCurrentPhase = aoSubscription.getCurrentPhase(); assertNotNull(aoCurrentPhase); assertEquals(aoCurrentPhase.getPhaseType(), PhaseType.EVERGREEN);
PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.EVERGREEN); final PlanPhase currentPhase = subscription.getCurrentPhase(); assertNull(currentPhase); testUtil.checkNextPhaseChange(subscription, 0, null);
assertEquals(aoStatus.get(0).getProductName(), aoProduct); assertEquals(aoStatus.get(0).getBillingPeriod(), aoTerm); assertEquals(aoStatus.get(0).getPhaseType(), aoSubscription.getCurrentPhase().getPhaseType()); assertEquals(aoStatus.get(0).getPriceList(), aoSubscription.getCurrentPriceList().getName()); assertEquals(aoStatus.get(0).getReason(), DryRunChangeReason.AO_INCLUDED_IN_NEW_PLAN);
final PlanPhase trialPhase = subscription.getCurrentPhase(); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); clock.addDeltaFromReality(it.toDurationMillis()); assertListenerStatus(); PlanPhase currentPhase = subscription.getCurrentPhase(); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN); currentPhase = subscription.getCurrentPhase(); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN);
assertEquals(aoStatus.get(0).getProductName(), aoProduct); assertEquals(aoStatus.get(0).getBillingPeriod(), aoTerm); assertEquals(aoStatus.get(0).getPhaseType(), aoSubscription.getCurrentPhase().getPhaseType()); assertEquals(aoStatus.get(0).getPriceList(), aoSubscription.getCurrentPriceList().getName()); assertEquals(aoStatus.get(0).getReason(), DryRunChangeReason.AO_NOT_AVAILABLE_IN_NEW_PLAN);
final PlanPhase trialPhase = subscription.getCurrentPhase(); final DateTime expectedPhaseTrialChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), trialPhase.getDuration()); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); clock.addDeltaFromReality(it.toDurationMillis()); assertListenerStatus(); PlanPhase currentPhase = subscription.getCurrentPhase(); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT); currentPhase = subscription.getCurrentPhase(); checkChangePlan(subscription, fromProd, ProductCategory.BASE, fromTerm, PhaseType.DISCOUNT); currentPhase = subscription.getCurrentPhase(); checkChangePlan(subscription, toProd, ProductCategory.BASE, toTerm, PhaseType.DISCOUNT);
private void tChangePlanBundleAlignIMM(final String fromProd, final BillingPeriod fromTerm, final String fromPlanSet, final String toProd, final BillingPeriod toTerm, final String toPlanSet) throws SubscriptionBaseApiException { final DefaultSubscriptionBase subscription = testUtil.createSubscription(bundle, fromProd, fromTerm, fromPlanSet); testListener.pushExpectedEvent(NextEvent.CHANGE); Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(3)); clock.addDeltaFromReality(it.toDurationMillis()); // CHANGE PLAN IMM subscription.changePlan(toProd, toTerm, toPlanSet, callContext); checkChangePlan(subscription, toProd, ProductCategory.BASE, toTerm, PhaseType.TRIAL); assertListenerStatus(); final PlanPhase currentPhase = subscription.getCurrentPhase(); final DateTime nextExpectedPhaseChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), currentPhase.getDuration()); testUtil.checkNextPhaseChange(subscription, 1, nextExpectedPhaseChange); // NEXT PHASE testListener.pushExpectedEvent(NextEvent.PHASE); it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(30)); clock.addDeltaFromReality(it.toDurationMillis()); final DateTime futureNow = clock.getUTCNow(); assertTrue(futureNow.isAfter(nextExpectedPhaseChange)); assertListenerStatus(); }
final PlanPhase trialPhase = subscription.getCurrentPhase(); final DateTime expectedPhaseTrialChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), trialPhase.getDuration()); assertEquals(trialPhase.getPhaseType(), PhaseType.TRIAL); PlanPhase currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.EVERGREEN); assertNotNull(currentProduct); assertEquals(currentProduct, toProd); currentPhase = subscription.getCurrentPhase(); assertNotNull(currentPhase); assertEquals(currentPhase.getPhaseType(), PhaseType.DISCOUNT);