killbill-memoizeit
Changes
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java 8(+4 -4)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java 14(+8 -6)
entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java 10(+5 -5)
Details
diff --git a/entitlement/src/main/java/com/ning/billing/entitlement/glue/EntitlementModule.java b/entitlement/src/main/java/com/ning/billing/entitlement/glue/EntitlementModule.java
index 6217d83..e167807 100644
--- a/entitlement/src/main/java/com/ning/billing/entitlement/glue/EntitlementModule.java
+++ b/entitlement/src/main/java/com/ning/billing/entitlement/glue/EntitlementModule.java
@@ -30,6 +30,7 @@ import com.ning.billing.entitlement.api.migration.EntitlementMigrationApi;
import com.ning.billing.entitlement.api.user.DefaultEntitlementUserApi;
import com.ning.billing.entitlement.api.user.EntitlementUserApi;
import com.ning.billing.entitlement.api.user.SubscriptionApiService;
+import com.ning.billing.entitlement.api.user.SubscriptionFactory;
import com.ning.billing.entitlement.engine.addon.AddonUtils;
import com.ning.billing.entitlement.engine.core.Engine;
import com.ning.billing.entitlement.engine.dao.EntitlementDao;
@@ -46,6 +47,7 @@ public class EntitlementModule extends AbstractModule {
}
protected void installEntitlementCore() {
+ bind(SubscriptionFactory.class).asEagerSingleton();
bind(SubscriptionApiService.class).asEagerSingleton();
bind(EntitlementService.class).to(Engine.class).asEagerSingleton();
bind(Engine.class).asEagerSingleton();
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
index fec3550..57e34e9 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCancelMemory.java
@@ -32,25 +32,25 @@ public class TestUserApiCancelMemory extends TestUserApiCancel {
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCancelSubscriptionIMM() {
super.testCancelSubscriptionIMM();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCancelSubscriptionEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testCancelSubscriptionEOTWithChargeThroughDate();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCancelSubscriptionEOTWithNoChargeThroughDate() {
super.testCancelSubscriptionEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testUncancel() throws EntitlementBillingApiException {
super.testUncancel();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
index ab76734..0351ea1 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiChangePlanMemory.java
@@ -32,44 +32,46 @@ public class TestUserApiChangePlanMemory extends TestUserApiChangePlan {
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testChangePlanBundleAlignEOTWithNoChargeThroughDate() {
super.testChangePlanBundleAlignEOTWithNoChargeThroughDate();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testChangePlanBundleAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanBundleAlignEOTWithChargeThroughDate();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testChangePlanBundleAlignIMM() {
super.testChangePlanBundleAlignIMM();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testMultipleChangeLastIMM() throws EntitlementBillingApiException {
super.testMultipleChangeLastIMM();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testMultipleChangeLastEOT() throws EntitlementBillingApiException {
super.testMultipleChangeLastEOT();
}
+ /*
// Set to false until we implement rescue example.
@Override
@Test(enabled=false, groups={"fast"})
public void testChangePlanChangePlanAlignEOTWithChargeThroughDate() throws EntitlementBillingApiException {
super.testChangePlanChangePlanAlignEOTWithChargeThroughDate();
}
+ */
@Override
- @Test(enabled=true, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCorrectPhaseAlignmentOnChange() {
super.testCorrectPhaseAlignmentOnChange();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
index 047ca67..b674e34 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/api/user/TestUserApiCreateMemory.java
@@ -31,31 +31,31 @@ public class TestUserApiCreateMemory extends TestUserApiCreate {
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCreateWithRequestedDate() {
super.testCreateWithRequestedDate();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testCreateWithInitialPhase() {
super.testSimpleSubscriptionThroughPhases();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
public void testSimpleCreateSubscription() {
super.testSimpleCreateSubscription();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
protected void testSimpleSubscriptionThroughPhases() {
super.testSimpleSubscriptionThroughPhases();
}
@Override
- @Test(enabled=false, groups={"fast"})
+ @Test(enabled=true, groups={"fast-disabled"})
protected void testSubscriptionWithAddOn() {
super.testSubscriptionWithAddOn();
}
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
index 2336188..79f163d 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/engine/dao/MockEntitlementDaoMemory.java
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.inject.Inject;
+import com.ning.billing.catalog.api.CatalogService;
import com.ning.billing.catalog.api.ProductCategory;
import com.ning.billing.catalog.api.TimeUnit;
import com.ning.billing.config.EntitlementConfig;
@@ -64,17 +65,17 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
private final TreeSet<EntitlementEvent> events;
private final Clock clock;
private final EntitlementConfig config;
- private final SubscriptionFactory factory;
private final NotificationQueueService notificationQueueService;
+ private final CatalogService catalogService;
@Inject
public MockEntitlementDaoMemory(final Clock clock, final EntitlementConfig config,
- final SubscriptionFactory factory,
- final NotificationQueueService notificationQueueService) {
+ final NotificationQueueService notificationQueueService,
+ final CatalogService catalogService) {
super();
this.clock = clock;
this.config = config;
- this.factory = factory;
+ this.catalogService = catalogService;
this.notificationQueueService = notificationQueueService;
this.bundles = new ArrayList<SubscriptionBundle>();
this.subscriptions = new ArrayList<Subscription>();
@@ -130,7 +131,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
public Subscription getSubscriptionFromId(final SubscriptionFactory factory, final UUID subscriptionId) {
for (final Subscription cur : subscriptions) {
if (cur.getId().equals(subscriptionId)) {
- return buildSubscription((SubscriptionData) cur);
+ return buildSubscription(factory, (SubscriptionData) cur);
}
}
return null;
@@ -167,7 +168,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
});
}
}
- Subscription updatedSubscription = buildSubscription(subscription);
+ Subscription updatedSubscription = buildSubscription(null, subscription);
subscriptions.add(updatedSubscription);
}
@@ -194,7 +195,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
List<Subscription> results = new ArrayList<Subscription>();
for (final Subscription cur : subscriptions) {
if (cur.getBundleId().equals(bundleId)) {
- results.add(buildSubscription((SubscriptionData) cur));
+ results.add(buildSubscription(factory, (SubscriptionData) cur));
}
}
return results;
@@ -234,7 +235,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
for (final Subscription cur : subscriptions) {
if (cur.getBundleId().equals(bundleId) &&
cur.getCurrentPlan().getProduct().getCategory() == ProductCategory.BASE) {
- return buildSubscription((SubscriptionData) cur);
+ return buildSubscription(factory, (SubscriptionData) cur);
}
}
return null;
@@ -248,8 +249,16 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
- private Subscription buildSubscription(final SubscriptionData in) {
- return factory.createSubscription(new SubscriptionBuilder(in), getEventsForSubscription(in.getId()));
+ private Subscription buildSubscription(final SubscriptionFactory factory, final SubscriptionData in) {
+ if (factory != null) {
+ return factory.createSubscription(new SubscriptionBuilder(in), getEventsForSubscription(in.getId()));
+ } else {
+ SubscriptionData subscription = new SubscriptionData(new SubscriptionBuilder(in), null, clock);
+ if (events.size() > 0) {
+ subscription.rebuildTransitions(getEventsForSubscription(in.getId()), catalogService.getFullCatalog());
+ }
+ return subscription;
+ }
}
@Override
@@ -307,6 +316,7 @@ public class MockEntitlementDaoMemory implements EntitlementDao, MockEntitlement
}
}
+
private void cancelNextPhaseEvent(final UUID subscriptionId) {
Subscription curSubscription = getSubscriptionFromId(null, subscriptionId);
diff --git a/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java b/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
index 02a3535..03dc211 100644
--- a/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
+++ b/invoice/src/main/java/com/ning/billing/invoice/notification/DefaultNextBillingDateNotifier.java
@@ -27,7 +27,6 @@ import com.google.inject.Inject;
import com.ning.billing.config.InvoiceConfig;
import com.ning.billing.entitlement.api.user.EntitlementUserApi;
import com.ning.billing.entitlement.api.user.Subscription;
-import com.ning.billing.entitlement.engine.dao.EntitlementDao;
import com.ning.billing.invoice.InvoiceListener;
import com.ning.billing.invoice.api.DefaultInvoiceService;
import com.ning.billing.util.bus.Bus;