public void initialize(final StandaloneCatalog catalog, final PriceOverride priceOverride, final InternalCallContextFactory internalCallContextFactory) { super.initialize(catalog); this.priceOverride = priceOverride; this.internalCallContextFactory = internalCallContextFactory; }
private void initializeCatalog(final DefaultVersionedCatalog tenantCatalog) { tenantCatalog.initialize(defaultCatalog.getClock(), tenantCatalog); for (final StandaloneCatalog cur : tenantCatalog.getVersions()) { if (cur instanceof StandaloneCatalogWithPriceOverride) { ((StandaloneCatalogWithPriceOverride) cur).initialize(cur, priceOverride, internalCallContextFactory); } else { cur.initialize(cur); } } }
@Test(groups = "slow", expectedExceptions = CatalogApiException.class) public void testWithInvalidPriceOverride() throws Exception { final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class); catalog.initialize(catalog); final Plan plan = catalog.findCurrentPlan("discount-standard-monthly"); final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>(); final PlanPhasePriceOverride phase1 = new DefaultPlanPhasePriceOverride(plan.getAllPhases()[0].getName(), Currency.USD, null, BigDecimal.ONE, null); overrides.add(phase1); priceOverride.getOrCreateOverriddenPlan(catalog, plan, new DateTime(catalog.getEffectiveDate()), overrides, internalCallContext); }
public CatalogUpdater(final DateTime effectiveDate, final Currency... currencies) { final DefaultPriceList defaultPriceList = new DefaultPriceList().setName(PriceListSet.DEFAULT_PRICELIST_NAME); final StandaloneCatalog tmp = new StandaloneCatalog() .setCatalogName(DEFAULT_CATALOG_NAME) .setEffectiveDate(effectiveDate.toDate()) .setRecurringBillingMode(BillingMode.IN_ADVANCE) .setProducts(ImmutableList.<Product>of()) .setPlans(ImmutableList.<Plan>of()) .setPriceLists(new DefaultPriceListSet(defaultPriceList, new DefaultPriceList[0])) .setPlanRules(getSaneDefaultPlanRules(defaultPriceList)); if (currencies != null && currencies.length > 0) { tmp.setSupportedCurrencies(currencies); } else { tmp.setSupportedCurrencies(new Currency[0]); } tmp.initialize(tmp); this.catalog = new DefaultMutableStaticCatalog(tmp); }
@Test(groups = "fast") public void testPriceInitialization() throws URISyntaxException, CatalogApiException { final StandaloneCatalog c = new MockCatalog(); c.setSupportedCurrencies(new Currency[]{Currency.GBP, Currency.EUR, Currency.USD, Currency.BRL, Currency.MXN}); ((DefaultInternationalPrice) c.getCurrentPlans().iterator().next().getFinalPhase().getRecurring().getRecurringPrice()).setPrices(new DefaultPrice[0]); c.setUnits(new DefaultUnit[0]); c.initialize(c); Assert.assertEquals(c.getCurrentPlans().iterator().next().getFinalPhase().getRecurring().getRecurringPrice().getPrice(Currency.GBP), new BigDecimal(0)); }
catalog.initialize(catalog); final Plan plan = catalog.findCurrentPlan("discount-standard-monthly");
catalog.initialize(catalog);
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog) { final StandaloneCatalog result = new StandaloneCatalog(); result.setCatalogName(catalogName); result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate()); result.setProducts(toDefaultProducts(pluginCatalog.getProducts())); result.setPlans(toDefaultPlans(result, pluginCatalog.getPlans())); result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList())); result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies())); result.setUnits(toDefaultUnits(pluginCatalog.getUnits())); result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules())); for (final Product cur : pluginCatalog.getProducts()) { final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName()); if (target != null) { ((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable())); ((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded())); } } result.initialize(result); return result; }
public void initialize(final StandaloneCatalog catalog, final PriceOverride priceOverride, final InternalCallContextFactory internalCallContextFactory) { super.initialize(catalog); this.priceOverride = priceOverride; this.internalCallContextFactory = internalCallContextFactory; }
private void initializeCatalog(final DefaultVersionedCatalog tenantCatalog) { tenantCatalog.initialize(defaultCatalog.getClock(), tenantCatalog); for (final StandaloneCatalog cur : tenantCatalog.getVersions()) { if (cur instanceof StandaloneCatalogWithPriceOverride) { ((StandaloneCatalogWithPriceOverride) cur).initialize(cur, priceOverride, internalCallContextFactory); } else { cur.initialize(cur); } } }
@Test(groups = "slow", expectedExceptions = CatalogApiException.class) public void testWithInvalidPriceOverride() throws Exception { final StandaloneCatalog catalog = XMLLoader.getObjectFromString(Resources.getResource("SpyCarAdvanced.xml").toExternalForm(), StandaloneCatalog.class); catalog.initialize(catalog); final Plan plan = catalog.findCurrentPlan("discount-standard-monthly"); final List<PlanPhasePriceOverride> overrides = new ArrayList<PlanPhasePriceOverride>(); final PlanPhasePriceOverride phase1 = new DefaultPlanPhasePriceOverride(plan.getAllPhases()[0].getName(), Currency.USD, null, BigDecimal.ONE, null); overrides.add(phase1); priceOverride.getOrCreateOverriddenPlan(catalog, plan, new DateTime(catalog.getEffectiveDate()), overrides, internalCallContext); }
public CatalogUpdater(final DateTime effectiveDate, final Currency... currencies) { final DefaultPriceList defaultPriceList = new DefaultPriceList().setName(PriceListSet.DEFAULT_PRICELIST_NAME); final StandaloneCatalog tmp = new StandaloneCatalog() .setCatalogName(DEFAULT_CATALOG_NAME) .setEffectiveDate(effectiveDate.toDate()) .setRecurringBillingMode(BillingMode.IN_ADVANCE) .setProducts(ImmutableList.<Product>of()) .setPlans(ImmutableList.<Plan>of()) .setPriceLists(new DefaultPriceListSet(defaultPriceList, new DefaultPriceList[0])) .setPlanRules(getSaneDefaultPlanRules(defaultPriceList)); if (currencies != null && currencies.length > 0) { tmp.setSupportedCurrencies(currencies); } else { tmp.setSupportedCurrencies(new Currency[0]); } tmp.initialize(tmp); this.catalog = new DefaultMutableStaticCatalog(tmp); }
@Test(groups = "fast") public void testPriceInitialization() throws URISyntaxException, CatalogApiException { final StandaloneCatalog c = new MockCatalog(); c.setSupportedCurrencies(new Currency[]{Currency.GBP, Currency.EUR, Currency.USD, Currency.BRL, Currency.MXN}); ((DefaultInternationalPrice) c.getCurrentPlans().iterator().next().getFinalPhase().getRecurring().getRecurringPrice()).setPrices(new DefaultPrice[0]); c.setUnits(new DefaultUnit[0]); c.initialize(c); Assert.assertEquals(c.getCurrentPlans().iterator().next().getFinalPhase().getRecurring().getRecurringPrice().getPrice(Currency.GBP), new BigDecimal(0)); }
catalog.initialize(catalog); final Plan plan = catalog.findCurrentPlan("discount-standard-monthly");
catalog.initialize(catalog);
public StandaloneCatalog toStandaloneCatalog(final StandalonePluginCatalog pluginCatalog) { final StandaloneCatalog result = new StandaloneCatalog(); result.setCatalogName(catalogName); result.setEffectiveDate(pluginCatalog.getEffectiveDate().toDate()); result.setProducts(toDefaultProducts(pluginCatalog.getProducts())); result.setPlans(toDefaultPlans(result, pluginCatalog.getPlans())); result.setPriceLists(toDefaultPriceListSet(pluginCatalog.getDefaultPriceList(), pluginCatalog.getChildrenPriceList())); result.setSupportedCurrencies(toArray(pluginCatalog.getCurrencies())); result.setUnits(toDefaultUnits(pluginCatalog.getUnits())); result.setPlanRules(toDefaultPlanRules(pluginCatalog.getPlanRules())); for (final Product cur : pluginCatalog.getProducts()) { final Product target = result.getCatalogEntityCollectionProduct().findByName(cur.getName()); if (target != null) { ((DefaultProduct) target).setAvailable(toFilteredDefaultProduct(cur.getAvailable())); ((DefaultProduct) target).setIncluded(toFilteredDefaultProduct(cur.getIncluded())); } } result.initialize(result); return result; }