Пример #1
0
  @Test(groups = "fast")
  public void testBasic() {
    final MockCatalog cat = new MockCatalog();

    final DefaultProduct product = cat.getCurrentProducts()[0];
    final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist();

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

    assertion(
        Result.FOO,
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        PhaseType.EVERGREEN,
        cat);
    assertionNull(
        cr,
        cat.getCurrentProducts()[1].getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        PhaseType.EVERGREEN,
        cat);
    assertionNull(
        cr,
        product.getName(),
        ProductCategory.ADD_ON,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        PhaseType.EVERGREEN,
        cat);
    assertionNull(
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.ANNUAL,
        priceList.getName(),
        PhaseType.EVERGREEN,
        cat);
    assertionException(
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        "dipsy",
        PhaseType.EVERGREEN,
        cat);
    assertionNull(
        cr,
        product.getName(),
        ProductCategory.BASE,
        BillingPeriod.MONTHLY,
        priceList.getName(),
        PhaseType.TRIAL,
        cat);
  }
Пример #2
0
  @Test(groups = "fast")
  public void testOrder() throws CatalogApiException {
    final MockCatalog cat = new MockCatalog();

    final DefaultProduct product = cat.getCurrentProducts()[0];
    final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist();

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

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

    final CaseResult cr2 =
        new CaseResult(
            product,
            ProductCategory.BASE,
            BillingPeriod.MONTHLY,
            priceList,
            PhaseType.EVERGREEN,
            Result.TINKYWINKY);

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

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

    final Result r1 =
        CasePhase.getResult(
            new CaseResult[] {cr0, cr1, cr2, cr3, cr4},
            new PlanPhaseSpecifier(
                product.getName(),
                product.getCategory(),
                BillingPeriod.MONTHLY,
                priceList.getName(),
                PhaseType.EVERGREEN),
            cat);

    Assert.assertEquals(Result.FOO, r1);

    final Result r2 =
        CasePhase.getResult(
            new CaseResult[] {cr0, cr1, cr2, cr3, cr4},
            new PlanPhaseSpecifier(
                product.getName(),
                product.getCategory(),
                BillingPeriod.ANNUAL,
                priceList.getName(),
                PhaseType.EVERGREEN),
            cat);

    Assert.assertEquals(Result.DIPSY, r2);
  }