killbill-memoizeit
Changes
entitlement/src/test/resources/testInput.xml 21(+7 -14)
Details
diff --git a/api/src/main/java/com/ning/billing/catalog/api/ActionPolicy.java b/api/src/main/java/com/ning/billing/catalog/api/ActionPolicy.java
index 86b8619..4719d4d 100644
--- a/api/src/main/java/com/ning/billing/catalog/api/ActionPolicy.java
+++ b/api/src/main/java/com/ning/billing/catalog/api/ActionPolicy.java
@@ -17,6 +17,7 @@
package com.ning.billing.catalog.api;
public enum ActionPolicy {
- END_OF_TERM,
- IMMEDIATE
+ END_OF_TERM, // transition occurs at end of term
+ IMMEDIATE, // transition occurs immediately
+ ILLEGAL // transition is not allowed
}
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 f583753..403adec 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
@@ -23,7 +23,7 @@ public interface ICatalog {
public abstract IProduct[] getProducts();
- public abstract IPriceList[] getPriceLists();
+ public abstract IPriceListSet getPriceLists();
public abstract IPriceList getPriceListFromName(String priceListName);
diff --git a/api/src/main/java/com/ning/billing/catalog/api/IPriceList.java b/api/src/main/java/com/ning/billing/catalog/api/IPriceList.java
index f6a528a..44d515d 100644
--- a/api/src/main/java/com/ning/billing/catalog/api/IPriceList.java
+++ b/api/src/main/java/com/ning/billing/catalog/api/IPriceList.java
@@ -26,5 +26,6 @@ public interface IPriceList {
public abstract IPlan findPlanByProductName(String productName);
public abstract boolean isDefault();
+
}
\ No newline at end of file
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseBillingAlignment.java b/catalog/src/main/java/com/ning/billing/catalog/CaseBillingAlignment.java
index 57dd49c..698c5e4 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseBillingAlignment.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseBillingAlignment.java
@@ -31,7 +31,7 @@ public class CaseBillingAlignment extends CasePhase<BillingAlignment> {
public CaseBillingAlignment() {}
public CaseBillingAlignment(Product product, ProductCategory productCategory, BillingPeriod billingPeriod,
- PriceList priceList, PhaseType phaseType, BillingAlignment alignment) {
+ PriceListChild priceList, PhaseType phaseType, BillingAlignment alignment) {
super(product, productCategory, billingPeriod, priceList, phaseType, alignment);
this.alignment = alignment;
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseCancelPolicy.java b/catalog/src/main/java/com/ning/billing/catalog/CaseCancelPolicy.java
index 700d6be..954ec8d 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseCancelPolicy.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseCancelPolicy.java
@@ -30,7 +30,7 @@ public class CaseCancelPolicy extends CasePhase<ActionPolicy>{
public CaseCancelPolicy() {}
- public CaseCancelPolicy(Product product, ProductCategory productCategory, BillingPeriod billingPeriod, PriceList priceList,
+ public CaseCancelPolicy(Product product, ProductCategory productCategory, BillingPeriod billingPeriod, PriceListChild priceList,
PhaseType phaseType, ActionPolicy policy) {
super(product, productCategory, billingPeriod, priceList, phaseType, policy);
this.policy = policy;
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseChange.java b/catalog/src/main/java/com/ning/billing/catalog/CaseChange.java
index 3efaa2e..96b4248 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseChange.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseChange.java
@@ -22,6 +22,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlIDREF;
import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.IPriceList;
import com.ning.billing.catalog.api.PhaseType;
import com.ning.billing.catalog.api.PlanPhaseSpecifier;
import com.ning.billing.catalog.api.PlanSpecifier;
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanAlignment.java b/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanAlignment.java
index a00ebb4..7c0e02c 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanAlignment.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanAlignment.java
@@ -34,7 +34,7 @@ public class CaseChangePlanAlignment extends CaseChange<PlanAlignmentChange> {
Product from, Product to,
ProductCategory fromProductCategory, ProductCategory toProductCategory,
BillingPeriod fromBP,BillingPeriod toBP,
- PriceList fromPriceList, PriceList toPriceList,
+ PriceListChild fromPriceList, PriceListChild toPriceList,
PhaseType fromType,
PlanAlignmentChange result) {
super(from, to,
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanPolicy.java b/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanPolicy.java
index 258b9cd..050668e 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanPolicy.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseChangePlanPolicy.java
@@ -36,7 +36,7 @@ public class CaseChangePlanPolicy extends CaseChange<ActionPolicy> {
Product from, Product to,
ProductCategory fromProductCategory, ProductCategory toProductCategory,
BillingPeriod fromBP,BillingPeriod toBP,
- PriceList fromPriceList, PriceList toPriceList,
+ PriceListChild fromPriceList, PriceListChild toPriceList,
PhaseType fromType,
ActionPolicy result) {
super(from, to,
diff --git a/catalog/src/main/java/com/ning/billing/catalog/CaseCreateAlignment.java b/catalog/src/main/java/com/ning/billing/catalog/CaseCreateAlignment.java
index 69a64ca..f1dcbbc 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/CaseCreateAlignment.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/CaseCreateAlignment.java
@@ -19,6 +19,7 @@ package com.ning.billing.catalog;
import javax.xml.bind.annotation.XmlElement;
import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.IPriceList;
import com.ning.billing.catalog.api.PlanAlignmentCreate;
import com.ning.billing.catalog.api.ProductCategory;
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 684c131..f588821 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Catalog.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Catalog.java
@@ -16,6 +16,7 @@
package com.ning.billing.catalog;
+import java.net.URI;
import java.util.Collection;
import java.util.Date;
@@ -30,6 +31,8 @@ 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;
@@ -42,21 +45,13 @@ import com.ning.billing.util.config.ValidationErrors;
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
- public PlanRules getPlanRules() {
- return planRules;
- }
-
- public void setPlanRules(PlanRules planRules) {
- this.planRules = planRules;
- }
-
@XmlElement(required=true)
private Date effectiveDate;
@XmlElement(required=true)
private String catalogName;
- private String catalogURL;
+ private URI catalogURI;
@XmlElementWrapper(name="currencies", required=true)
@XmlElement(name="currency", required=true)
@@ -73,9 +68,8 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
@XmlElement(name="plan", required=true)
private Plan[] plans;
- @XmlElementWrapper(name="priceLists", required=true)
- @XmlElement(name="priceList", required=true)
- private PriceList[] priceLists;
+ @XmlElement(name="priceLists", required=true)
+ private PriceListSet priceLists;
public Catalog() {}
@@ -84,19 +78,17 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
}
@Override
- public void initialize(Catalog catalog) {
- super.initialize(catalog);
- planRules.initialize(catalog);
+ public void initialize(Catalog catalog, URI sourceURI) {
+ catalogURI = sourceURI;
+ super.initialize(catalog, sourceURI);
+ planRules.initialize(catalog, sourceURI);
+ priceLists.initialize(catalog, sourceURI);
for(Product p : products) {
- p.initialize(catalog);
+ p.initialize(catalog, sourceURI);
}
for(Plan p : plans) {
- p.initialize(catalog);
+ p.initialize(catalog, sourceURI);
}
- for(PriceList p : priceLists) {
- p.initialize(catalog);
- }
-
}
/* (non-Javadoc)
@@ -123,25 +115,16 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
* @see com.ning.billing.catalog.ICatalog#getPlanSets()
*/
@Override
- public PriceList[] getPriceLists() {
+ public PriceListSet getPriceLists() {
return priceLists;
}
- public void setPlanSets(PriceList[] planSets) {
- this.priceLists = planSets;
- }
-
/* (non-Javadoc)
* @see com.ning.billing.catalog.ICatalog#getPriceListFromName(java.lang.String)
*/
@Override
public PriceList getPriceListFromName(String priceListName) {
- for(PriceList set : priceLists) {
- if(set.getName().equals(priceListName)) {
- return set;
- }
- }
- return null;
+ return priceLists.getPriceListFromName(priceListName);
}
/* (non-Javadoc)
@@ -150,7 +133,7 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
@Override
public Plan getPlan(String productName, BillingPeriod term, String planSetName) {
- PriceList planSet = getPriceListFromName(planSetName);
+ PriceList planSet = getPriceListFromName(planSetName);
if (planSet == null) {
return null;
}
@@ -189,8 +172,8 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
@Override
public ValidationErrors validate(Catalog catalog, ValidationErrors errors) {
validate(catalog,errors, products);
- validate(catalog,errors, priceLists);
validate(catalog,errors, plans);
+ priceLists.validate(catalog,errors);
planRules.validate(catalog, errors);
return errors;
}
@@ -285,12 +268,16 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
this.effectiveDate = effectiveDate;
}
- public String getCatalogURL() {
- return catalogURL;
+ public URI getCatalogURI() {
+ return catalogURI;
+ }
+
+ public PlanRules getPlanRules() {
+ return planRules;
}
- public void setCatalogURL(String catalogURL) {
- this.catalogURL = catalogURL;
+ public void setPlanRules(PlanRules planRules) {
+ this.planRules = planRules;
}
@Override
@@ -301,7 +288,7 @@ public class Catalog extends ValidatingConfig<Catalog> implements ICatalog {
return null;
}
- public void setPriceLists(PriceList[] priceLists) {
+ public void setPriceLists(PriceListSet priceLists) {
this.priceLists = priceLists;
}
diff --git a/catalog/src/main/java/com/ning/billing/catalog/InternationalPrice.java b/catalog/src/main/java/com/ning/billing/catalog/InternationalPrice.java
index 0917266..c81c9b7 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/InternationalPrice.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/InternationalPrice.java
@@ -74,7 +74,7 @@ public class InternationalPrice extends ValidatingConfig<Catalog> implements IIn
for (IPrice p : prices) {
Currency currency = p.getCurrency();
if(!currencyIsSupported(currency, supportedCurrencies)) {
- errors.add("Unsupported currency: " + currency, catalog.getCatalogURL(), this.getClass(), "");
+ errors.add("Unsupported currency: " + currency, catalog.getCatalogURI(), this.getClass(), "");
}
}
return errors;
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 a0244b7..1ae6199 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Plan.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Plan.java
@@ -16,6 +16,7 @@
package com.ning.billing.catalog;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Iterator;
@@ -69,8 +70,8 @@ public class Plan extends ValidatingConfig<Catalog> implements IPlan {
}
@Override
- public void initialize(Catalog catalog) {
- super.initialize(catalog);
+ public void initialize(Catalog catalog, URI sourceURI) {
+ super.initialize(catalog, sourceURI);
if(finalPhase != null) {
finalPhase.setPlan(this);
}
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 2cc5cd1..de76149 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/PriceList.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/PriceList.java
@@ -18,84 +18,21 @@ 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.util.config.ValidatingConfig;
-import com.ning.billing.util.config.ValidationErrors;
@XmlAccessorType(XmlAccessType.NONE)
-public class PriceList extends ValidatingConfig<Catalog> implements IPriceList {
+public abstract class PriceList extends ValidatingConfig<Catalog> implements IPriceList {
- @XmlAttribute(required=true)
@XmlID
- private String name;
+ public abstract String getName();
- @XmlElement(required=false)
- private Boolean isDefault = false;
+ public abstract Plan[] getPlans();
- @XmlElementWrapper(name="plans", required=true)
- @XmlElement(name="plan", required=true)
- @XmlIDREF
- private Plan[] plans;
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPlanSet#getName()
- */
- @Override
- public String getName() {
- return name;
- }
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPlanSet#getPlans()
- */
- @Override
- public Plan[] getPlans() {
- return plans;
- }
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPlanSet#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 setName(String name) {
- this.name = name;
- }
-
- public void setPlans(Plan[] plans) {
- this.plans = plans;
- }
-
- /* (non-Javadoc)
- * @see com.ning.billing.catalog.IPlanSet#getProductType()
- */
- @Override
- public boolean isDefault() {
- return isDefault;
- }
-
- public void setProductType(boolean isDefault) {
- this.isDefault = isDefault;
- }
-
- @Override
- public ValidationErrors validate(Catalog catalog, 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/Product.java b/catalog/src/main/java/com/ning/billing/catalog/Product.java
index 48924d1..176b8d4 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/Product.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/Product.java
@@ -16,6 +16,8 @@
package com.ning.billing.catalog;
+import java.net.URI;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
@@ -116,7 +118,7 @@ public class Product extends ValidatingConfig<Catalog> implements IProduct {
}
@Override
- public void initialize(Catalog catalog) {
+ public void initialize(Catalog catalog, URI sourceURI) {
catalogName = catalog.getCalalogName();
}
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 f8eed4f..676123b 100644
--- a/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java
+++ b/catalog/src/main/java/com/ning/billing/catalog/VersionedCatalog.java
@@ -15,6 +15,7 @@
*/
package com.ning.billing.catalog;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -27,7 +28,9 @@ 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.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;
@@ -91,17 +94,17 @@ public class VersionedCatalog extends ValidatingConfig<Catalog> implements ICata
}
@Override
- public PriceList[] getPriceLists() {
+ public PriceListSet getPriceLists() {
return currentCatalog.getPriceLists();
}
@Override
- public PriceList getPriceListFromName(String planSetName) {
+ public IPriceList getPriceListFromName(String planSetName) {
return currentCatalog.getPriceListFromName(planSetName);
}
@Override
- public Plan getPlan(String productName, BillingPeriod term,
+ public IPlan getPlan(String productName, BillingPeriod term,
String planSetName) {
return currentCatalog.getPlan(productName, term, planSetName);
}
@@ -133,9 +136,9 @@ public class VersionedCatalog extends ValidatingConfig<Catalog> implements ICata
}
@Override
- public void initialize(Catalog catalog) {
+ public void initialize(Catalog catalog, URI sourceURI) {
for(Catalog c : versions) {
- c.initialize(catalog);
+ c.initialize(catalog, sourceURI);
}
}
diff --git a/catalog/src/test/java/com/ning/billing/catalog/MockCatalog.java b/catalog/src/test/java/com/ning/billing/catalog/MockCatalog.java
index 07a9b79..0122a62 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/MockCatalog.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/MockCatalog.java
@@ -72,13 +72,19 @@ public class MockCatalog extends Catalog {
public void populatePriceLists() {
Plan[] plans = getPlans();
- PriceList[] priceList = new PriceList[plans.length];
- for(int i = 0; i < plans.length; i++) {
- priceList[i] = new PriceList();
- priceList[i].setName(plans[i].getName()+ "-pl");
- priceList[i].setPlans(new Plan[]{plans[i]});
+ PriceListSet set = new PriceListSet();
+
+ set.setDefaultPricelist(new PriceListDefault());
+ set.getDefaultPricelist().setPlans(new Plan[]{plans[0]});
+
+ PriceListChild[] priceList = new PriceListChild[plans.length - 1];
+ for(int i = 1; i < plans.length; i++) {
+ priceList[i-1] = new PriceListChild();
+ priceList[i-1].setName(plans[i].getName()+ "-pl");
+ priceList[i-1].setPlans(new Plan[]{plans[i]});
}
- setPriceLists(priceList);
+ set.setChildPriceLists(priceList);
+ setPriceLists(set);
}
public String[] getProductNames() {
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestCase.java b/catalog/src/test/java/com/ning/billing/catalog/TestCase.java
index 5848c57..5db84d1 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestCase.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestCase.java
@@ -53,7 +53,7 @@ public class TestCase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -75,7 +75,7 @@ public class TestCase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -98,7 +98,7 @@ public class TestCase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -121,7 +121,7 @@ public class TestCase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -144,7 +144,7 @@ public class TestCase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestCaseChange.java b/catalog/src/test/java/com/ning/billing/catalog/TestCaseChange.java
index ed48ccf..cc92fad 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestCaseChange.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestCaseChange.java
@@ -64,10 +64,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -154,10 +154,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -237,10 +237,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -327,10 +327,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -417,10 +417,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -507,10 +507,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -598,10 +598,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -688,10 +688,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -778,10 +778,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
@@ -868,10 +868,10 @@ public class TestCaseChange {
MockCatalog cat = new MockCatalog();
Product product1 = cat.getProducts()[0];
- PriceList priceList1 = cat.getPriceLists()[0];
+ PriceList priceList1 = cat.getPriceLists().getDefaultPricelist();
Product product2 = cat.getProducts()[2];
- PriceList priceList2 = cat.getPriceLists()[2];
+ PriceList priceList2 = cat.getPriceLists().getChildPriceLists()[1];
CaseChangeResult cr = new CaseChangeResult(
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestCasePhase.java b/catalog/src/test/java/com/ning/billing/catalog/TestCasePhase.java
index 9d3f7cc..ea8e916 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestCasePhase.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestCasePhase.java
@@ -54,7 +54,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -78,7 +78,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -102,7 +102,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -126,7 +126,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -150,7 +150,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
@@ -174,7 +174,7 @@ public class TestCasePhase {
MockCatalog cat = new MockCatalog();
Product product = cat.getProducts()[0];
- PriceList priceList = cat.getPriceLists()[0];
+ PriceList priceList = cat.getPriceLists().getDefaultPricelist();
CaseResult cr = new CaseResult(
diff --git a/catalog/src/test/java/com/ning/billing/catalog/TestPlanRules.java b/catalog/src/test/java/com/ning/billing/catalog/TestPlanRules.java
index 6121a85..4b44163 100644
--- a/catalog/src/test/java/com/ning/billing/catalog/TestPlanRules.java
+++ b/catalog/src/test/java/com/ning/billing/catalog/TestPlanRules.java
@@ -66,8 +66,8 @@ public class TestPlanRules {
}
- protected PriceList createPriceList(String name) {
- PriceList result = new PriceList();
+ protected PriceListChild createPriceList(String name) {
+ PriceListChild result = new PriceListChild();
result.setName(name);
return result;
}
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml
index 51e68dc..ccba4c0 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-1.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-01-01T00:00:00+00:00</effectiveDate>
<catalogName>WeaponsHireSmall</catalogName>
@@ -153,13 +153,12 @@
</plan>
</plans>
<priceLists>
- <priceList name="standardBase">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
<plan>shotgun-annual</plan>
</plans>
- </priceList>
+ </defaultPriceList>
</priceLists>
</catalog>
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
index 3ad25f3..e97d5ba 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-2.xml
@@ -153,13 +153,12 @@
</plan>
</plans>
<priceLists>
- <priceList name="standardBase">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
<plan>shotgun-annual</plan>
</plans>
- </priceList>
+ </defaultPriceList>
</priceLists>
</catalog>
diff --git a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
index 20ca041..568ec5e 100644
--- a/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
+++ b/catalog/src/test/resources/versionedCatalog/WeaponsHireSmall-3.xml
@@ -153,13 +153,12 @@
</plan>
</plans>
<priceLists>
- <priceList name="standardBase">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
<plan>shotgun-annual</plan>
</plans>
- </priceList>
+ </defaultPriceList>
</priceLists>
</catalog>
diff --git a/catalog/src/test/resources/WeaponsHire.xml b/catalog/src/test/resources/WeaponsHire.xml
index a3f4e0b..e9c041b 100644
--- a/catalog/src/test/resources/WeaponsHire.xml
+++ b/catalog/src/test/resources/WeaponsHire.xml
@@ -37,7 +37,7 @@ Use Cases to do:
-->
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../main/resources/CatalogSchema.xsd ">
+ xsi:noNamespaceSchemaLocation="CatalogSchema.xsd ">
<effectiveDate>2011-10-08T00:00:00+00:00</effectiveDate>
<catalogName>Firearms</catalogName>
@@ -549,8 +549,7 @@ Use Cases to do:
</plan>
</plans>
<priceLists>
- <priceList name="standard">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
@@ -564,8 +563,8 @@ Use Cases to do:
<plan>holster-monthly-regular</plan>
<plan>refurbish-maintenance</plan>
</plans>
- </priceList>
- <priceList name="gunclubDiscount">
+ </defaultPriceList>
+ <childPriceList name="gunclubDiscount">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
@@ -575,12 +574,12 @@ Use Cases to do:
<plan>assault-rifle-annual-gunclub-discount</plan>
<plan>holster-monthly-special</plan>
</plans>
- </priceList>
- <priceList name="rescue">
+ </childPriceList>
+ <childPriceList name="rescue">
<plans>
<plan>assault-rifle-annual-rescue</plan>
</plans>
- </priceList>
+ </childPriceList>
</priceLists>
</catalog>
diff --git a/catalog/src/test/resources/WeaponsHireSmall.xml b/catalog/src/test/resources/WeaponsHireSmall.xml
index a40f4c7..c6b25da 100644
--- a/catalog/src/test/resources/WeaponsHireSmall.xml
+++ b/catalog/src/test/resources/WeaponsHireSmall.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-10-08T00:00:00+00:00</effectiveDate>
<catalogName>WeaponsHireSmall</catalogName>
@@ -153,13 +153,12 @@
</plan>
</plans>
<priceLists>
- <priceList name="standardBase">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
- <plan>pistol-monthly</plan>
- <plan>shotgun-monthly</plan>
+ <plan>pistol-monthly</plan>
+ <plan>shotgun-monthly</plan>
<plan>shotgun-annual</plan>
</plans>
- </priceList>
+ </defaultPriceList>
</priceLists>
</catalog>
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 38c55f2..05e5432 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
@@ -30,6 +30,7 @@ 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;
@@ -51,7 +52,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = "standard";
+ String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -90,7 +91,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = "standard";
+ String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -143,7 +144,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = "standard";
+ String planSet = PriceListSet.DEFAULT_PRICELIST_NAME;
// CREATE
Subscription subscription = createSubscription(prod, term, planSet);
@@ -187,7 +188,7 @@ public abstract class TestUserApiCancel extends TestUserApiBase {
String prod = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSet = "standard";
+ String planSet = PriceListSet.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 8816503..4def199 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
@@ -31,6 +31,7 @@ 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;
@@ -66,7 +67,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanBundleAlignEOTWithNoChargeThroughDateReal() {
- tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, "standard", "Pistol", BillingPeriod.MONTHLY, "standard");
+ tChangePlanBundleAlignEOTWithNoChargeThroughDate("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
}
@@ -170,7 +171,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanBundleAlignIMMReal() {
- tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, "standard", "Assault-Rifle", BillingPeriod.MONTHLY, "standard");
+ tChangePlanBundleAlignIMM("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME, "Assault-Rifle", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
}
@@ -212,7 +213,7 @@ public abstract class TestUserApiChangePlan extends TestUserApiBase {
protected void testChangePlanChangePlanAlignEOTWithChargeThroughDateReal() {
- tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, "standard", "Assault-Rifle", BillingPeriod.ANNUAL, "rescue");
+ tChangePlanChangePlanAlignEOTWithChargeThroughDate("Shotgun", BillingPeriod.ANNUAL, PriceListSet.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 44c126c..c8eac1f 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
@@ -28,6 +28,7 @@ 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;
@@ -51,7 +52,7 @@ public abstract class TestUserApiCreate extends TestUserApiBase {
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.MONTHLY;
- String planSetName = "standard";
+ String planSetName = PriceListSet.DEFAULT_PRICELIST_NAME;
testListener.pushExpectedEvent(NextEvent.CREATE);
@@ -163,7 +164,7 @@ public abstract class TestUserApiCreate extends TestUserApiBase {
String productName = "Shotgun";
BillingPeriod term = BillingPeriod.ANNUAL;
- String planSetName = "standard";
+ String planSetName = PriceListSet.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 8f22f83..1e6f454 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
@@ -17,12 +17,8 @@
package com.ning.billing.entitlement.api.user;
import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertNull;
-import static org.testng.Assert.assertTrue;
import static org.testng.Assert.assertFalse;
-
import java.util.UUID;
import org.joda.time.DateTime;
@@ -33,6 +29,7 @@ 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;
@@ -61,10 +58,10 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testCreateSubscriptionBadCatalog() {
// WRONG PRODUTCS
- tCreateSubscriptionInternal(bundle.getId(), null, BillingPeriod.ANNUAL, "standard", ErrorCode.ENT_CREATE_BAD_CATALOG);
- tCreateSubscriptionInternal(bundle.getId(), "Whatever", BillingPeriod.ANNUAL, "standard", ErrorCode.ENT_CREATE_BAD_CATALOG);
+ 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);
// WRONG BILLING PERIOD
- tCreateSubscriptionInternal(bundle.getId(), "Shotgun", null, "standard", ErrorCode.ENT_CREATE_BAD_CATALOG);
+ tCreateSubscriptionInternal(bundle.getId(), "Shotgun", null, PriceListSet.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);
@@ -73,19 +70,19 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testCreateSubscriptionNoBundle() {
- tCreateSubscriptionInternal(null, "Shotgun", BillingPeriod.ANNUAL, "standard", ErrorCode.ENT_CREATE_NO_BUNDLE);
+ tCreateSubscriptionInternal(null, "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BUNDLE);
}
@Test(enabled=false)
public void testCreateSubscriptionNoBP() {
- //tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, "standard", ErrorCode.ENT_CREATE_NO_BP);
+ //tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_NO_BP);
}
@Test(enabled=true)
public void testCreateSubscriptionBPExists() {
try {
- createSubscription("Shotgun", BillingPeriod.ANNUAL, "standard");
- tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, "standard", ErrorCode.ENT_CREATE_BP_EXISTS);
+ createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
+ tCreateSubscriptionInternal(bundle.getId(), "Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME, ErrorCode.ENT_CREATE_BP_EXISTS);
} catch (Exception e) {
e.printStackTrace();
Assert.assertFalse(true);
@@ -111,12 +108,12 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testChangeSubscriptionNonActive() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, "standard");
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.ANNUAL, PriceListSet.DEFAULT_PRICELIST_NAME);
testListener.pushExpectedEvent(NextEvent.CANCEL);
subscription.cancel();
try {
- subscription.changePlan("Pistol", BillingPeriod.MONTHLY, "standard");
+ subscription.changePlan("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
} catch (EntitlementUserApiException e) {
assertEquals(e.getCode(), ErrorCode.ENT_CHANGE_NON_ACTIVE.getCode());
try {
@@ -135,7 +132,7 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testChangeSubscriptionFutureCancelled() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, "standard");
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
// SET CTD TO CANCEL IN FUTURE
IPlanPhase trialPhase = subscription.getCurrentPhase();
@@ -147,7 +144,7 @@ public class TestUserApiError extends TestUserApiBase {
subscription.cancel();
try {
- subscription.changePlan("Pistol", BillingPeriod.MONTHLY, "standard");
+ subscription.changePlan("Pistol", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
} catch (EntitlementUserApiException e) {
assertEquals(e.getCode(), ErrorCode.ENT_CHANGE_FUTURE_CANCELLED.getCode());
try {
@@ -170,7 +167,7 @@ public class TestUserApiError extends TestUserApiBase {
@Test(enabled=true)
public void testUncancelBadState() {
try {
- ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, "standard");
+ ISubscription subscription = createSubscription("Shotgun", BillingPeriod.MONTHLY, PriceListSet.DEFAULT_PRICELIST_NAME);
try {
subscription.uncancel();
entitlement/src/test/resources/testInput.xml 21(+7 -14)
diff --git a/entitlement/src/test/resources/testInput.xml b/entitlement/src/test/resources/testInput.xml
index 59b9093..e9c041b 100644
--- a/entitlement/src/test/resources/testInput.xml
+++ b/entitlement/src/test/resources/testInput.xml
@@ -37,7 +37,7 @@ Use Cases to do:
-->
<catalog xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:noNamespaceSchemaLocation="../../main/resources/CatalogSchema.xsd ">
+ xsi:noNamespaceSchemaLocation="CatalogSchema.xsd ">
<effectiveDate>2011-10-08T00:00:00+00:00</effectiveDate>
<catalogName>Firearms</catalogName>
@@ -83,12 +83,6 @@ Use Cases to do:
<product name="Refurbish-Maintenance">
<category>ADD_ON</category>
</product>
- <product name="Bowie-Knife">
- <category>BASE</category>
- </product>
- <product name="Samuri-Sword">
- <category>BASE</category>
- </product>
</products>
<rules>
@@ -555,8 +549,7 @@ Use Cases to do:
</plan>
</plans>
<priceLists>
- <priceList name="standard">
- <isDefault>true</isDefault>
+ <defaultPriceList>
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
@@ -570,8 +563,8 @@ Use Cases to do:
<plan>holster-monthly-regular</plan>
<plan>refurbish-maintenance</plan>
</plans>
- </priceList>
- <priceList name="gunclubDiscount">
+ </defaultPriceList>
+ <childPriceList name="gunclubDiscount">
<plans>
<plan>pistol-monthly</plan>
<plan>shotgun-monthly</plan>
@@ -581,12 +574,12 @@ Use Cases to do:
<plan>assault-rifle-annual-gunclub-discount</plan>
<plan>holster-monthly-special</plan>
</plans>
- </priceList>
- <priceList name="rescue">
+ </childPriceList>
+ <childPriceList name="rescue">
<plans>
<plan>assault-rifle-annual-rescue</plan>
</plans>
- </priceList>
+ </childPriceList>
</priceLists>
</catalog>
diff --git a/util/src/main/java/com/ning/billing/util/config/ValidatingConfig.java b/util/src/main/java/com/ning/billing/util/config/ValidatingConfig.java
index 5c2b87a..34c2adc 100644
--- a/util/src/main/java/com/ning/billing/util/config/ValidatingConfig.java
+++ b/util/src/main/java/com/ning/billing/util/config/ValidatingConfig.java
@@ -17,6 +17,8 @@
package com.ning.billing.util.config;
+import java.net.URI;
+
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@@ -37,7 +39,6 @@ public abstract class ValidatingConfig<Context> {
*
* @param root
*/
- public void initialize(Context root){}
-
+ public void initialize(Context root, URI uri){}
}
diff --git a/util/src/main/java/com/ning/billing/util/config/ValidationError.java b/util/src/main/java/com/ning/billing/util/config/ValidationError.java
index e37d424..f2e2346 100644
--- a/util/src/main/java/com/ning/billing/util/config/ValidationError.java
+++ b/util/src/main/java/com/ning/billing/util/config/ValidationError.java
@@ -15,25 +15,27 @@
*/
package com.ning.billing.util.config;
+import java.net.URI;
+
public class ValidationError {
private final String description;
- private final String catalogURL;
+ private final URI sourceURI;
private final Class<?> objectType;
private final String objectName;
- public ValidationError(String description, String catalogURL,
+ public ValidationError(String description, URI sourceURI,
Class<?> objectType, String objectName) {
super();
this.description = description;
- this.catalogURL = catalogURL;
+ this.sourceURI = sourceURI;
this.objectType = objectType;
this.objectName = objectName;
}
public String getDescription() {
return description;
}
- public String getCatalogURL() {
- return catalogURL;
+ public URI getSourceURI() {
+ return sourceURI;
}
public Class<?> getObjectType() {
return objectType;
diff --git a/util/src/main/java/com/ning/billing/util/config/ValidationErrors.java b/util/src/main/java/com/ning/billing/util/config/ValidationErrors.java
index 234d022..72cf752 100644
--- a/util/src/main/java/com/ning/billing/util/config/ValidationErrors.java
+++ b/util/src/main/java/com/ning/billing/util/config/ValidationErrors.java
@@ -16,14 +16,15 @@
package com.ning.billing.util.config;
+import java.net.URI;
import java.util.ArrayList;
public class ValidationErrors extends ArrayList<ValidationError>{
private static final long serialVersionUID = 1L;
- public void add(String description, String catalogURL,
+ public void add(String description, URI catalogURI,
Class<?> objectType, String objectName) {
- add(new ValidationError(description, catalogURL, objectType, objectName));
+ add(new ValidationError(description, catalogURI, objectType, objectName));
}
diff --git a/util/src/main/java/com/ning/billing/util/config/XMLLoader.java b/util/src/main/java/com/ning/billing/util/config/XMLLoader.java
index f7dee0f..8aaaf14 100644
--- a/util/src/main/java/com/ning/billing/util/config/XMLLoader.java
+++ b/util/src/main/java/com/ning/billing/util/config/XMLLoader.java
@@ -60,7 +60,7 @@ public class XMLLoader {
return getObjectFromStream(uri, resourceStream, objectType);
} else if (scheme.equals(URI_SCHEME_FOR_FILE) &&
!uri.getSchemeSpecificPart().startsWith("/")) { // interpret URIs of this form as relative path uris
- uriToCall = new File("src/test/resources/testInput.xml").toURI();
+ uriToCall = new File(uri.getSchemeSpecificPart()).toURI();
}
return getObjectFromURL(uriToCall.toURL(), objectType);
}
@@ -93,7 +93,7 @@ public class XMLLoader {
public static <T extends ValidatingConfig<T>> void validate(URI uri, T c) {
- c.initialize(c);
+ c.initialize(c, uri);
ValidationErrors errs = c.validate(c, new ValidationErrors());
log.info("Errors: " + errs.size() + " for " + uri);
}
diff --git a/util/src/main/java/com/ning/billing/util/config/XMLSchemaGenerator.java b/util/src/main/java/com/ning/billing/util/config/XMLSchemaGenerator.java
index a1c9749..c816523 100644
--- a/util/src/main/java/com/ning/billing/util/config/XMLSchemaGenerator.java
+++ b/util/src/main/java/com/ning/billing/util/config/XMLSchemaGenerator.java
@@ -65,6 +65,13 @@ public class XMLSchemaGenerator {
System.out.println(XMLSchemaGenerator.class.getName() + " <file> <class1>");
}
+
+ public static String xmlSchemaAsString(Class<?> clazz) throws IOException, TransformerException, JAXBException {
+ ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_SCHEMA_SIZE_IN_BYTES);
+ JAXBContext context =JAXBContext.newInstance(clazz);
+ pojoToXSD(context, output);
+ return new String(output.toByteArray());
+ }
public static InputStream xmlSchema(Class<?> clazz) throws IOException, TransformerException, JAXBException {
ByteArrayOutputStream output = new ByteArrayOutputStream(MAX_SCHEMA_SIZE_IN_BYTES);