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

How to use
PlanChangeResult
in
com.ning.billing.catalog.api

Best Java code snippets using com.ning.billing.catalog.api.PlanChangeResult (Showing top 3 results out of 315)

origin: com.ning.billing/killbill-catalog

@Test(groups = "fast")
public void testExistingPriceListIsKept() throws CatalogApiException {
  final DefaultProduct product1 = cat.getCurrentProducts()[0];
  final DefaultPriceList priceList1 = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
  final PlanPhaseSpecifier from = new PlanPhaseSpecifier(product1.getName(), product1.getCategory(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
  final PlanSpecifier to = new PlanSpecifier(product1.getName(), product1.getCategory(), BillingPeriod.ANNUAL, priceList1.getName());
  PlanChangeResult result = null;
  try {
    result = cat.getPlanRules().planChange(from, to, cat);
  } catch (IllegalPlanChange e) {
    Assert.fail("We should not have triggered this error");
  } catch (CatalogApiException e) {
    Assert.fail("", e);
  }
  Assert.assertEquals(result.getPolicy(), BillingActionPolicy.END_OF_TERM);
  Assert.assertEquals(result.getAlignment(), PlanAlignmentChange.START_OF_SUBSCRIPTION);
  Assert.assertEquals(result.getNewPriceList(), priceList1);
}
origin: com.ning.billing/killbill-catalog

public PlanChangeResult planChange(final PlanPhaseSpecifier from, PlanSpecifier to, final StandaloneCatalog catalog) throws CatalogApiException {
  final DefaultPriceList toPriceList;
  if (to.getPriceListName() == null) { // Pricelist may be null because it is unspecified this is the principal use-case
    toPriceList = findPriceList(from.toPlanSpecifier(), catalog);
    to = new PlanSpecifier(to.getProductName(), to.getProductCategory(), to.getBillingPeriod(), toPriceList.getName());
  } else {
    toPriceList = catalog.findCurrentPriceList(to.getPriceListName());
  }
  final BillingActionPolicy policy = getPlanChangePolicy(from, to, catalog);
  if (policy == BillingActionPolicy.ILLEGAL) {
    throw new IllegalPlanChange(from, to);
  }
  final PlanAlignmentChange alignment = getPlanChangeAlignment(from, to, catalog);
  return new PlanChangeResult(toPriceList, policy, alignment);
}
origin: com.ning.billing/killbill-catalog

  @Test(groups = "fast")
  public void testBaseCase() throws CatalogApiException {
    final DefaultProduct product1 = cat.getCurrentProducts()[0];
    final DefaultProduct product2 = cat.getCurrentProducts()[1];
    final DefaultPriceList priceList1 = cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);
    final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[0];

    final PlanPhaseSpecifier from = new PlanPhaseSpecifier(product1.getName(), product1.getCategory(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
    final PlanSpecifier to = new PlanSpecifier(product2.getName(), product2.getCategory(), BillingPeriod.MONTHLY, null);

    PlanChangeResult result = null;
    try {
      result = cat.getPlanRules().planChange(from, to, cat);
    } catch (IllegalPlanChange e) {
      Assert.fail("We should not have triggered this error");
    } catch (CatalogApiException e) {
      Assert.fail("", e);
    }

    Assert.assertEquals(result.getPolicy(), BillingActionPolicy.END_OF_TERM);
    Assert.assertEquals(result.getAlignment(), PlanAlignmentChange.START_OF_SUBSCRIPTION);
    Assert.assertEquals(result.getNewPriceList(), priceList2);
  }
}
com.ning.billing.catalog.apiPlanChangeResult

Most used methods

  • <init>
  • getAlignment
  • getNewPriceList
  • getPolicy

Popular in Java

  • Reading from database using SQL prepared statement
  • onCreateOptionsMenu (Activity)
  • putExtra (Intent)
  • onRequestPermissionsResult (Fragment)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • InputStreamReader (java.io)
    A class for turning a byte stream into a character stream. Data read from the source input stream is
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • BoxLayout (javax.swing)
  • Get (org.apache.hadoop.hbase.client)
    Used to perform Get operations on a single row. To get everything for a row, instantiate a Get objec
  • 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