Tabnine Logo
SubscriptionBaseApiException
Code IndexAdd Tabnine to your IDE (free)

How to use
SubscriptionBaseApiException
in
com.ning.billing.subscription.api.user

Best Java code snippets using com.ning.billing.subscription.api.user.SubscriptionBaseApiException (Showing top 10 results out of 315)

origin: com.ning.billing/killbill-entitlement

private DefaultBlockingAggregator getBlockedStateSubscriptionId(final UUID subscriptionId, final InternalTenantContext context) throws BlockingApiException {
  final SubscriptionBase subscription;
  try {
    subscription = subscriptionApi.getSubscriptionFromId(subscriptionId, context);
    return getBlockedStateSubscription(subscription, context);
  } catch (SubscriptionBaseApiException e) {
    throw new BlockingApiException(e, ErrorCode.fromCode(e.getCode()));
  }
}
origin: com.ning.billing/killbill-entitlement

@Override
public SubscriptionBundle getActiveSubscriptionBundleForExternalKey(final String externalKey, final TenantContext context) throws SubscriptionApiException {
  final InternalTenantContext internalContext = internalCallContextFactory.createInternalTenantContext(context);
  try {
    final UUID activeSubscriptionIdForKey = entitlementUtils.getFirstActiveSubscriptionIdForKeyOrNull(externalKey, internalContext);
    if (activeSubscriptionIdForKey == null) {
      throw new SubscriptionApiException(new SubscriptionBaseApiException(ErrorCode.SUB_GET_INVALID_BUNDLE_KEY, externalKey));
    }
    final SubscriptionBase subscriptionBase = subscriptionBaseInternalApi.getSubscriptionFromId(activeSubscriptionIdForKey, internalContext);
    return getSubscriptionBundle(subscriptionBase.getBundleId(), context);
  } catch (final SubscriptionBaseApiException e) {
    throw new SubscriptionApiException(e);
  }
}
origin: com.ning.billing/killbill-subscription

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());
  }
}
origin: com.ning.billing/killbill-entitlement

private DefaultBlockingAggregator getBlockedStateBundleId(final UUID bundleId, final InternalTenantContext context) throws BlockingApiException {
  final SubscriptionBaseBundle bundle;
  try {
    bundle = subscriptionApi.getBundleFromId(bundleId, context);
    return getBlockedStateBundle(bundle, context);
  } catch (SubscriptionBaseApiException e) {
    throw new BlockingApiException(e, ErrorCode.fromCode(e.getCode()));
  }
}
origin: com.ning.billing/killbill-entitlement

@Override
public Entitlement createBaseEntitlement(final UUID accountId, final PlanPhaseSpecifier planPhaseSpecifier, final String externalKey, final LocalDate effectiveDate, final CallContext callContext) throws EntitlementApiException {
  final InternalCallContext contextWithValidAccountRecordId = internalCallContextFactory.createInternalCallContext(accountId, callContext);
  try {
    if (entitlementUtils.getFirstActiveSubscriptionIdForKeyOrNull(externalKey, contextWithValidAccountRecordId) != null) {
      throw new EntitlementApiException(new SubscriptionBaseApiException(ErrorCode.SUB_CREATE_ACTIVE_BUNDLE_KEY_EXISTS, externalKey));
    }
    final SubscriptionBaseBundle bundle = subscriptionBaseInternalApi.createBundleForAccount(accountId, externalKey, contextWithValidAccountRecordId);
    final DateTime referenceTime = clock.getUTCNow();
    final DateTime requestedDate = dateHelper.fromLocalDateAndReferenceTime(effectiveDate, referenceTime, contextWithValidAccountRecordId);
    final SubscriptionBase subscription = subscriptionBaseInternalApi.createSubscription(bundle.getId(), planPhaseSpecifier, requestedDate, contextWithValidAccountRecordId);
    return new DefaultEntitlement(subscription.getId(), eventsStreamBuilder, this,
                   blockingStateDao, subscriptionBaseInternalApi, checker, notificationQueueService,
                   entitlementUtils, dateHelper, clock, internalCallContextFactory, callContext);
  } catch (SubscriptionBaseApiException e) {
    throw new EntitlementApiException(e);
  }
}
origin: com.ning.billing/killbill-subscription

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());
  }
}
origin: com.ning.billing/killbill-entitlement

throw new EntitlementApiException(new SubscriptionBaseApiException(ErrorCode.SUB_GET_INVALID_BUNDLE_KEY, externalKey));
origin: com.ning.billing/killbill-subscription

  @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();
  }
}
origin: com.ning.billing/killbill-subscription

@Test(groups = "fast")
public void testChangeSubscriptionNonActive() throws SubscriptionBaseApiException {
  final SubscriptionBase subscription = testUtil.createSubscription(bundle, "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
  testListener.pushExpectedEvent(NextEvent.CANCEL);
  subscription.cancelWithDate(clock.getUTCNow(), callContext);
  try {
    subscription.changePlanWithDate("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow(), callContext);
  } catch (SubscriptionBaseApiException e) {
    assertEquals(e.getCode(), ErrorCode.SUB_CHANGE_NON_ACTIVE.getCode());
  }
}
origin: com.ning.billing/killbill-subscription

@Test(groups = "fast")
public void testChangeSubscriptionFutureCancelled() throws SubscriptionBaseApiException {
  SubscriptionBase subscription = testUtil.createSubscription(bundle, "Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
  final PlanPhase trialPhase = subscription.getCurrentPhase();
  // MOVE TO NEXT PHASE
  final PlanPhase currentPhase = subscription.getCurrentPhase();
  testListener.pushExpectedEvent(NextEvent.PHASE);
  final Interval it = new Interval(clock.getUTCNow(), clock.getUTCNow().plusDays(31));
  clock.addDeltaFromReality(it.toDurationMillis());
  assertListenerStatus();
  // SET CTD TO CANCEL IN FUTURE
  final DateTime expectedPhaseTrialChange = TestSubscriptionHelper.addDuration(subscription.getStartDate(), trialPhase.getDuration());
  final Duration ctd = testUtil.getDurationMonth(1);
  final DateTime newChargedThroughDate = TestSubscriptionHelper.addDuration(expectedPhaseTrialChange, ctd);
  subscriptionInternalApi.setChargedThroughDate(subscription.getId(), newChargedThroughDate, internalCallContext);
  subscription = subscriptionInternalApi.getSubscriptionFromId(subscription.getId(), internalCallContext);
  subscription.cancelWithPolicy(BillingActionPolicy.END_OF_TERM, callContext);
  try {
    subscription.changePlanWithDate("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, clock.getUTCNow(), callContext);
  } catch (SubscriptionBaseApiException e) {
    assertEquals(e.getCode(), ErrorCode.SUB_CHANGE_FUTURE_CANCELLED.getCode());
  }
  assertListenerStatus();
}
com.ning.billing.subscription.api.userSubscriptionBaseApiException

Most used methods

  • getCode
  • <init>
  • getMessage

Popular in Java

  • Start an intent from android
  • setScale (BigDecimal)
  • getApplicationContext (Context)
  • getSupportFragmentManager (FragmentActivity)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • MalformedURLException (java.net)
    This exception is thrown when a program attempts to create an URL from an incorrect specification.
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Properties (java.util)
    A Properties object is a Hashtable where the keys and values must be Strings. Each property can have
  • JFrame (javax.swing)
  • StringUtils (org.apache.commons.lang)
    Operations on java.lang.String that arenull safe. * IsEmpty/IsBlank - checks if a String contains
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now