killbill-memoizeit

Details

diff --git a/catalog/src/main/java/org/killbill/billing/catalog/rules/DefaultPlanRules.java b/catalog/src/main/java/org/killbill/billing/catalog/rules/DefaultPlanRules.java
index 07c9e84..b0e3222 100644
--- a/catalog/src/main/java/org/killbill/billing/catalog/rules/DefaultPlanRules.java
+++ b/catalog/src/main/java/org/killbill/billing/catalog/rules/DefaultPlanRules.java
@@ -108,15 +108,18 @@ public class DefaultPlanRules extends ValidatingConfig<StandaloneCatalog> implem
 
 
     public PlanAlignmentCreate getPlanCreateAlignment(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException {
-        return DefaultCase.getResult(createAlignmentCase, specifier, catalog);
+        final PlanAlignmentCreate result =  DefaultCase.getResult(createAlignmentCase, specifier, catalog);
+        return (result != null) ? result : PlanAlignmentCreate.START_OF_BUNDLE;
     }
 
     public BillingActionPolicy getPlanCancelPolicy(final PlanPhaseSpecifier planPhase, final StaticCatalog catalog) throws CatalogApiException {
-        return DefaultCasePhase.getResult(cancelCase, planPhase, catalog);
+        final BillingActionPolicy result =  DefaultCasePhase.getResult(cancelCase, planPhase, catalog);
+        return (result != null) ? result : BillingActionPolicy.END_OF_TERM;
     }
 
     public BillingAlignment getBillingAlignment(final PlanPhaseSpecifier planPhase, final StaticCatalog catalog) throws CatalogApiException {
-        return DefaultCasePhase.getResult(billingAlignmentCase, planPhase, catalog);
+        final BillingAlignment result = DefaultCasePhase.getResult(billingAlignmentCase, planPhase, catalog);
+        return (result != null) ?  result : BillingAlignment.ACCOUNT;
     }
 
     public PlanChangeResult planChange(final PlanPhaseSpecifier from, PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException {
@@ -140,7 +143,8 @@ public class DefaultPlanRules extends ValidatingConfig<StandaloneCatalog> implem
 
     public PlanAlignmentChange getPlanChangeAlignment(final PlanPhaseSpecifier from,
                                                       final PlanSpecifier to, final StaticCatalog catalog) throws CatalogApiException {
-        return DefaultCaseChange.getResult(changeAlignmentCase, from, to, catalog);
+        final PlanAlignmentChange result =  DefaultCaseChange.getResult(changeAlignmentCase, from, to, catalog);
+        return (result != null) ? result : PlanAlignmentChange.START_OF_BUNDLE;
     }
 
     public BillingActionPolicy getPlanChangePolicy(final PlanPhaseSpecifier from,
@@ -152,13 +156,13 @@ public class DefaultPlanRules extends ValidatingConfig<StandaloneCatalog> implem
         }
         //Plan toPlan = catalog.findPlan()
 
-        return DefaultCaseChange.getResult(changeCase, from, to, catalog);
+        final BillingActionPolicy result =  DefaultCaseChange.getResult(changeCase, from, to, catalog);
+        return (result != null) ? result : BillingActionPolicy.END_OF_TERM;
     }
 
     private DefaultPriceList findPriceList(final PlanSpecifier specifier, final StaticCatalog catalog) throws CatalogApiException {
         DefaultPriceList result = DefaultCase.getResult(priceListCase, specifier, catalog);
         if (result == null) {
-
             result = (DefaultPriceList) catalog.findCurrentPricelist(specifier.getPriceListName());
         }
         return result;