killbill-uncached
Changes
pom.xml 2(+1 -1)
Details
diff --git a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
index f9c1c0d..ed0e394 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/StandaloneCatalog.java
@@ -79,14 +79,14 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
private DefaultUnit[] units;
@XmlElementWrapper(name = "products", required = true)
- @XmlElement(type=DefaultProduct.class, name = "product", required = false)
+ @XmlElement(type = DefaultProduct.class, name = "product", required = false)
private CatalogEntityCollection<Product> products;
@XmlElement(name = "rules", required = true)
private DefaultPlanRules planRules;
@XmlElementWrapper(name = "plans", required = true)
- @XmlElement(type=DefaultPlan.class, name = "plan", required = false)
+ @XmlElement(type = DefaultPlan.class, name = "plan", required = false)
private CatalogEntityCollection<Plan> plans;
@XmlElement(name = "priceLists", required = true)
@@ -103,35 +103,35 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
this.effectiveDate = effectiveDate;
}
- /* (non-Javadoc)
- * @see org.killbill.billing.catalog.ICatalog#getCalalogName()
- */
@Override
public String getCatalogName() {
return catalogName;
}
+ public StandaloneCatalog setCatalogName(final String catalogName) {
+ this.catalogName = catalogName;
+ return this;
+ }
+
@Override
public Date getEffectiveDate() {
return effectiveDate;
}
- /* (non-Javadoc)
- * @see org.killbill.billing.catalog.ICatalog#getProducts()
- */
+ public StandaloneCatalog setEffectiveDate(final Date effectiveDate) {
+ this.effectiveDate = effectiveDate;
+ return this;
+ }
+
@Override
public Collection<Product> getCurrentProducts() {
return products.getEntries();
}
-
- public CatalogEntityCollection<Product> getCatalogEntityCollectionProduct() {
+ public CatalogEntityCollection<Product> getCatalogEntityCollectionProduct() {
return products;
}
- /* (non-Javadoc)
- * @see org.killbill.billing.catalog.ICatalog#getProducts()
- */
@Override
public DefaultUnit[] getCurrentUnits() {
return units;
@@ -142,21 +142,18 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return supportedCurrencies;
}
-
-
@Override
public Collection<Plan> getCurrentPlans() {
return plans.getEntries();
}
-
public CatalogEntityCollection<Plan> getCatalogEntityCollectionPlan() {
return plans;
}
public boolean isTemplateCatalog() {
- return (products == null || products.size() == 0) &&
- (plans == null || plans.size() == 0) &&
+ return (products == null || products.isEmpty()) &&
+ (plans == null || plans.isEmpty()) &&
(supportedCurrencies == null || supportedCurrencies.length == 0);
}
@@ -168,6 +165,11 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return planRules;
}
+ public StandaloneCatalog setPlanRules(final DefaultPlanRules planRules) {
+ this.planRules = planRules;
+ return this;
+ }
+
public DefaultPriceList findCurrentPriceList(final String priceListName) throws CatalogApiException {
return priceLists.findPriceListFrom(priceListName);
}
@@ -176,6 +178,11 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return this.priceLists;
}
+ public StandaloneCatalog setPriceLists(final DefaultPriceListSet priceLists) {
+ this.priceLists = priceLists;
+ return this;
+ }
+
@Override
public Plan createOrFindCurrentPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext unused) throws CatalogApiException {
final Plan result;
@@ -194,7 +201,7 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
}
if (result == null) {
throw new CatalogApiException(ErrorCode.CAT_PLAN_NOT_FOUND,
- spec.getPlanName() != null ? spec.getPlanName() : "undefined",
+ spec.getPlanName() != null ? spec.getPlanName() : "undefined",
spec.getProductName() != null ? spec.getProductName() : "undefined",
spec.getBillingPeriod() != null ? spec.getBillingPeriod() : "undefined",
spec.getPriceListName() != null ? spec.getPriceListName() : "undefined");
@@ -202,6 +209,12 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return result;
}
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // RULES
+ //
+ //////////////////////////////////////////////////////////////////////////////
+
@Override
public DefaultPlan findCurrentPlan(final String name) throws CatalogApiException {
if (name == null || plans == null) {
@@ -245,16 +258,6 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return priceLists.findPriceListFrom(name);
}
- //////////////////////////////////////////////////////////////////////////////
- //
- // RULES
- //
- //////////////////////////////////////////////////////////////////////////////
- @Override
- public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException {
- return planRules.getPlanChangePolicy(from, to, this);
- }
-
@Override
public PlanAlignmentChange planChangeAlignment(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException {
return planRules.getPlanChangeAlignment(from, to, this);
@@ -275,6 +278,12 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return planRules.getBillingAlignment(planPhase, this);
}
+ //////////////////////////////////////////////////////////////////////////////
+ //
+ // UNIT LIMIT
+ //
+ //////////////////////////////////////////////////////////////////////////////
+
@Override
public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to)
throws CatalogApiException {
@@ -283,8 +292,8 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
@Override
public ValidationErrors validate(final StandaloneCatalog catalog, final ValidationErrors errors) {
- validateCollection(catalog, errors, (DefaultProduct[]) products.toArray(new DefaultProduct[products.size()]));
- validateCollection(catalog, errors, (DefaultPlan[]) plans.toArray(new DefaultPlan[plans.size()]));
+ validateCollection(catalog, errors, (DefaultProduct[]) products.toArray(new DefaultProduct[0]));
+ validateCollection(catalog, errors, (DefaultPlan[]) plans.toArray(new DefaultPlan[0]));
priceLists.validate(catalog, errors);
planRules.validate(catalog, errors);
return errors;
@@ -303,7 +312,7 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
cur.initialize(catalog, sourceURI);
}
for (final Product p : products.getEntries()) {
- ((DefaultProduct)p).initialize(catalog, sourceURI);
+ ((DefaultProduct) p).initialize(catalog, sourceURI);
}
for (final Plan p : plans.getEntries()) {
((DefaultPlan) p).initialize(catalog, sourceURI);
@@ -314,16 +323,9 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return recurringBillingMode;
}
- //////////////////////////////////////////////////////////////////////////////
- //
- // UNIT LIMIT
- //
- //////////////////////////////////////////////////////////////////////////////
-
- @Override
- public boolean compliesWithLimits(final String phaseName, final String unit, final double value) throws CatalogApiException {
- PlanPhase phase = findCurrentPhase(phaseName);
- return phase.compliesWithLimits(unit, value);
+ public StandaloneCatalog setRecurringBillingMode(final BillingMode recurringBillingMode) {
+ this.recurringBillingMode = recurringBillingMode;
+ return this;
}
public StandaloneCatalog setProducts(final Iterable<Product> products) {
@@ -341,60 +343,24 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
return this;
}
- public StandaloneCatalog setCatalogName(final String catalogName) {
- this.catalogName = catalogName;
- return this;
- }
-
- public StandaloneCatalog setEffectiveDate(final Date effectiveDate) {
- this.effectiveDate = effectiveDate;
- return this;
- }
-
- public StandaloneCatalog setRecurringBillingMode(final BillingMode recurringBillingMode) {
- this.recurringBillingMode = recurringBillingMode;
- return this;
- }
-
- public StandaloneCatalog setPlanRules(final DefaultPlanRules planRules) {
- this.planRules = planRules;
- return this;
- }
-
- public StandaloneCatalog setPriceLists(final DefaultPriceListSet priceLists) {
- this.priceLists = priceLists;
- return this;
- }
-
public StandaloneCatalog setUnits(final DefaultUnit[] units) {
this.units = units;
return this;
}
@Override
- public boolean canCreatePlan(final PlanSpecifier specifier) throws CatalogApiException {
- final Product product = findCurrentProduct(specifier.getProductName());
- final Plan plan = createOrFindCurrentPlan(specifier, null);
- final DefaultPriceList priceList = findCurrentPriceList(specifier.getPriceListName());
-
- return (product != null) &&
- (plan != null) &&
- (priceList != null);
- }
-
- @Override
public List<Listing> getAvailableAddOnListings(final String baseProductName, @Nullable final String priceListName) {
final List<Listing> availAddons = new ArrayList<Listing>();
try {
- Product product = findCurrentProduct(baseProductName);
+ final Product product = findCurrentProduct(baseProductName);
if (product != null) {
- for (Product availAddon : product.getAvailable()) {
- for (BillingPeriod billingPeriod : BillingPeriod.values()) {
- for (PriceList priceList : getPriceLists().getAllPriceLists()) {
+ for (final Product availAddon : product.getAvailable()) {
+ for (final BillingPeriod billingPeriod : BillingPeriod.values()) {
+ for (final PriceList priceList : getPriceLists().getAllPriceLists()) {
if (priceListName == null || priceListName.equals(priceList.getName())) {
- Collection<Plan> addonInList = priceList.findPlans(availAddon, billingPeriod);
- for (Plan cur : addonInList) {
+ final Collection<Plan> addonInList = priceList.findPlans(availAddon, billingPeriod);
+ for (final Plan cur : addonInList) {
availAddons.add(new DefaultListing(cur, priceList));
}
}
@@ -402,7 +368,7 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
}
}
}
- } catch (CatalogApiException e) {
+ } catch (final CatalogApiException e) {
// No such product - just return an empty list
}
return availAddons;
@@ -412,10 +378,10 @@ public class StandaloneCatalog extends ValidatingConfig<StandaloneCatalog> imple
public List<Listing> getAvailableBasePlanListings() {
final List<Listing> availBasePlans = new ArrayList<Listing>();
- for (Plan plan : getCurrentPlans()) {
+ for (final Plan plan : getCurrentPlans()) {
if (plan.getProduct().getCategory().equals(ProductCategory.BASE)) {
- for (PriceList priceList : getPriceLists().getAllPriceLists()) {
- for (Plan priceListPlan : priceList.getPlans()) {
+ for (final PriceList priceList : getPriceLists().getAllPriceLists()) {
+ for (final Plan priceListPlan : priceList.getPlans()) {
if (priceListPlan.getName().equals(plan.getName()) &&
priceListPlan.getProduct().getName().equals(plan.getProduct().getName())) {
availBasePlans.add(new DefaultListing(priceListPlan, priceList));
diff --git a/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java b/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
index f7d8036..f970b68 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/VersionedCatalog.java
@@ -44,7 +44,6 @@ import org.joda.time.DateTime;
import org.killbill.billing.ErrorCode;
import org.killbill.billing.catalog.api.BillingActionPolicy;
import org.killbill.billing.catalog.api.BillingAlignment;
-import org.killbill.billing.catalog.api.BillingMode;
import org.killbill.billing.catalog.api.Catalog;
import org.killbill.billing.catalog.api.CatalogApiException;
import org.killbill.billing.catalog.api.Currency;
@@ -123,38 +122,12 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
// This is not strictly correct from an api point of view, but there is no real good use case
// where the system would ask for the catalog for a date prior any catalog was uploaded and
// yet time manipulation could end of inn that state -- see https://github.com/killbill/killbill/issues/760
- if (versions.size() > 0) {
+ if (!versions.isEmpty()) {
return 0;
}
throw new CatalogApiException(ErrorCode.CAT_NO_CATALOG_FOR_GIVEN_DATE, date.toString());
}
- private class PlanRequestWrapper {
-
- private final PlanSpecifier spec;
- private final PlanPhasePriceOverridesWithCallContext overrides;
-
- public PlanRequestWrapper(final String planName) {
- this.spec = new PlanSpecifier(planName);
- this.overrides = null;
- }
-
- public PlanRequestWrapper(final PlanSpecifier spec,
- final PlanPhasePriceOverridesWithCallContext overrides) {
- this.spec = spec;
- this.overrides = overrides;
- }
-
-
- public Plan findPlan(final StandaloneCatalog catalog) throws CatalogApiException {
- return catalog.createOrFindCurrentPlan(spec, overrides);
- }
-
- public PlanSpecifier getSpec() {
- return spec;
- }
- }
-
private CatalogPlanEntry findCatalogPlanEntry(final PlanRequestWrapper wrapper,
final DateTime requestedDate,
final DateTime subscriptionStartDate) throws CatalogApiException {
@@ -180,7 +153,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
}
}
-
final boolean oldestCatalog = (i == 0);
final DateTime catalogEffectiveDate = CatalogDateHelper.toUTCDateTime(c.getEffectiveDate());
final boolean catalogOlderThanSubscriptionStartDate = !subscriptionStartDate.isBefore(catalogEffectiveDate);
@@ -212,26 +184,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
spec.getPriceListName() != null ? spec.getPriceListName() : "undefined");
}
- private static class CatalogPlanEntry {
-
- private final StaticCatalog staticCatalog;
- private final Plan plan;
-
- public CatalogPlanEntry(final StaticCatalog staticCatalog, final Plan plan) {
- this.staticCatalog = staticCatalog;
- this.plan = plan;
- }
-
- public StaticCatalog getStaticCatalog() {
- return staticCatalog;
- }
-
- public Plan getPlan() {
- return plan;
- }
- }
-
-
public Clock getClock() {
return clock;
}
@@ -243,13 +195,13 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
//
// Public methods not exposed in interface
//
- public void addAll(final List<StandaloneCatalog> inputVersions) throws CatalogApiException {
+ public void addAll(final Iterable<StandaloneCatalog> inputVersions) {
for (final StandaloneCatalog cur : inputVersions) {
add(cur);
}
}
- public void add(final StandaloneCatalog e) throws CatalogApiException {
+ public void add(final StandaloneCatalog e) {
if (catalogName == null && e.getCatalogName() != null) {
catalogName = e.getCatalogName();
}
@@ -270,9 +222,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
return versions.size();
}
- //
- // Simple getters
- //
@Override
public String getCatalogName() {
return catalogName;
@@ -303,9 +252,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
return versionForDate(requestedDate).getPriceLists();
}
- //
- // Find a plan
- //
@Override
public Plan findPlan(final String name,
final DateTime requestedDate)
@@ -336,21 +282,15 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
final DateTime requestedDate,
final DateTime subscriptionStartDate)
throws CatalogApiException {
- final CatalogPlanEntry entry = findCatalogPlanEntry(new PlanRequestWrapper(spec, overrides), requestedDate, subscriptionStartDate);
+ final CatalogPlanEntry entry = findCatalogPlanEntry(new PlanRequestWrapper(spec, overrides), requestedDate, subscriptionStartDate);
return entry.getPlan();
}
- //
- // Find a product
- //
@Override
public Product findProduct(final String name, final DateTime requestedDate) throws CatalogApiException {
return versionForDate(requestedDate).findCurrentProduct(name);
}
- //
- // Find a phase
- //
@Override
public PlanPhase findPhase(final String phaseName,
final DateTime requestedDate,
@@ -361,9 +301,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
return plan.findPhase(phaseName);
}
- //
- // Find a price list associated to a given subscription
- //
@Override
public PriceList findPriceListForPlan(final String planName,
final DateTime requestedDate,
@@ -373,22 +310,11 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
return entry.getStaticCatalog().findCurrentPricelist(entry.getPlan().getPriceListName());
}
-
public PriceList findPriceList(final String name, final DateTime requestedDate)
throws CatalogApiException {
return versionForDate(requestedDate).findCurrentPriceList(name);
}
-
- //
- // Rules
- //
- @Override
- public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from,
- final PlanSpecifier to, final DateTime requestedDate) throws CatalogApiException {
- return versionForDate(requestedDate).planChangePolicy(from, to);
- }
-
@Override
public BillingActionPolicy planCancelPolicy(final PlanPhaseSpecifier planPhase, final DateTime requestedDate) throws CatalogApiException {
return versionForDate(requestedDate).planCancelPolicy(planPhase);
@@ -417,15 +343,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
}
@Override
- public boolean canCreatePlan(final PlanSpecifier specifier, final DateTime requestedDate)
- throws CatalogApiException {
- return versionForDate(requestedDate).canCreatePlan(specifier);
- }
-
- //
- // VerifiableConfig API
- //
- @Override
public void initialize(final VersionedCatalog catalog, final URI sourceURI) {
//
// Initialization is performed first on each StandaloneCatalog (XMLLoader#initializeAndValidate)
@@ -438,13 +355,12 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
@Override
public ValidationErrors validate(final VersionedCatalog catalog, final ValidationErrors errors) {
-
final Set<Date> effectiveDates = new TreeSet<Date>();
for (final StandaloneCatalog c : versions) {
if (effectiveDates.contains(c.getEffectiveDate())) {
errors.add(new ValidationError(String.format("Catalog effective date '%s' already exists for a previous version", c.getEffectiveDate()),
- c.getCatalogURI(), VersionedCatalog.class, ""));
+ c.getCatalogURI(), VersionedCatalog.class, ""));
} else {
effectiveDates.add(c.getEffectiveDate());
}
@@ -517,12 +433,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
}
@Override
- public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from,
- final PlanSpecifier to) throws CatalogApiException {
- return versionForDate(clock.getUTCNow()).planChangePolicy(from, to);
- }
-
- @Override
public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to)
throws CatalogApiException {
return versionForDate(clock.getUTCNow()).planChange(from, to);
@@ -553,12 +463,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
}
@Override
- public boolean canCreatePlan(final PlanSpecifier specifier)
- throws CatalogApiException {
- return versionForDate(clock.getUTCNow()).canCreatePlan(specifier);
- }
-
- @Override
public List<Listing> getAvailableAddOnListings(final String baseProductName, @Nullable final String priceListName) throws CatalogApiException {
return versionForDate(clock.getUTCNow()).getAvailableAddOnListings(baseProductName, priceListName);
}
@@ -569,11 +473,6 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
}
@Override
- public boolean compliesWithLimits(final String phaseName, final String unit, final double value) throws CatalogApiException {
- return versionForDate(clock.getUTCNow()).compliesWithLimits(phaseName, unit, value);
- }
-
- @Override
public void readExternal(final ObjectInput in) throws IOException {
MapperHolder.mapper().readerForUpdating(this).readValue(new ExternalizableInput(in));
}
@@ -582,4 +481,48 @@ public class VersionedCatalog extends ValidatingConfig<VersionedCatalog> impleme
public void writeExternal(final ObjectOutput oo) throws IOException {
MapperHolder.mapper().writeValue(new ExternalizableOutput(oo), this);
}
+
+ private static class CatalogPlanEntry {
+
+ private final StaticCatalog staticCatalog;
+ private final Plan plan;
+
+ public CatalogPlanEntry(final StaticCatalog staticCatalog, final Plan plan) {
+ this.staticCatalog = staticCatalog;
+ this.plan = plan;
+ }
+
+ public StaticCatalog getStaticCatalog() {
+ return staticCatalog;
+ }
+
+ public Plan getPlan() {
+ return plan;
+ }
+ }
+
+ private class PlanRequestWrapper {
+
+ private final PlanSpecifier spec;
+ private final PlanPhasePriceOverridesWithCallContext overrides;
+
+ public PlanRequestWrapper(final String planName) {
+ this.spec = new PlanSpecifier(planName);
+ this.overrides = null;
+ }
+
+ public PlanRequestWrapper(final PlanSpecifier spec,
+ final PlanPhasePriceOverridesWithCallContext overrides) {
+ this.spec = spec;
+ this.overrides = overrides;
+ }
+
+ public Plan findPlan(final StandaloneCatalog catalog) throws CatalogApiException {
+ return catalog.createOrFindCurrentPlan(spec, overrides);
+ }
+
+ public PlanSpecifier getSpec() {
+ return spec;
+ }
+ }
}
diff --git a/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java b/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
index 1744d0d..ff6c7e9 100644
--- a/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
+++ b/catalog/src/test/java/org/killbill/billing/catalog/MockCatalog.java
@@ -1,7 +1,9 @@
/*
* Copyright 2010-2013 Ning, Inc.
+ * Copyright 2014-2018 Groupon, Inc
+ * Copyright 2014-2018 The Billing Project, LLC
*
- * Ning licenses this file to you under the Apache License, version 2.0
+ * The Billing Project licenses this file to you under the Apache License, version 2.0
* (the "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
*
@@ -17,18 +19,14 @@
package org.killbill.billing.catalog;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.Iterator;
-import java.util.LinkedList;
import org.joda.time.DateTime;
import org.killbill.billing.catalog.api.BillingActionPolicy;
import org.killbill.billing.catalog.api.BillingAlignment;
import org.killbill.billing.catalog.api.Catalog;
import org.killbill.billing.catalog.api.CatalogApiException;
-import org.killbill.billing.catalog.api.CatalogEntity;
import org.killbill.billing.catalog.api.Currency;
import org.killbill.billing.catalog.api.Plan;
import org.killbill.billing.catalog.api.PlanAlignmentChange;
@@ -42,18 +40,10 @@ import org.killbill.billing.catalog.api.PriceList;
import org.killbill.billing.catalog.api.PriceListSet;
import org.killbill.billing.catalog.api.Product;
import org.killbill.billing.catalog.api.Unit;
-import org.killbill.billing.catalog.rules.DefaultCaseCancelPolicy;
-import org.killbill.billing.catalog.rules.DefaultCaseChangePlanAlignment;
-import org.killbill.billing.catalog.rules.DefaultCaseChangePlanPolicy;
-import org.killbill.billing.catalog.rules.DefaultCaseCreateAlignment;
import org.killbill.billing.catalog.rules.DefaultPlanRules;
-import com.google.common.collect.ImmutableList;
-
public class MockCatalog extends StandaloneCatalog implements Catalog {
- private static final String[] PRODUCT_NAMES = new String[]{"TestProduct1", "TestProduct2", "TestProduct3"};
- private boolean canCreatePlan;
private PlanChangeResult planChange;
private BillingAlignment billingAlignment;
private PlanAlignmentCreate planCreateAlignment;
@@ -70,15 +60,6 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
setPlanRules(new DefaultPlanRules());
}
- public void setRules(
- final DefaultCaseChangePlanPolicy[] caseChangePlanPolicy,
- final DefaultCaseChangePlanAlignment[] caseChangePlanAlignment,
- final DefaultCaseCancelPolicy[] caseCancelPolicy,
- final DefaultCaseCreateAlignment[] caseCreateAlignment
- ) {
-
- }
-
public void populatePriceLists() {
final Collection<Plan> plans = getCurrentPlans();
@@ -88,7 +69,7 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
final Plan initialPlan = it.next();
while (it.hasNext()) {
final Plan plan = it.next();
- priceList[i - 1] = new DefaultPriceList(new DefaultPlan[] { (DefaultPlan) plan}, plan.getName() + "-pl");
+ priceList[i - 1] = new DefaultPriceList(new DefaultPlan[]{(DefaultPlan) plan}, plan.getName() + "-pl");
i++;
}
@@ -96,37 +77,33 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
setPriceLists(set);
}
- public String[] getProductNames() {
- return PRODUCT_NAMES;
- }
-
@Override
- public Date getStandaloneCatalogEffectiveDate(final DateTime dateTime) throws CatalogApiException {
+ public Date getStandaloneCatalogEffectiveDate(final DateTime dateTime) {
return getEffectiveDate();
}
@Override
- public Currency[] getSupportedCurrencies(final DateTime requestedDate) throws CatalogApiException {
+ public Currency[] getSupportedCurrencies(final DateTime requestedDate) {
return getCurrentSupportedCurrencies();
}
@Override
- public Unit[] getUnits(final DateTime requestedDate) throws CatalogApiException {
+ public Unit[] getUnits(final DateTime requestedDate) {
return getCurrentUnits();
}
@Override
- public Collection<Product> getProducts(final DateTime requestedDate) throws CatalogApiException {
+ public Collection<Product> getProducts(final DateTime requestedDate) {
return getCurrentProducts();
}
@Override
- public Collection<Plan> getPlans(final DateTime requestedDate) throws CatalogApiException {
+ public Collection<Plan> getPlans(final DateTime requestedDate) {
return getCurrentPlans();
}
@Override
- public PriceListSet getPriceLists(final DateTime dateTime) throws CatalogApiException {
+ public PriceListSet getPriceLists(final DateTime dateTime) {
return getPriceLists();
}
@@ -136,7 +113,7 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public Plan createOrFindPlan(final PlanSpecifier spec, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate)
+ public Plan createOrFindPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate)
throws CatalogApiException {
return createOrFindCurrentPlan(spec, overrides);
}
@@ -148,8 +125,8 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public Plan createOrFindPlan(final PlanSpecifier spec, PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate,
- final DateTime subscriptionStartDate) throws CatalogApiException {
+ public Plan createOrFindPlan(final PlanSpecifier spec, final PlanPhasePriceOverridesWithCallContext overrides, final DateTime requestedDate,
+ final DateTime subscriptionStartDate) throws CatalogApiException {
return createOrFindCurrentPlan(spec, overrides);
}
@@ -175,14 +152,7 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public BillingActionPolicy planChangePolicy(final PlanPhaseSpecifier from, final PlanSpecifier to, final DateTime requestedDate)
- throws CatalogApiException {
- return planChangePolicy(from, to);
- }
-
- @Override
- public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final DateTime requestedDate)
- throws CatalogApiException {
+ public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to, final DateTime requestedDate) {
return planChange(from, to);
}
@@ -193,14 +163,12 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier, final DateTime requestedDate)
- throws CatalogApiException {
+ public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier, final DateTime requestedDate) {
return planCreateAlignment(specifier);
}
@Override
- public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase, final DateTime requestedDate)
- throws CatalogApiException {
+ public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase, final DateTime requestedDate) {
return billingAlignment(planPhase);
}
@@ -211,16 +179,6 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public boolean canCreatePlan(final PlanSpecifier specifier, final DateTime requestedDate) throws CatalogApiException {
- return canCreatePlan(specifier);
- }
-
- @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);
@@ -232,46 +190,24 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
}
@Override
- public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier) throws CatalogApiException {
+ public PlanAlignmentCreate planCreateAlignment(final PlanSpecifier specifier) {
return planCreateAlignment;
}
@Override
- public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase) throws CatalogApiException {
+ public BillingAlignment billingAlignment(final PlanPhaseSpecifier planPhase) {
return billingAlignment;
}
@Override
- public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to) throws CatalogApiException {
+ public PlanChangeResult planChange(final PlanPhaseSpecifier from, final PlanSpecifier to) {
return planChange;
}
- @Override
- public boolean canCreatePlan(final PlanSpecifier specifier) throws CatalogApiException {
- return canCreatePlan;
- }
-
-
- public DefaultProduct getCurrentProduct(int idx) {
+ public DefaultProduct getCurrentProduct(final int idx) {
return (DefaultProduct) getCurrentProducts().toArray()[idx];
}
- private <T extends CatalogEntity> void convertCurrentEntries(final Collection<T> unordered, final T [] result) {
- // Tests are not so well written and make assumption on how such entries are ordered
- final LinkedList<T> list = new LinkedList<T>(unordered);
- Collections.sort(list, new Comparator<T>() {
- @Override
- public int compare(final T o1, final T o2) {
- return o1.getName().compareTo(o2.getName());
- }
- });
- list.toArray(result);
- }
-
- public void setCanCreatePlan(final boolean canCreatePlan) {
- this.canCreatePlan = canCreatePlan;
- }
-
public void setPlanChange(final PlanChangeResult planChange) {
this.planChange = planChange;
}
@@ -283,5 +219,4 @@ public class MockCatalog extends StandaloneCatalog implements Catalog {
public void setPlanCreateAlignment(final PlanAlignmentCreate planCreateAlignment) {
this.planCreateAlignment = planCreateAlignment;
}
-
}
pom.xml 2(+1 -1)
diff --git a/pom.xml b/pom.xml
index 1340f45..cdf7211 100644
--- a/pom.xml
+++ b/pom.xml
@@ -21,7 +21,7 @@
<parent>
<artifactId>killbill-oss-parent</artifactId>
<groupId>org.kill-bill.billing</groupId>
- <version>0.141.67</version>
+ <version>0.141.68-SNAPSHOT</version>
</parent>
<artifactId>killbill</artifactId>
<version>0.19.16-SNAPSHOT</version>