Example #1
0
  @Test(groups = "fast")
  public void testExistingPriceListIsKept() throws CatalogApiException {
    final DefaultProduct product1 = cat.getCurrentProduct(0);
    final DefaultPriceList priceList1 =
        cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);

    final PlanPhaseSpecifier from =
        new PlanPhaseSpecifier(
            product1.getName(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
    final PlanSpecifier to =
        new PlanSpecifier(product1.getName(), 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);
  }
Example #2
0
  @Test(groups = "fast")
  public void testWildCardPriceList() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();

    final DefaultProduct product = cat.getCurrentProducts()[0];
    final DefaultPriceList priceList =
        cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);

    final CaseResult cr =
        new CaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, null, Result.FOO);

    assertion(
        Result.FOO,
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        cat);
    assertionNull(
        cr,
        cat.getCurrentProducts()[1].getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        cat);
    assertionNull(
        cr,
        product.getName(),
        ProductCategory.ADD_ON,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        cat);
    assertionNull(
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.ANNUAL,
        priceList.getName(),
        cat);
    assertion(
        Result.FOO,
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        "dipsy",
        cat);
  }
Example #3
0
  @Test
  public void testCaseOrder() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();

    final DefaultProduct product = cat.getCurrentProducts()[0];
    final DefaultPriceList priceList =
        cat.findCurrentPriceList(PriceListSet.DEFAULT_PRICELIST_NAME);

    final CaseResult cr0 =
        new CaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, Result.FOO);

    final CaseResult cr1 =
        new CaseResult(product, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, Result.BAR);

    final CaseResult cr2 =
        new CaseResult(
            product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, Result.DIPSY);

    final CaseResult cr3 =
        new CaseResult(product, ProductCategory.BASE, BillingPeriod.ANNUAL, priceList, Result.LALA);

    final Result r1 =
        Case.getResult(
            new CaseResult[] {cr0, cr1, cr2, cr3},
            new PlanSpecifier(
                product.getName(),
                product.getCategory(),
                BillingPeriod.MONTHLY,
                priceList.getName()),
            cat);
    Assert.assertEquals(r1, Result.FOO);

    final Result r2 =
        Case.getResult(
            new CaseResult[] {cr0, cr1, cr2},
            new PlanSpecifier(
                product.getName(),
                product.getCategory(),
                BillingPeriod.ANNUAL,
                priceList.getName()),
            cat);
    Assert.assertEquals(r2, Result.DIPSY);
  }