killbill-memoizeit
Changes
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java 15(+4 -11)
util/src/test/resources/log4j.xml 36(+36 -0)
Details
diff --git a/api/src/main/java/com/ning/billing/catalog/api/ICatalog.java b/api/src/main/java/com/ning/billing/catalog/api/ICatalog.java
index 403adec..5a5f872 100644
--- a/api/src/main/java/com/ning/billing/catalog/api/ICatalog.java
+++ b/api/src/main/java/com/ning/billing/catalog/api/ICatalog.java
@@ -22,11 +22,7 @@ import java.util.List;
public interface ICatalog {
public abstract IProduct[] getProducts();
-
- public abstract IPriceListSet getPriceLists();
-
- public abstract IPriceList getPriceListFromName(String priceListName);
-
+
public abstract IPlan getPlan(String productName, BillingPeriod term, String priceList);
public abstract Currency[] getSupportedCurrencies();
diff --git a/api/src/main/java/com/ning/billing/catalog/api/IPriceListSet.java b/api/src/main/java/com/ning/billing/catalog/api/IPriceListSet.java
index f973b9e..bbbb3c2 100644
--- a/api/src/main/java/com/ning/billing/catalog/api/IPriceListSet.java
+++ b/api/src/main/java/com/ning/billing/catalog/api/IPriceListSet.java
@@ -17,13 +17,9 @@
package com.ning.billing.catalog.api;
public interface IPriceListSet {
-
- public static final String DEFAULT_PRICELIST_NAME = "DEFAULT";
- public abstract IPriceList getDefaultPricelist();
+ public static final String DEFAULT_PRICELIST_NAME="DEFAULT";
- public abstract IPriceList[] getChildPriceLists();
-
- public abstract IPriceList getPriceListFromName(String priceListName);
+ public abstract IPlan getPlanListFrom(String priceListName, IProduct product, BillingPeriod period);
}
\ No newline at end of file
diff --git a/catalog/src/main/java/com/ning/billing/catalog/Catalog.java b/catalog/src/main/java/com/ning/billing/catalog/Catalog.java
index f588821..bc6482d 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Catalog.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Catalog.java
@@ -31,13 +31,12 @@ import com.ning.billing.catalog.api.BillingAlignment;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.ICatalog;
-import com.ning.billing.catalog.api.IPlan;
-import com.ning.billing.catalog.api.IPriceList;
import com.ning.billing.catalog.api.IProduct;
import com.ning.billing.catalog.api.PlanAlignmentChange;
import com.ning.billing.catalog.api.PlanAlignmentCreate;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PlanSpecifier;
+import com.ning.billing.catalog.rules.PlanRules;
import com.ning.billing.util.config.ValidatingConfig;
import com.ning.billing.util.config.ValidationError;
import com.ning.billing.util.config.ValidationErrors;
@@ -111,40 +110,14 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
this.products = products;
}
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.ICatalog#getPlanSets()
- */
- @Override
- public PriceListSet getPriceLists() {
- return priceLists;
- }
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.ICatalog#getPriceListFromName(java.lang.String)
- */
- @Override
- public PriceList getPriceListFromName(String priceListName) {
- return priceLists.getPriceListFromName(priceListName);
- }
-
/* (non-Javadoc)
* @see com.ning.billing.catalog.ICatalog#getPlan(java.lang.String, java.lang.String)
*/
@Override
- public Plan getPlan(String productName, BillingPeriod term, String planSetName) {
-
- PriceList planSet = getPriceListFromName(planSetName);
- if (planSet == null) {
- return null;
- }
-
- for (Plan cur : planSet.getPlans()) {
- if (cur.getProduct().getName().equals(productName) &&
- cur.getBillingPeriod() == term) {
- return cur;
- }
- }
- return null;
+ public Plan getPlan(String productName, BillingPeriod period, String priceListName) {
+ IProduct product = getProductFromName(productName);
+ return priceLists.getPlanListFrom(priceListName, product, period);
}
@Override
@@ -292,11 +265,19 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
this.priceLists = priceLists;
}
+ public PriceListSet getPriceLists() {
+ return this.priceLists;
+ }
+
@Override
public void configureEffectiveDate(Date date) {
// Nothing to do here this is a method that is only inplemented on VersionedCatalog
}
+
+ public PriceList getPriceListFromName(String priceListName) {
+ return priceLists.findPriceListFrom(priceListName);
+ }
//TODO: MDW validation - only allow one default pricelist
diff --git a/catalog/src/main/java/com/ning/billing/catalog/Plan.java b/catalog/src/main/java/com/ning/billing/catalog/Plan.java
index 1ae6199..92a2e06 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Plan.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Plan.java
@@ -63,7 +63,7 @@ public class Plan extends ValidatingConfig<Catalog> implements IPlan {
public Plan(){}
- protected Plan(String name, Product product, PlanPhase finalPhase) {
+ public Plan(String name, Product product, PlanPhase finalPhase) {
this.name = name;
this.product = product;
this.finalPhase = finalPhase;
diff --git a/catalog/src/main/java/com/ning/billing/catalog/PlanPhase.java b/catalog/src/main/java/com/ning/billing/catalog/PlanPhase.java
index 36250b4..3f43e5f 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/PlanPhase.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/PlanPhase.java
@@ -56,7 +56,7 @@ public class PlanPhase extends ValidatingConfig<Catalog> implements IPlanPhase {
public PlanPhase(){}
- protected PlanPhase(BillingPeriod period, PhaseType type) {
+ public PlanPhase(BillingPeriod period, PhaseType type) {
this.billingPeriod = period;
this.type = type;
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/PriceList.java b/catalog/src/main/java/com/ning/billing/catalog/PriceList.java
index de76149..18e21cf 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/PriceList.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/PriceList.java
@@ -18,21 +18,57 @@ package com.ning.billing.catalog;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlID;
+import javax.xml.bind.annotation.XmlIDREF;
-import com.ning.billing.catalog.api.IPlan;
-import com.ning.billing.catalog.api.IPriceList;
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.IProduct;
import com.ning.billing.util.config.ValidatingConfig;
+import com.ning.billing.util.config.ValidationErrors;
@XmlAccessorType(XmlAccessType.NONE)
-public abstract class PriceList extends ValidatingConfig<Catalog> implements IPriceList {
+public class PriceList extends ValidatingConfig<Catalog> {
+ @XmlAttribute(required=true)
@XmlID
- public abstract String getName();
+ private String name;
- public abstract Plan[] getPlans();
+ @XmlElementWrapper(name="plans", required=true)
+ @XmlElement(name="plan", required=true)
+ @XmlIDREF
+ private Plan[] plans;
+
+ public PriceList(){}
+
+ public PriceList(Plan[] plans, String name) {
+ this.plans = plans;
+ this.name = name;
+ }
+
+ protected Plan[] getPlans() {
+ return plans;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public Plan findPlan(IProduct product, BillingPeriod period) {
+ for (Plan cur : getPlans()) {
+ if (cur.getProduct().equals(product) && cur.getBillingPeriod().equals(period)) {
+ return cur;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public ValidationErrors validate(Catalog root, ValidationErrors errors) {
+ return errors;
+ }
- public abstract IPlan findPlanByProductName(String productName);
- public abstract boolean isDefault();
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/PriceListDefault.java b/catalog/src/main/java/com/ning/billing/catalog/PriceListDefault.java
index 770f391..781f44d 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/PriceListDefault.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/PriceListDefault.java
@@ -18,52 +18,28 @@ package com.ning.billing.catalog;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlIDREF;
-import com.ning.billing.catalog.api.IPriceList;
import com.ning.billing.catalog.api.IPriceListSet;
-import com.ning.billing.util.config.ValidatingConfig;
+import com.ning.billing.util.config.ValidationError;
import com.ning.billing.util.config.ValidationErrors;
@XmlAccessorType(XmlAccessType.NONE)
-public class PriceListDefault extends PriceList implements IPriceList {
-
- @XmlElementWrapper(name="plans", required=true)
- @XmlElement(name="plan", required=true)
- @XmlIDREF
- private Plan[] plans;
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPriceListDefault#getPlans()
- */
- @Override
- public Plan[] getPlans() {
- return plans;
- }
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPriceListDefault#findPlanByProductName(java.lang.String)
- */
- @Override
- public Plan findPlanByProductName(String productName) {
- for (Plan cur : plans) {
- if (cur.getProduct().getName().equals(productName)) {
- return cur;
- }
- }
- return null;
- }
-
- public void setPlans(Plan[] plans) {
- this.plans = plans;
+public class PriceListDefault extends PriceList {
+
+ public PriceListDefault(){}
+
+ public PriceListDefault(Plan[] defaultPlans) {
+ super(defaultPlans, IPriceListSet.DEFAULT_PRICELIST_NAME);
}
@Override
public ValidationErrors validate(Catalog catalog, ValidationErrors errors) {
+ if(getName().equals(IPriceListSet.DEFAULT_PRICELIST_NAME)) {
+ errors.add(new ValidationError("The name of the default pricelist must be 'DEFAULT'",
+ catalog.getCatalogURI(), PriceList.class, getName()));
+
+ }
return errors;
-
}
@Override
@@ -71,9 +47,4 @@ public class PriceListDefault extends PriceList implements IPriceList {
return IPriceListSet.DEFAULT_PRICELIST_NAME;
}
- @Override
- public boolean isDefault() {
- return true;
- }
-
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/PriceListSet.java b/catalog/src/main/java/com/ning/billing/catalog/PriceListSet.java
index 08c2cf9..7cd2986 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/PriceListSet.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/PriceListSet.java
@@ -20,76 +20,77 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
-import com.ning.billing.catalog.api.IPriceList;
+import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.IPriceListSet;
+import com.ning.billing.catalog.api.IProduct;
import com.ning.billing.util.config.ValidatingConfig;
import com.ning.billing.util.config.ValidationError;
import com.ning.billing.util.config.ValidationErrors;
@XmlAccessorType(XmlAccessType.NONE)
-public class PriceListSet extends ValidatingConfig<Catalog> implements IPriceListSet {
+public class PriceListSet extends ValidatingConfig<Catalog> {
@XmlElement(required=true, name="defaultPriceList")
private PriceListDefault defaultPricelist;
@XmlElement(required=false, name="childPriceList")
- private PriceListChild[] childPriceLists;
+ private PriceList[] childPriceLists;
public PriceListSet() {
if(childPriceLists == null) {
- childPriceLists = new PriceListChild[0];
+ childPriceLists = new PriceList[0];
}
}
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPriceListSet#getDefaultPricelist()
- */
- @Override
- public PriceListDefault getDefaultPricelist() {
- return defaultPricelist;
- }
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPriceListSet#getChildPriceLists()
- */
- @Override
- public PriceListChild[] getChildPriceLists() {
- return childPriceLists;
+
+ public PriceListSet(PriceListDefault defaultPricelist, PriceList[] childPriceLists) {
+ this.defaultPricelist = defaultPricelist;
+ this.childPriceLists = childPriceLists;
}
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPriceListSet#getPriceListFromName(String priceListName)
- */
- @Override
- public PriceList getPriceListFromName(String priceListName) {
- if(priceListName.equals(DEFAULT_PRICELIST_NAME)) {
- return getDefaultPricelist();
+ public Plan getPlanListFrom(String priceListName, IProduct product,
+ BillingPeriod period) {
+ Plan result = null;
+ PriceList pl = findPriceListFrom(priceListName);
+ if(pl != null) {
+ result = pl.findPlan(product, period);
}
- for(PriceListChild set : childPriceLists) {
- if(set.getName().equals(priceListName)) {
- return set;
- }
+ if(result != null) {
+ return result;
}
- return null;
+
+ return defaultPricelist.findPlan(product, period);
}
-
-
- public void setDefaultPricelist(PriceListDefault defaultPricelist) {
- this.defaultPricelist = defaultPricelist;
- }
-
- public void setChildPriceLists(PriceListChild[] childPriceLists) {
- this.childPriceLists = childPriceLists;
+ public PriceList findPriceListFrom (String priceListName) {
+ if (defaultPricelist.getName().equals(priceListName)) {
+ return defaultPricelist;
+ }
+ for(PriceList pl : childPriceLists) {
+ if(pl.getName().equals(priceListName)) {
+ return pl;
+ }
+ }
+ return null;
}
@Override
public ValidationErrors validate(Catalog root, ValidationErrors errors) {
//Check that the default pricelist name is not in use in the children
- for(PriceListChild pl : childPriceLists) {
- if(pl.getName().equals(DEFAULT_PRICELIST_NAME)){
- errors.add(new ValidationError("Pricelists cannot use the reserved name '" + DEFAULT_PRICELIST_NAME + "'", root.getCatalogURI(), PriceListSet.class, pl.getName()));
+ for(PriceList pl : childPriceLists) {
+ if(pl.getName().equals(IPriceListSet.DEFAULT_PRICELIST_NAME)){
+ errors.add(new ValidationError("Pricelists cannot use the reserved name '" + IPriceListSet.DEFAULT_PRICELIST_NAME + "'", root.getCatalogURI(), PriceListSet.class, pl.getName()));
}
}
return errors;
}
+
+ public PriceList getDefaultPricelist() {
+ return defaultPricelist;
+ }
+
+ public PriceList[] getChildPriceLists() {
+ return childPriceLists;
+ }
+
+
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/Product.java b/catalog/src/main/java/com/ning/billing/catalog/Product.java
index 176b8d4..371c4be 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Product.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Product.java
@@ -76,7 +76,7 @@ public class Product extends ValidatingConfig<Catalog> implements IProduct {
public Product() {
}
- protected Product(String name, ProductCategory category) {
+ public Product(String name, ProductCategory category) {
this.category = category;
this.name = name;
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/rules/CasePriceList.java b/catalog/src/main/java/com/ning/billing/catalog/rules/CasePriceList.java
new file mode 100644
index 0000000..ccd0f87
--- /dev/null
+++ b/catalog/src/main/java/com/ning/billing/catalog/rules/CasePriceList.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2010-2011 Ning, Inc.
+ *
+ * Ning 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.catalog.rules;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlIDREF;
+
+import com.ning.billing.catalog.PriceList;
+import com.ning.billing.catalog.Product;
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.ProductCategory;
+
+public class CasePriceList extends Case<PriceList> {
+
+ private PriceList toPriceList;
+
+ @XmlElement(required=false, name="fromProduct")
+ @XmlIDREF
+ public Product getProduct(){
+ return product;
+ }
+
+ @XmlElement(required=false, name="fromProductCategory")
+ public ProductCategory getProductCategory() {
+ return productCategory;
+ }
+
+ @XmlElement(required=false, name="fromBillingPeriod")
+ public BillingPeriod getBillingPeriod() {
+ return billingPeriod;
+ }
+
+ @XmlElement(required=false, name="fromPriceList")
+ @XmlIDREF
+ public PriceList getPriceList() {
+ return priceList;
+ }
+
+ @Override
+ @XmlElement(required=true, name="toPriceList")
+ @XmlIDREF
+ protected PriceList getResult() {
+ return toPriceList;
+ }
+}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/rules/CaseStandardNaming.java b/catalog/src/main/java/com/ning/billing/catalog/rules/CaseStandardNaming.java
new file mode 100644
index 0000000..3b20634
--- /dev/null
+++ b/catalog/src/main/java/com/ning/billing/catalog/rules/CaseStandardNaming.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2010-2011 Ning, Inc.
+ *
+ * Ning 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.catalog.rules;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlIDREF;
+
+import com.ning.billing.catalog.PriceList;
+import com.ning.billing.catalog.Product;
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.ProductCategory;
+
+public abstract class CaseStandardNaming<T> extends Case<T> {
+
+ public CaseStandardNaming() {}
+
+ public CaseStandardNaming(Product product, ProductCategory productCategory,
+ BillingPeriod billingPeriod, PriceList priceList, T result) {
+ super(product, productCategory, billingPeriod, priceList, result);
+ }
+
+ @XmlElement(required=false, name="product")
+ @XmlIDREF
+ public Product getProduct(){
+ return product;
+ }
+
+ @XmlElement(required=false, name="productCategory")
+ public ProductCategory getProductCategory() {
+ return productCategory;
+ }
+
+ @XmlElement(required=false, name="billingPeriod")
+ public BillingPeriod getBillingPeriod() {
+ return billingPeriod;
+ }
+
+ @XmlElement(required=false, name="priceList")
+ @XmlIDREF
+ public PriceList getPriceList() {
+ return priceList;
+ }
+
+}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java b/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java
index 676123b..288c3df 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java
@@ -30,7 +30,6 @@ import com.ning.billing.catalog.api.Currency;
import com.ning.billing.catalog.api.ICatalog;
import com.ning.billing.catalog.api.IPlan;
import com.ning.billing.catalog.api.IPlanPhase;
-import com.ning.billing.catalog.api.IPriceList;
import com.ning.billing.catalog.api.IProduct;
import com.ning.billing.catalog.api.PlanAlignmentChange;
import com.ning.billing.catalog.api.PlanAlignmentCreate;
@@ -94,16 +93,6 @@ public class VersionedCatalog extends ValidatingConfig<Catalog> implements ICata
}
@Override
- public PriceListSet getPriceLists() {
- return currentCatalog.getPriceLists();
- }
-
- @Override
- public IPriceList getPriceListFromName(String planSetName) {
- return currentCatalog.getPriceListFromName(planSetName);
- }
-
- @Override
public IPlan getPlan(String productName, BillingPeriod term,
String planSetName) {
return currentCatalog.getPlan(productName, term, planSetName);
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestPriceListSet.java b/catalog/src/test/java/com/ning/billing/catalog/TestPriceListSet.java
new file mode 100644
index 0000000..fad50a8
--- /dev/null
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestPriceListSet.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2010-2011 Ning, Inc.
+ *
+ * Ning 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:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.ning.billing.catalog;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.IPriceListSet;
+import com.ning.billing.catalog.api.PhaseType;
+import com.ning.billing.catalog.api.ProductCategory;
+
+public class TestPriceListSet {
+ @Test(enabled=true)
+ public void testOverriding() {
+ Product foo = new Product("Foo", ProductCategory.BASE);
+ Product bar = new Product("Bar", ProductCategory.BASE);
+ Plan[] defaultPlans = new Plan[]{
+ new Plan("plan-foo-monthly", foo, new PlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN)),
+ new Plan("plan-bar-monthly", bar, new PlanPhase(BillingPeriod.MONTHLY, PhaseType.EVERGREEN)),
+ new Plan("plan-foo-annual", foo, new PlanPhase(BillingPeriod.ANNUAL, PhaseType.EVERGREEN)),
+ new Plan("plan-bar-annual", bar, new PlanPhase(BillingPeriod.ANNUAL, PhaseType.EVERGREEN))
+ };
+ Plan[] childPlans = new Plan[]{
+ new Plan("plan-foo", foo, new PlanPhase(BillingPeriod.ANNUAL, PhaseType.DISCOUNT)),
+ new Plan("plan-bar", bar, new PlanPhase(BillingPeriod.ANNUAL, PhaseType.DISCOUNT))
+ };
+ PriceListDefault defaultPriceList = new PriceListDefault(defaultPlans);
+ PriceList[] childPriceLists = new PriceList[] {
+ new PriceList(childPlans, "child")
+ };
+ PriceListSet set = new PriceListSet(defaultPriceList, childPriceLists);
+
+ Assert.assertEquals(set.getPlanListFrom(IPriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN);
+ Assert.assertEquals(set.getPlanListFrom(IPriceListSet.DEFAULT_PRICELIST_NAME, foo, BillingPeriod.MONTHLY).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN);
+ Assert.assertEquals(set.getPlanListFrom("child", foo, BillingPeriod.ANNUAL).getFinalPhase().getPhaseType(), PhaseType.DISCOUNT);
+ Assert.assertEquals(set.getPlanListFrom("child", foo, BillingPeriod.MONTHLY).getFinalPhase().getPhaseType(), PhaseType.EVERGREEN);
+ }
+}
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java b/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
index 4515af1..fc456ac 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestVersionedCatalog.java
@@ -30,6 +30,8 @@ import org.testng.annotations.Test;
import org.xml.sax.SAXException;
import com.google.common.io.Resources;
+import com.ning.billing.catalog.Catalog;
+import com.ning.billing.catalog.VersionedCatalog;
import com.ning.billing.catalog.api.InvalidConfigException;
import com.ning.billing.catalog.io.VersionedCatalogLoader;
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml
index ccba4c0..2214b04 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml
@@ -153,7 +153,7 @@
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
index e97d5ba..7d0e1b8 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
@@ -16,7 +16,7 @@
-->
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../../main/resources/CatalogSchema.xsd ">
+ xsi:noNamespaceSchemaLocation="../CatalogSchema.xsd ">
<effectiveDate>2011-02-02T00:00:00+00:00</effectiveDate>
<catalogName>WeaponsHireSmall</catalogName>
@@ -153,7 +153,7 @@
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
index 568ec5e..070adbe 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
@@ -16,7 +16,7 @@
-->
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../../main/resources/CatalogSchema.xsd ">
+ xsi:noNamespaceSchemaLocation="../CatalogSchema.xsd ">
<effectiveDate>2011-03-03T00:00:00+00:00</effectiveDate>
<catalogName>WeaponsHireSmall</catalogName>
@@ -153,7 +153,7 @@
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/catalog/src/test/resources/WeaponsHire.xml b/catalog/src/test/resources/WeaponsHire.xml
index e9c041b..cfd445b 100644
--- a/catalog/src/test/resources/WeaponsHire.xml
+++ b/catalog/src/test/resources/WeaponsHire.xml
@@ -152,6 +152,10 @@ Use Cases to do:
<productCategory>ADD_ON</productCategory>
<alignment>BUNDLE</alignment>
</billingAlignmentCase>
+ <priceListCase>
+ <fromPriceList>rescue</fromPriceList>
+ <toPriceList>DEFAULT</toPriceList>
+ </priceListCase>
</rules>
<plans>
@@ -549,7 +553,7 @@ Use Cases to do:
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/catalog/src/test/resources/WeaponsHireSmall.xml b/catalog/src/test/resources/WeaponsHireSmall.xml
index c6b25da..c4a098d 100644
--- a/catalog/src/test/resources/WeaponsHireSmall.xml
+++ b/catalog/src/test/resources/WeaponsHireSmall.xml
@@ -153,7 +153,7 @@
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/api/user/EntitlementUserApi.java b/entitlement/src/main/java/com/ning/billing/entitlement/api/user/EntitlementUserApi.java
index e46bc69..19f2ec8 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/api/user/EntitlementUserApi.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/api/user/EntitlementUserApi.java
@@ -28,12 +28,9 @@ import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.ICatalog;
import com.ning.billing.catalog.api.IPlan;
import com.ning.billing.catalog.api.IPlanPhase;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.entitlement.alignment.IPlanAligner;
import com.ning.billing.entitlement.alignment.IPlanAligner.TimedPhase;
-import com.ning.billing.entitlement.api.user.IApiListener;
-import com.ning.billing.entitlement.api.user.ISubscription;
-import com.ning.billing.entitlement.api.user.ISubscriptionBundle;
-import com.ning.billing.entitlement.api.user.IEntitlementUserApi;
import com.ning.billing.entitlement.engine.core.Engine;
import com.ning.billing.entitlement.engine.dao.IEntitlementDao;
import com.ning.billing.entitlement.events.IEvent;
@@ -106,7 +103,7 @@ public class EntitlementUserApi implements IEntitlementUserApi {
BillingPeriod term, String priceList, DateTime requestedDate) throws EntitlementUserApiException {
// STEPH Should really get 'standard' from catalog
- String realPriceList = (priceList == null) ? "standard" : priceList;
+ String realPriceList = (priceList == null) ? IPriceListSet.DEFAULT_PRICELIST_NAME : priceList;
DateTime now = clock.getUTCNow();
if (requestedDate != null && requestedDate.isAfter(now)) {
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
index c781fd7..6a8dee2 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancel.java
@@ -17,26 +17,21 @@
package com.ning.billing.entitlement.api.user;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
-import static org.testng.Assert.assertFalse;
import java.util.List;
import org.joda.time.DateTime;
import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import com.ning.billing.catalog.PriceListSet;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.IDuration;
import com.ning.billing.catalog.api.IPlan;
import com.ning.billing.catalog.api.IPlanPhase;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.catalog.api.PhaseType;
-import com.ning.billing.catalog.api.TimeUnit;
import com.ning.billing.entitlement.api.ApiTestListener.NextEvent;
import com.ning.billing.util.clock.Clock;
@@ -52,7 +47,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSet = IPriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -91,7 +86,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSet = IPriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -144,7 +139,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSet = IPriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -188,7 +183,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSet = IPriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
index 670ac6d..373db87 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlan.java
@@ -26,23 +26,16 @@ import java.util.List;
import org.joda.time.DateTime;
import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import com.ning.billing.account.api.IAccount;
-import com.ning.billing.catalog.PriceListSet;
import com.ning.billing.catalog.api.BillingPeriod;
-import com.ning.billing.catalog.api.ICatalog;
import com.ning.billing.catalog.api.IDuration;
import com.ning.billing.catalog.api.IPlan;
import com.ning.billing.catalog.api.IPlanPhase;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.catalog.api.PhaseType;
-import com.ning.billing.catalog.api.PlanAlignmentChange;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.entitlement.api.ApiTestListener.NextEvent;
import com.ning.billing.entitlement.events.IEvent;
-import com.ning.billing.entitlement.events.phase.IPhaseEvent;
import com.ning.billing.entitlement.events.user.IUserEvent;
import com.ning.billing.util.clock.Clock;
@@ -67,7 +60,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanBundleAlignEOTWithNoChargeThroughDateReal() {
- tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
+ tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME, "Pistol", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME);
}
@@ -171,7 +164,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanBundleAlignIMMReal() {
- tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
+ tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME);
}
@@ -213,7 +206,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanChangePlanAlignEOTWithChargeThroughDateReal() {
- tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue");
+ tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.ANNUAL, "rescue");
}
private void tChangePlanChangePlanAlignEOTWithChargeThroughDate(String fromProd, BillingPeriod fromTerm, String fromPlanSet,
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
index ade73dc..64f69c3 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreate.java
@@ -24,16 +24,12 @@ import java.util.List;
import org.joda.time.DateTime;
import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-import com.ning.billing.catalog.PriceListSet;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.IPlan;
import com.ning.billing.catalog.api.IPlanPhase;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.catalog.api.PhaseType;
-import com.ning.billing.catalog.api.PlanAlignmentChange;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.entitlement.api.ApiTestListener.NextEvent;
import com.ning.billing.entitlement.events.IEvent;
@@ -52,7 +48,7 @@ public abstract class TestUserApiCreate extends TestUserApiBase {
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSetName = IPriceListSet.DEFAULT_PRICELIST_NAME;
testListener.pushExpectedEvent(NextEvent.CREATE);
@@ -164,7 +160,7 @@ public abstract class TestUserApiCreate extends TestUserApiBase {
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.ANNUAL;
- String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
+ String planSetName = IPriceListSet.DEFAULT_PRICELIST_NAME;
testListener.pushExpectedEvent(NextEvent.CREATE);
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
index 6599f57..520ddbe 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiError.java
@@ -29,10 +29,10 @@ import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
import com.ning.billing.ErrorCode;
-import com.ning.billing.catalog.PriceListSet;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.IDuration;
import com.ning.billing.catalog.api.IPlanPhase;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.entitlement.api.ApiTestListener.NextEvent;
import com.ning.billing.entitlement.glue.EngineModuleMemoryMock;
import com.ning.billing.util.clock.Clock;
@@ -58,10 +58,10 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testCreateSubscriptionBadCatalog() {
// WRONG PRODUTCS
- tCreateSubscriptionInternal(bundle.getId(), null, BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
- tCreateSubscriptionInternal(bundle.getId(), "Whatever", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
+ tCreateSubscriptionInternal(bundle.getId(), null, BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
+ tCreateSubscriptionInternal(bundle.getId(), "Whatever", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
// WRONG BILLING PERIOD
- tCreateSubscriptionInternal(bundle.getId(), "Shotgun", null, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
+ tCreateSubscriptionInternal(bundle.getId(), "Shotgun", null, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BAD_CATALOG);
// WRONG PLAN SET
tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, null, ErrorCode.ENT_CREATE_BAD_CATALOG);
tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, "Whatever", ErrorCode.ENT_CREATE_BAD_CATALOG);
@@ -70,19 +70,19 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testCreateSubscriptionNoBundle() {
- tCreateSubscriptionInternal(null, "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BUNDLE);
+ tCreateSubscriptionInternal(null, "Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BUNDLE);
}
@Test(enabled=false)
public void testCreateSubscriptionNoBP() {
- //tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BP);
+ //tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BP);
}
@Test(enabled=true)
public void testCreateSubscriptionBPExists() {
try {
- createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
- tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BP_EXISTS);
+ createSubscription("Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME);
+ tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BP_EXISTS);
} catch (Exception e) {
e.printStackTrace();
Assert.assertFalse(true);
@@ -108,7 +108,7 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testChangeSubscriptionNonActive() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, IPriceListSet.DEFAULT_PRICELIST_NAME);
testListener.pushExpectedEvent(NextEvent.CANCEL);
subscription.cancel(clock.getUTCNow(), false);
@@ -132,7 +132,7 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testChangeSubscriptionFutureCancelled() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME);
// SET CTD TO CANCEL IN FUTURE
IPlanPhase trialPhase = subscription.getCurrentPhase();
@@ -167,7 +167,7 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testUncancelBadState() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, IPriceListSet.DEFAULT_PRICELIST_NAME);
try {
subscription.uncancel();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/TestEntitlementDao.java b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/TestEntitlementDao.java
index cd6da83..b2dee60 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/TestEntitlementDao.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/TestEntitlementDao.java
@@ -30,6 +30,7 @@ import com.google.inject.Injector;
import com.google.inject.Stage;
import com.ning.billing.catalog.api.BillingPeriod;
import com.ning.billing.catalog.api.IPlan;
+import com.ning.billing.catalog.api.IPriceListSet;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.entitlement.api.user.Subscription;
import com.ning.billing.entitlement.api.user.TestUserApiBase;
@@ -102,7 +103,7 @@ public class TestEntitlementDao extends TestUserApiBase {
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSetName = "standard";
+ String planSetName = IPriceListSet.DEFAULT_PRICELIST_NAME;
IPlan plan = catalog.getPlan(productName, term, planSetName);
final IEvent event = new ApiEventCreate(UUID.randomUUID(), now, now, plan.getName(), "evergreen", planSetName, now, now, 1);
diff --git a/entitlement/src/test/resources/testInput.xml b/entitlement/src/test/resources/testInput.xml
index e9c041b..cfd445b 100644
--- a/entitlement/src/test/resources/testInput.xml
+++ b/entitlement/src/test/resources/testInput.xml
@@ -152,6 +152,10 @@ Use Cases to do:
<productCategory>ADD_ON</productCategory>
<alignment>BUNDLE</alignment>
</billingAlignmentCase>
+ <priceListCase>
+ <fromPriceList>rescue</fromPriceList>
+ <toPriceList>DEFAULT</toPriceList>
+ </priceListCase>
</rules>
<plans>
@@ -549,7 +553,7 @@ Use Cases to do:
</plan>
</plans>
<priceLists>
- <defaultPriceList>
+ <defaultPriceList name="DEFAULT">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
diff --git a/util/src/main/java/com/ning/billing/util/config/XMLWriter.java b/util/src/main/java/com/ning/billing/util/config/XMLWriter.java
index 3f16e90..58e42dd 100644
--- a/util/src/main/java/com/ning/billing/util/config/XMLWriter.java
+++ b/util/src/main/java/com/ning/billing/util/config/XMLWriter.java
@@ -27,6 +27,7 @@ public class XMLWriter<T> {
public static <T> String writeXML(T object, Class<T> type) throws Exception {
JAXBContext context =JAXBContext.newInstance(type);
Marshaller marshaller = context.createMarshaller();
+ marshaller.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE );
ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_XML_SIZE_IN_BYTES);
marshaller.marshal(object, output);
diff --git a/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java b/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
index f9115a0..007c16b 100644
--- a/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
+++ b/util/src/test/java/com/ning/billing/util/config/TestXMLWriter.java
@@ -45,7 +45,7 @@ public class TestXMLWriter {
String output = XMLWriter.writeXML(test, XmlTestClass.class);
System.out.println(output);
- assertEquals(output, TEST_XML);
+ assertEquals(output.replaceAll("\\s", ""), TEST_XML.replaceAll("\\s", ""));
}
util/src/test/resources/log4j.xml 36(+36 -0)
diff --git a/util/src/test/resources/log4j.xml b/util/src/test/resources/log4j.xml
new file mode 100644
index 0000000..75abc76
--- /dev/null
+++ b/util/src/test/resources/log4j.xml
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2010-2011 Ning, Inc.
+ ~
+ ~ Ning 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:
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ ~ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ ~ License for the specific language governing permissions and limitations
+ ~ under the License.
+ -->
+
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+ <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out"/>
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%p %d{ISO8601} %X{trace} %t %c %m%n"/>
+ </layout>
+ </appender>
+
+
+ <logger name="com.ning.billing.entitlement">
+ <level value="info"/>
+ </logger>
+
+ <root>
+ <priority value="info"/>
+ <appender-ref ref="stdout"/>
+ </root>
+</log4j:configuration>