protected void assertion(final Result result, final CaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertEquals(result, cr.getResult(new PlanPhaseSpecifier(productName, productCategory, bp, priceListName, phaseType), cat)); } catch (CatalogApiException e) { Assert.fail("", e); } } }
final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist(); final CaseResult cr0 = new CaseResult( product, ProductCategory.BASE, Result.FOO); final CaseResult cr1 = new CaseResult( product, ProductCategory.BASE, Result.BAR); final CaseResult cr2 = new CaseResult( product, ProductCategory.BASE, Result.TINKYWINKY); final CaseResult cr3 = new CaseResult( product, ProductCategory.BASE, final CaseResult cr4 = new CaseResult( product, ProductCategory.BASE,
@Test(groups = "fast") public void testWildCardPriceList() { 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, null, 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); assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, "dipsy", PhaseType.EVERGREEN, cat); assertionNull(cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.TRIAL, cat); }
@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); }
@Test(groups = "fast") public void testWildCardProductCategory() { final MockCatalog cat = new MockCatalog(); final DefaultProduct product = cat.getCurrentProducts()[0]; final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist(); final CaseResult cr = new CaseResult( product, null, 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); assertion(Result.FOO, 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); }
@Test(groups = "fast") public void testWildCardProduct() { final MockCatalog cat = new MockCatalog(); final DefaultProduct product = cat.getCurrentProducts()[0]; final DefaultPriceList priceList = cat.getPriceLists().getDefaultPricelist(); final CaseResult cr = new CaseResult( null, ProductCategory.BASE, BillingPeriod.MONTHLY, priceList, PhaseType.EVERGREEN, Result.FOO); assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.EVERGREEN, cat); assertion(Result.FOO, 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); }
@Test(groups = "fast") public void testWildCardPhaseType() { 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, null, 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); assertion(Result.FOO, cr, product.getName(), ProductCategory.BASE, BillingPeriod.MONTHLY, priceList.getName(), PhaseType.TRIAL, cat); }
@Test(groups = "fast") public void testWildCardBillingPeriod() { 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, null, 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); assertion(Result.FOO, 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); }
protected void assertionException(final CaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertNull(cr.getResult(new PlanPhaseSpecifier(productName, productCategory, bp, priceListName, phaseType), cat)); Assert.fail("Exception expected"); } catch (CatalogApiException e) { Assert.assertEquals(e.getCode(), ErrorCode.CAT_PRICE_LIST_NOT_FOUND.getCode()); } }
protected void assertionNull(final CaseResult cr, final String productName, final ProductCategory productCategory, final BillingPeriod bp, final String priceListName, final PhaseType phaseType, final StandaloneCatalog cat) { try { Assert.assertNull(cr.getResult(new PlanPhaseSpecifier(productName, productCategory, bp, priceListName, phaseType), cat)); } catch (CatalogApiException e) { Assert.fail("", e); } }
public CaseResult(final DefaultProduct product, final ProductCategory productCategory, final BillingPeriod billingPeriod, final DefaultPriceList priceList, final PhaseType phaseType, final Result policy) { setProduct(product); setProductCategory(productCategory); setBillingPeriod(billingPeriod); setPriceList(priceList); setPhaseType(phaseType); this.policy = policy; }