Пример #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);
  }
Пример #2
0
  @BeforeMethod(groups = "fast")
  public void beforeMethod() {
    cat = new MockCatalog();

    final DefaultPriceList priceList2 = cat.getPriceLists().getChildPriceLists()[0];

    final DefaultCaseChangePlanPolicy casePolicy =
        new DefaultCaseChangePlanPolicy().setPolicy(BillingActionPolicy.END_OF_TERM);
    final DefaultCaseChangePlanAlignment caseAlignment =
        new DefaultCaseChangePlanAlignment()
            .setAlignment(PlanAlignmentChange.START_OF_SUBSCRIPTION);
    final DefaultCasePriceList casePriceList =
        new DefaultCasePriceList().setToPriceList(priceList2);

    cat.getPlanRules()
        .setChangeCase(new DefaultCaseChangePlanPolicy[] {casePolicy})
        .setChangeAlignmentCase(new DefaultCaseChangePlanAlignment[] {caseAlignment})
        .setPriceListCase(new DefaultCasePriceList[] {casePriceList});
  }