private void tCreateSubscriptionInternal(@Nullable final UUID bundleId, @Nullable final String productName, @Nullable final BillingPeriod term, final String planSet, final ErrorCode expected) { try { subscriptionInternalApi.createSubscription(bundleId, testUtil.getProductSpecifier(productName, planSet, term, null), clock.getUTCNow(), internalCallContext); Assert.fail("Exception expected, error code: " + expected); } catch (SubscriptionBaseApiException e) { assertEquals(e.getCode(), expected.getCode()); } }
@Test(groups = "slow") public void testSubscriptionWithAddOn() throws SubscriptionBaseApiException { final String productName = "Shotgun"; final BillingPeriod term = BillingPeriod.ANNUAL; final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME; testListener.pushExpectedEvent(NextEvent.CREATE); final DefaultSubscriptionBase subscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(bundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), internalCallContext); assertNotNull(subscription); assertListenerStatus(); } }
testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); assertNotNull(subscription);
testListener.pushExpectedEvent(NextEvent.CREATE); DefaultSubscriptionBase subscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(bundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); assertNotNull(subscription); assertEquals(subscription.getActiveVersion(), SubscriptionEvents.INITIAL_VERSION); if (fromUserAPi) { subscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(bundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); } else { subscription.recreate(testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, callContext); testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); } else { subscription.recreate(testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), callContext);
@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(); }
testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), internalCallContext); assertNotNull(subscription);
@Test(groups = "slow") public void testCreateBundlesWithSameExternalKeys() throws SubscriptionBaseApiException { final DateTime init = clock.getUTCNow(); final DateTime requestedDate = init.minusYears(1); final String productName = "Shotgun"; final BillingPeriod term = BillingPeriod.MONTHLY; final String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME; testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.PHASE); final DefaultSubscriptionBase subscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(bundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); assertListenerStatus(); assertNotNull(subscription); testListener.pushExpectedEvent(NextEvent.CANCEL); subscription.cancelWithDate(clock.getUTCNow(), callContext); assertListenerStatus(); final SubscriptionBaseBundle newBundle = subscriptionInternalApi.createBundleForAccount(bundle.getAccountId(), DefaultSubscriptionTestInitializer.DEFAULT_BUNDLE_KEY, internalCallContext); assertNotNull(newBundle); assertEquals(newBundle.getOriginalCreatedDate().compareTo(bundle.getCreatedDate()), 0); testListener.pushExpectedEvents(NextEvent.CREATE, NextEvent.PHASE); final DefaultSubscriptionBase newSubscription = (DefaultSubscriptionBase) subscriptionInternalApi.createSubscription(newBundle.getId(), testUtil.getProductSpecifier(productName, planSetName, term, null), requestedDate, internalCallContext); subscriptionInternalApi.updateExternalKey(newBundle.getId(), "myNewSuperKey", internalCallContext); final SubscriptionBaseBundle bundleWithNewKey = subscriptionInternalApi.getBundleFromId(newBundle.getId(), internalCallContext); assertEquals(bundleWithNewKey.getExternalKey(), "myNewSuperKey"); assertListenerStatus(); assertNotNull(newSubscription); }
testUtil.getProductSpecifier(productName, planSetName, term, null), clock.getUTCNow(), internalCallContext); assertNotNull(subscription);