@Override public UUID getBundleId() { return bundle.getId(); }
@Override public String getBundleExternalKey() { return bundle.getExternalKey(); }
public DefaultSubscriptionBase createSubscription(final SubscriptionBaseBundle bundle, final String productName, final BillingPeriod term, final String planSet, final DateTime requestedDate) throws SubscriptionBaseApiException { return createSubscriptionWithBundle(bundle.getId(), productName, term, planSet, requestedDate); }
@Test(groups = "fast") public void testCreateSubscriptionAddOnIncluded() throws SubscriptionBaseApiException { final UUID accountId = UUID.randomUUID(); final SubscriptionBaseBundle aoBundle = subscriptionInternalApi.createBundleForAccount(accountId, "myAOBundle", internalCallContext); testUtil.createSubscriptionWithBundle(aoBundle.getId(), "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_AO_ALREADY_INCLUDED); }
@Test(groups = "fast") public void testCreateSubscriptionBPExists() throws SubscriptionBaseApiException { testUtil.createSubscription(bundle, "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME); tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_BP_EXISTS); }
@Test(groups = "fast") public void testCreateSubscriptionBadCatalog() { // WRONG PRODUCTS tCreateSubscriptionInternal(bundle.getId(), null, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.CAT_NULL_PRODUCT_NAME); tCreateSubscriptionInternal(bundle.getId(), "Whatever", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.CAT_NO_SUCH_PRODUCT); // TODO: MARTIN TO FIX WITH CORRECT ERROR CODE. RIGHT NOW NPE // WRONG BILLING PERIOD tCreateSubscriptionInternal(bundle.getId(), "Shotgun", null, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.CAT_PLAN_NOT_FOUND); // WRONG PLAN SET tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, "Whatever", ErrorCode.CAT_PRICE_LIST_NOT_FOUND); }
@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(); } }
@Test(groups = "fast") public void testUncancelBadState() throws SubscriptionBaseApiException { final SubscriptionBase subscription = testUtil.createSubscription(bundle, "Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME); try { subscription.uncancel(callContext); } catch (SubscriptionBaseApiException e) { assertEquals(e.getCode(), ErrorCode.SUB_UNCANCEL_BAD_STATE.getCode()); } assertListenerStatus(); } }
private List<SubscriptionBaseEvent> transferBundle(final DateTime migrateSubscriptionEventEffectiveDate, final DateTime migrateBillingEventEffectiveDate, final DateTime transferDate) throws SubscriptionBaseTransferApiException { final ImmutableList<ExistingEvent> existingEvents = createMigrateEvents(migrateSubscriptionEventEffectiveDate, migrateBillingEventEffectiveDate); final SubscriptionBuilder subscriptionBuilder = new SubscriptionBuilder(); final DefaultSubscriptionBase subscription = new DefaultSubscriptionBase(subscriptionBuilder); return transferApi.toEvents(existingEvents, subscription, transferDate, callContext); }
@Override @BeforeMethod(groups = "fast") public void beforeMethod() throws Exception { super.beforeMethod(); test = new TestWithException(); final DateTime startDate = clock.getUTCNow(); baseSubscription = testUtil.createSubscription(bundle, baseProduct, BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, startDate); }
public static DateTime addDuration(final DateTime input, final List<Duration> durations) { return addOrRemoveDuration(input, durations, true); }
@Override public void cancelSubscription(final DefaultSubscriptionBase subscription, final SubscriptionBaseEvent cancelEvent, final InternalCallContext context, final int seqId) { synchronized (events) { cancelNextPhaseEvent(subscription.getId(), context); insertEvent(cancelEvent, context); } }
@Test(groups = "slow") public void testChangePlanBundleAlignIMM() throws SubscriptionBaseApiException { tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME); }
@Test(groups = "fast") public void testCreateSubscriptionAddOnNotAvailable() throws SubscriptionBaseApiException { final UUID accountId = UUID.randomUUID(); final SubscriptionBaseBundle aoBundle = subscriptionInternalApi.createBundleForAccount(accountId, "myAOBundle", internalCallContext); testUtil.createSubscriptionWithBundle(aoBundle.getId(), "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, null); tCreateSubscriptionInternal(aoBundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_AO_NOT_AVAILABLE); }
public DefaultSubscriptionBase createSubscription(final SubscriptionBaseBundle bundle, final String productName, final BillingPeriod term, final String planSet) throws SubscriptionBaseApiException { return createSubscriptionWithBundle(bundle.getId(), productName, term, planSet, null); }
@Test(groups = "fast") public void testCreateSubscriptionNoBP() { tCreateSubscriptionInternal(bundle.getId(), "Telescopic-Scope", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.SUB_CREATE_NO_BP); }
public DefaultAccountEventsStreams(final Account account, final Iterable<SubscriptionBaseBundle> bundles, final Map<UUID, Collection<EventsStream>> eventsStreams) { this.account = account; this.eventsStreams = eventsStreams; for (final SubscriptionBaseBundle baseBundle : bundles) { this.bundles.put(baseBundle.getId(), baseBundle); } }
public static DateTime removeDuration(final DateTime input, final List<Duration> durations) { return addOrRemoveDuration(input, durations, false); }
@Override public void createNextPhaseEvent(final DefaultSubscriptionBase subscription, final SubscriptionBaseEvent nextPhase, final InternalCallContext context) { cancelNextPhaseEvent(subscription.getId(), context); insertEvent(nextPhase, context); }
@Override public SubscriptionBaseBundle getSubscriptionBundleFromId(final UUID bundleId, final InternalTenantContext context) { for (final SubscriptionBaseBundle cur : bundles) { if (cur.getId().equals(bundleId)) { return cur; } } return null; }