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

    final PlanPhaseSpecifier from =
        new PlanPhaseSpecifier(
            product1.getName(), BillingPeriod.MONTHLY, priceList1.getName(), PhaseType.EVERGREEN);
    final PlanSpecifier to = new PlanSpecifier(product2.getName(), 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);
  }
Ejemplo n.º 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);
  }
Ejemplo n.º 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);
  }