@Override public boolean compliesWithLimits(final String phaseName, final String unit, final double value) throws CatalogApiException { PlanPhase phase = findCurrentPhase(phaseName); return phase.compliesWithLimits(unit, value); }
@Override public DefaultPlan[] getPlans(final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).getCurrentPlans(); }
@Override public int compare(final StandaloneCatalog c1, final StandaloneCatalog c2) { return c1.getEffectiveDate().compareTo(c2.getEffectiveDate()); } });
@Override public ValidationErrors validate(final StandaloneCatalog catalog, final ValidationErrors errors) { if (effectiveDateForExistingSubscriptons != null && catalog.getEffectiveDate().getTime() > effectiveDateForExistingSubscriptons.getTime()) { errors.add(new ValidationError(String.format("Price effective date %s is before catalog effective date '%s'", effectiveDateForExistingSubscriptons, catalog.getEffectiveDate().getTime()), catalog.getCatalogURI(), DefaultInternationalPrice.class, "")); } return errors; }
@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}); c.getCurrentPlans()[0].getFinalPhase().getRecurringPrice().setPrices(null); c.initialize(c, new URI("foo://bar")); Assert.assertEquals(c.getCurrentPlans()[0].getFinalPhase().getRecurringPrice().getPrice(Currency.GBP), new BigDecimal(0)); }
@Override public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException { return super.planChangePolicy(from, to); }
@Override public PlanAlignmentChange planChangeAlignment(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException { return super.planChangeAlignment(from, to); }
@Override public BillingActionPolicy planCancelPolicy(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return super.planCancelPolicy(planPhase); }
@Override public List<Listing> getAvailableBasePlanListings() { final List<Listing> availBasePlans = new ArrayList<Listing>(); for (Plan plan : getCurrentPlans()) { if (plan.getProduct().getCategory().equals(ProductCategory.BASE)) { for (PriceList priceList : getPriceLists().getAllPriceLists()) { for (Plan priceListPlan : priceList.getPlans()) { if (priceListPlan.getName().equals(plan.getName()) && priceListPlan.getProduct().getName().equals(plan.getProduct().getName())) { availBasePlans.add(new DefaultListing(priceListPlan, priceList)); } } } } } return availBasePlans; } }
@Override public void initialize(final StandaloneCatalog catalog, final URI sourceURI) { for (final StandaloneCatalog c : versions) { c.initialize(catalog, sourceURI); } }
@Override public boolean canCreatePlan(final PlanSpecifier specifier, final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).canCreatePlan(specifier); }
@Override public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase, final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).billingAlignment(planPhase); }
@Test(groups = "fast") public void testAddCatalog() throws IOException, SAXException, InvalidConfigException, JAXBException, TransformerException, URISyntaxException, ServiceException, CatalogApiException { vc.add(new StandaloneCatalog(new Date())); Assert.assertEquals(vc.size(), 4); }
@Override public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to, final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).planChangePolicy(from, to); }
@Override public PlanAlignmentChange planChangeAlignment(final PlanPhaseSpecifier from, final PlanSpecifier to, final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).planChangeAlignment(from, to); }
@Override public BillingActionPolicy planCancelPolicy(final PlanPhaseSpecifier planPhase, final DateTime requestedDate) throws CatalogApiException { return versionForDate(requestedDate).planCancelPolicy(planPhase); }
@Override public boolean canCreatePlan(final PlanSpecifier specifier) throws CatalogApiException { return versionForDate(clock.getUTCNow()).canCreatePlan(specifier); }
@Override public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase) throws CatalogApiException { return versionForDate(clock.getUTCNow()).billingAlignment(planPhase); }
private int indexOfVersionForDate(final Date date) throws CatalogApiException { for (int i = versions.size() - 1; i >= 0; i--) { final StandaloneCatalog c = versions.get(i); if (c.getEffectiveDate().getTime() < date.getTime()) { return i; } } throw new CatalogApiException(ErrorCode.CAT_NO_CATALOG_FOR_GIVEN_DATE, date.toString()); }
@Override public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException { return versionForDate(clock.getUTCNow()).planChangePolicy(from, to); }