killbill-memoizeit
Changes
beatrix/pom.xml 11(+11 -0)
entitlement/pom.xml 54(+24 -30)
invoice/pom.xml 47(+13 -34)
invoice/src/test/java/com/ning/billing/invoice/notification/TestNextBillingDateNotifier.java 67(+13 -54)
junction/pom.xml 14(+2 -12)
junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscription.java 208(+208 -0)
junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscriptionEvent.java 333(+333 -0)
junction/src/test/java/com/ning/billing/junction/plumbing/billing/TestDefaultEntitlementBillingApi.java 96(+62 -34)
overdue/pom.xml 14(+1 -13)
payment/pom.xml 25(+16 -9)
server/pom.xml 12(+8 -4)
Details
diff --git a/api/src/main/java/com/ning/billing/invoice/api/InvoicePaymentApi.java b/api/src/main/java/com/ning/billing/invoice/api/InvoicePaymentApi.java
index 9fb0bb3..0a34604 100644
--- a/api/src/main/java/com/ning/billing/invoice/api/InvoicePaymentApi.java
+++ b/api/src/main/java/com/ning/billing/invoice/api/InvoicePaymentApi.java
@@ -42,7 +42,7 @@ public interface InvoicePaymentApi {
public void notifyOfPaymentAttempt(InvoicePayment invoicePayment, CallContext context);
public void notifyOfPaymentAttempt(UUID invoiceId, BigDecimal amountOutstanding, Currency currency, UUID paymentAttemptId, DateTime paymentAttemptDate, CallContext context);
-
+
public void notifyOfPaymentAttempt(UUID invoiceId, UUID paymentAttemptId, DateTime paymentAttemptDate, CallContext context);
}
beatrix/pom.xml 11(+11 -0)
diff --git a/beatrix/pom.xml b/beatrix/pom.xml
index bed20c1..e7ed282 100644
--- a/beatrix/pom.xml
+++ b/beatrix/pom.xml
@@ -78,6 +78,17 @@
<scope>test</scope>
</dependency>
<dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-account</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-account</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
<groupId>org.jdbi</groupId>
<artifactId>jdbi</artifactId>
<scope>test</scope>
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/MockModule.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/MockModule.java
index 0eb1341..3c937a7 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/MockModule.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/MockModule.java
@@ -22,10 +22,6 @@ import java.io.IOException;
import java.net.URL;
import java.util.Set;
-import com.ning.billing.util.email.EmailConfig;
-import com.ning.billing.util.email.EmailModule;
-import com.ning.billing.util.email.templates.TemplateModule;
-
import org.skife.config.ConfigurationObjectFactory;
import org.skife.jdbi.v2.IDBI;
@@ -54,6 +50,8 @@ import com.ning.billing.payment.setup.PaymentModule;
import com.ning.billing.util.bus.BusService;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.clock.ClockMock;
+import com.ning.billing.util.email.EmailModule;
+import com.ning.billing.util.email.templates.TemplateModule;
import com.ning.billing.util.glue.BusModule;
import com.ning.billing.util.glue.CallContextModule;
import com.ning.billing.util.glue.FieldStoreModule;
entitlement/pom.xml 54(+24 -30)
diff --git a/entitlement/pom.xml b/entitlement/pom.xml
index 426d9f8..172287f 100644
--- a/entitlement/pom.xml
+++ b/entitlement/pom.xml
@@ -39,23 +39,6 @@
</dependency>
<dependency>
<groupId>com.ning.billing</groupId>
- <artifactId>killbill-catalog</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-catalog</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
<artifactId>killbill-util</artifactId>
</dependency>
<dependency>
@@ -63,14 +46,7 @@
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
- <!-- Same here, this is really debatable whether or not we should keep that here -->
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-account</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
+ <dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>
@@ -87,11 +63,6 @@
<artifactId>slf4j-log4j12</artifactId>
</dependency>
<dependency>
- <groupId>org.testng</groupId>
- <artifactId>testng</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
@@ -108,11 +79,34 @@
<artifactId>stringtemplate</artifactId>
<scope>runtime</scope>
</dependency>
+ <!-- TEST SCOPE -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-mxj</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-catalog</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-catalog</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-util</artifactId>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-mxj-db-files</artifactId>
invoice/pom.xml 47(+13 -34)
diff --git a/invoice/pom.xml b/invoice/pom.xml
index 5f5522a..7d1911b 100644
--- a/invoice/pom.xml
+++ b/invoice/pom.xml
@@ -33,42 +33,35 @@
<groupId>com.ning.billing</groupId>
<artifactId>killbill-util</artifactId>
</dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-util</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-entitlement</artifactId>
- <scope>test</scope>
+ <dependency>
+ <groupId>org.jdbi</groupId>
+ <artifactId>jdbi</artifactId>
</dependency>
<dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-entitlement</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
+ <groupId>org.antlr</groupId>
+ <artifactId>stringtemplate</artifactId>
+ <scope>runtime</scope>
</dependency>
<dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-junction</artifactId>
- <scope>test</scope>
+ <groupId>com.google.inject</groupId>
+ <artifactId>guice</artifactId>
+ <scope>provided</scope>
</dependency>
+ <!-- TEST SCOPE -->
<dependency>
<groupId>com.ning.billing</groupId>
- <artifactId>killbill-catalog</artifactId>
+ <artifactId>killbill-util</artifactId>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-catalog</artifactId>
- <type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ning.billing</groupId>
- <artifactId>killbill-account</artifactId>
+ <artifactId>killbill-catalog</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
@@ -83,20 +76,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.jdbi</groupId>
- <artifactId>jdbi</artifactId>
- </dependency>
- <dependency>
- <groupId>org.antlr</groupId>
- <artifactId>stringtemplate</artifactId>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>com.google.inject</groupId>
- <artifactId>guice</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
diff --git a/invoice/src/test/java/com/ning/billing/invoice/glue/InvoiceModuleWithEmbeddedDb.java b/invoice/src/test/java/com/ning/billing/invoice/glue/InvoiceModuleWithEmbeddedDb.java
index 99cfcfb..081b21f 100644
--- a/invoice/src/test/java/com/ning/billing/invoice/glue/InvoiceModuleWithEmbeddedDb.java
+++ b/invoice/src/test/java/com/ning/billing/invoice/glue/InvoiceModuleWithEmbeddedDb.java
@@ -26,7 +26,6 @@ import org.skife.jdbi.v2.IDBI;
import com.ning.billing.account.api.AccountUserApi;
import com.ning.billing.catalog.glue.CatalogModule;
import com.ning.billing.dbi.MysqlTestingHelper;
-import com.ning.billing.entitlement.glue.DefaultEntitlementModule;
import com.ning.billing.invoice.api.InvoiceNotifier;
import com.ning.billing.invoice.api.test.DefaultInvoiceTestApi;
import com.ning.billing.invoice.api.test.InvoiceTestApi;
@@ -40,6 +39,7 @@ import com.ning.billing.invoice.notification.NullInvoiceNotifier;
import com.ning.billing.junction.api.BillingApi;
import com.ning.billing.mock.BrainDeadProxyFactory;
import com.ning.billing.mock.BrainDeadProxyFactory.ZombieControl;
+import com.ning.billing.mock.glue.MockEntitlementModule;
import com.ning.billing.util.callcontext.CallContextFactory;
import com.ning.billing.util.callcontext.DefaultCallContextFactory;
import com.ning.billing.util.clock.Clock;
@@ -112,7 +112,7 @@ public class InvoiceModuleWithEmbeddedDb extends DefaultInvoiceModule {
bind(BillingApi.class).toInstance(billingApi);
install(new CatalogModule());
- install(new DefaultEntitlementModule());
+ install(new MockEntitlementModule());
install(new GlobalLockerModule());
super.configure();
diff --git a/invoice/src/test/java/com/ning/billing/invoice/notification/TestNextBillingDateNotifier.java b/invoice/src/test/java/com/ning/billing/invoice/notification/TestNextBillingDateNotifier.java
index 4d6b6fe..a0eb6d5 100644
--- a/invoice/src/test/java/com/ning/billing/invoice/notification/TestNextBillingDateNotifier.java
+++ b/invoice/src/test/java/com/ning/billing/invoice/notification/TestNextBillingDateNotifier.java
@@ -40,54 +40,32 @@ import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
-import com.google.inject.name.Names;
-import com.ning.billing.catalog.DefaultCatalogService;
-import com.ning.billing.catalog.api.CatalogService;
-import com.ning.billing.config.CatalogConfig;
+import com.ning.billing.catalog.MockCatalogModule;
import com.ning.billing.config.InvoiceConfig;
import com.ning.billing.dbi.DBIProvider;
import com.ning.billing.dbi.DbiConfig;
import com.ning.billing.dbi.MysqlTestingHelper;
-import com.ning.billing.entitlement.api.SubscriptionApiService;
-import com.ning.billing.entitlement.api.SubscriptionFactory;
-import com.ning.billing.entitlement.api.timeline.RepairEntitlementLifecycleDao;
-import com.ning.billing.entitlement.api.timeline.RepairSubscriptionApiService;
-import com.ning.billing.entitlement.api.timeline.RepairSubscriptionFactory;
-import com.ning.billing.entitlement.api.user.DefaultSubscriptionApiService;
-import com.ning.billing.entitlement.api.user.DefaultSubscriptionFactory;
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.entitlement.engine.dao.EntitlementSqlDao;
-import com.ning.billing.entitlement.engine.dao.RepairEntitlementDao;
-import com.ning.billing.entitlement.glue.DefaultEntitlementModule;
import com.ning.billing.invoice.InvoiceDispatcher;
import com.ning.billing.invoice.InvoiceListener;
-import com.ning.billing.invoice.api.InvoiceNotifier;
-import com.ning.billing.invoice.dao.DefaultInvoiceDao;
-import com.ning.billing.invoice.dao.InvoiceDao;
-import com.ning.billing.invoice.model.DefaultInvoiceGenerator;
-import com.ning.billing.invoice.model.InvoiceGenerator;
+import com.ning.billing.invoice.glue.InvoiceModuleWithMocks;
import com.ning.billing.lifecycle.KillbillService;
import com.ning.billing.mock.BrainDeadProxyFactory;
import com.ning.billing.mock.BrainDeadProxyFactory.ZombieControl;
import com.ning.billing.mock.glue.MockJunctionModule;
import com.ning.billing.util.bus.Bus;
-import com.ning.billing.util.bus.InMemoryBus;
import com.ning.billing.util.callcontext.CallContextFactory;
import com.ning.billing.util.callcontext.DefaultCallContextFactory;
import com.ning.billing.util.clock.Clock;
import com.ning.billing.util.clock.ClockMock;
-import com.ning.billing.util.customfield.dao.AuditedCustomFieldDao;
-import com.ning.billing.util.customfield.dao.CustomFieldDao;
-import com.ning.billing.util.globallocker.GlobalLocker;
-import com.ning.billing.util.globallocker.MySqlGlobalLocker;
-import com.ning.billing.util.notificationq.DefaultNotificationQueueService;
+import com.ning.billing.util.clock.MockClockModule;
+import com.ning.billing.util.glue.BusModule;
+import com.ning.billing.util.glue.BusModule.BusType;
+import com.ning.billing.util.glue.NotificationQueueModule;
import com.ning.billing.util.notificationq.DummySqlTest;
import com.ning.billing.util.notificationq.NotificationQueueService;
import com.ning.billing.util.notificationq.dao.NotificationSqlDao;
-import com.ning.billing.util.tag.dao.AuditedTagDao;
-import com.ning.billing.util.tag.dao.TagDao;
public class TestNextBillingDateNotifier {
private Clock clock;
@@ -135,16 +113,12 @@ public class TestNextBillingDateNotifier {
final Injector g = Guice.createInjector(Stage.PRODUCTION, new AbstractModule() {
protected void configure() {
- bind(Clock.class).to(ClockMock.class).asEagerSingleton();
- bind(CallContextFactory.class).to(DefaultCallContextFactory.class).asEagerSingleton();
- bind(Bus.class).to(InMemoryBus.class).asEagerSingleton();
- bind(NotificationQueueService.class).to(DefaultNotificationQueueService.class).asEagerSingleton();
- bind(InvoiceNotifier.class).to(NullInvoiceNotifier.class).asEagerSingleton();
- final InvoiceConfig invoiceConfig = new ConfigurationObjectFactory(System.getProperties()).build(InvoiceConfig.class);
- bind(InvoiceConfig.class).toInstance(invoiceConfig);
- final CatalogConfig catalogConfig = new ConfigurationObjectFactory(System.getProperties()).build(CatalogConfig.class);
- bind(CatalogConfig.class).toInstance(catalogConfig);
- bind(CatalogService.class).to(DefaultCatalogService.class).asEagerSingleton();
+ install(new MockClockModule());
+ install(new BusModule(BusType.MEMORY));
+ install(new InvoiceModuleWithMocks());
+ install(new MockJunctionModule());
+ install(new MockCatalogModule());
+ install(new NotificationQueueModule());
final MysqlTestingHelper helper = new MysqlTestingHelper();
bind(MysqlTestingHelper.class).toInstance(helper);
@@ -157,22 +131,7 @@ public class TestNextBillingDateNotifier {
bind(IDBI.class).toInstance(dbi);
}
- bind(TagDao.class).to(AuditedTagDao.class).asEagerSingleton();
- bind(EntitlementDao.class).to(EntitlementSqlDao.class).asEagerSingleton();
- bind(EntitlementDao.class).annotatedWith(Names.named(DefaultEntitlementModule.REPAIR_NAMED)).to(RepairEntitlementDao.class);
- bind(RepairEntitlementLifecycleDao.class).annotatedWith(Names.named(DefaultEntitlementModule.REPAIR_NAMED)).to(RepairEntitlementDao.class);
- bind(RepairEntitlementDao.class).asEagerSingleton();
- bind(CustomFieldDao.class).to(AuditedCustomFieldDao.class).asEagerSingleton();
- bind(GlobalLocker.class).to(MySqlGlobalLocker.class).asEagerSingleton();
- bind(InvoiceGenerator.class).to(DefaultInvoiceGenerator.class).asEagerSingleton();
- bind(InvoiceDao.class).to(DefaultInvoiceDao.class).asEagerSingleton();
- bind(NextBillingDatePoster.class).to(DefaultNextBillingDatePoster.class).asEagerSingleton();
- bind(SubscriptionApiService.class).annotatedWith(Names.named(DefaultEntitlementModule.REPAIR_NAMED)).to(RepairSubscriptionApiService.class).asEagerSingleton();
- bind(SubscriptionApiService.class).to(DefaultSubscriptionApiService.class).asEagerSingleton();
- bind(SubscriptionFactory.class).annotatedWith(Names.named(DefaultEntitlementModule.REPAIR_NAMED)).to(RepairSubscriptionFactory.class).asEagerSingleton();
- bind(SubscriptionFactory.class).to(DefaultSubscriptionFactory.class).asEagerSingleton();
- install(new MockJunctionModule());
}
});
@@ -204,7 +163,7 @@ public class TestNextBillingDateNotifier {
@Test(enabled=true, groups="slow")
- public void test() throws Exception {
+ public void testInvoiceNotifier() throws Exception {
final UUID subscriptionId = new UUID(0L,1L);
final DateTime now = new DateTime();
final DateTime readyTime = now.plusMillis(2000);
junction/pom.xml 14(+2 -12)
diff --git a/junction/pom.xml b/junction/pom.xml
index a33d843..0375b37 100644
--- a/junction/pom.xml
+++ b/junction/pom.xml
@@ -55,6 +55,7 @@
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
+ <!-- TEST SCOPE -->
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-util</artifactId>
@@ -72,18 +73,7 @@
<artifactId>killbill-catalog</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-entitlement</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-entitlement</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
+ <dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
diff --git a/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscription.java b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscription.java
new file mode 100644
index 0000000..2780249
--- /dev/null
+++ b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscription.java
@@ -0,0 +1,208 @@
+/*
+ * 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.junction.plumbing.billing;
+
+import java.util.List;
+import java.util.UUID;
+
+import org.joda.time.DateTime;
+
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.Plan;
+import com.ning.billing.catalog.api.PlanPhase;
+import com.ning.billing.catalog.api.PlanPhaseSpecifier;
+import com.ning.billing.catalog.api.PriceList;
+import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.user.EntitlementUserApiException;
+import com.ning.billing.entitlement.api.user.Subscription;
+import com.ning.billing.entitlement.api.user.SubscriptionEvent;
+import com.ning.billing.junction.api.BlockingState;
+import com.ning.billing.mock.BrainDeadProxyFactory;
+import com.ning.billing.util.callcontext.CallContext;
+import com.ning.billing.util.customfield.CustomField;
+import com.ning.billing.util.tag.ControlTagType;
+import com.ning.billing.util.tag.Tag;
+import com.ning.billing.util.tag.TagDefinition;
+
+
+public class MockSubscription implements Subscription {
+ Subscription sub = BrainDeadProxyFactory.createBrainDeadProxyFor(Subscription.class);
+
+ public List<Tag> getTagList() {
+ return sub.getTagList();
+ }
+
+ public UUID getId() {
+ return sub.getId();
+ }
+
+ public String getCreatedBy() {
+ return sub.getCreatedBy();
+ }
+
+ public boolean hasTag(TagDefinition tagDefinition) {
+ return sub.hasTag(tagDefinition);
+ }
+
+ public DateTime getCreatedDate() {
+ return sub.getCreatedDate();
+ }
+
+ public String getFieldValue(String fieldName) {
+ return sub.getFieldValue(fieldName);
+ }
+
+ public boolean hasTag(ControlTagType controlTagType) {
+ return sub.hasTag(controlTagType);
+ }
+
+ public void setFieldValue(String fieldName, String fieldValue) {
+ sub.setFieldValue(fieldName, fieldValue);
+ }
+
+ public void addTag(TagDefinition definition) {
+ sub.addTag(definition);
+ }
+
+ public void addTags(List<Tag> tags) {
+ sub.addTags(tags);
+ }
+
+ public void saveFieldValue(String fieldName, String fieldValue, CallContext context) {
+ sub.saveFieldValue(fieldName, fieldValue, context);
+ }
+
+ public void addTagsFromDefinitions(List<TagDefinition> tagDefinitions) {
+ sub.addTagsFromDefinitions(tagDefinitions);
+ }
+
+ public List<CustomField> getFieldList() {
+ return sub.getFieldList();
+ }
+
+ public void clearTags() {
+ sub.clearTags();
+ }
+
+ public void setFields(List<CustomField> fields) {
+ sub.setFields(fields);
+ }
+
+ public void removeTag(TagDefinition definition) {
+ sub.removeTag(definition);
+ }
+
+ public void saveFields(List<CustomField> fields, CallContext context) {
+ sub.saveFields(fields, context);
+ }
+
+ public boolean generateInvoice() {
+ return sub.generateInvoice();
+ }
+
+ public boolean processPayment() {
+ return sub.processPayment();
+ }
+
+ public void clearFields() {
+ sub.clearFields();
+ }
+
+ public void clearPersistedFields(CallContext context) {
+ sub.clearPersistedFields(context);
+ }
+
+ public boolean cancel(DateTime requestedDate, boolean eot, CallContext context) throws EntitlementUserApiException {
+ return sub.cancel(requestedDate, eot, context);
+ }
+
+ public String getObjectName() {
+ return sub.getObjectName();
+ }
+
+ public boolean uncancel(CallContext context) throws EntitlementUserApiException {
+ return sub.uncancel(context);
+ }
+
+ public boolean changePlan(String productName, BillingPeriod term, String planSet, DateTime requestedDate,
+ CallContext context) throws EntitlementUserApiException {
+ return sub.changePlan(productName, term, planSet, requestedDate, context);
+ }
+
+ public boolean recreate(PlanPhaseSpecifier spec, DateTime requestedDate, CallContext context)
+ throws EntitlementUserApiException {
+ return sub.recreate(spec, requestedDate, context);
+ }
+
+ public UUID getBundleId() {
+ return sub.getBundleId();
+ }
+
+ public SubscriptionState getState() {
+ return sub.getState();
+ }
+
+ public DateTime getStartDate() {
+ return sub.getStartDate();
+ }
+
+ public DateTime getEndDate() {
+ return sub.getEndDate();
+ }
+
+ public Plan getCurrentPlan() {
+ return sub.getCurrentPlan();
+ }
+
+ public BlockingState getBlockingState() {
+ return sub.getBlockingState();
+ }
+
+ public PriceList getCurrentPriceList() {
+ return sub.getCurrentPriceList();
+ }
+
+ public PlanPhase getCurrentPhase() {
+ return sub.getCurrentPhase();
+ }
+
+ public DateTime getChargedThroughDate() {
+ return sub.getChargedThroughDate();
+ }
+
+ public DateTime getPaidThroughDate() {
+ return sub.getPaidThroughDate();
+ }
+
+ public ProductCategory getCategory() {
+ return sub.getCategory();
+ }
+
+ public SubscriptionEvent getPendingTransition() {
+ return sub.getPendingTransition();
+ }
+
+ public SubscriptionEvent getPreviousTransition() {
+ return sub.getPreviousTransition();
+ }
+
+ public List<SubscriptionEvent> getBillingTransitions() {
+ return sub.getBillingTransitions();
+ }
+
+
+}
diff --git a/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscriptionEvent.java b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscriptionEvent.java
new file mode 100644
index 0000000..cbba255
--- /dev/null
+++ b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/MockSubscriptionEvent.java
@@ -0,0 +1,333 @@
+/*
+ * 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.junction.plumbing.billing;
+
+import java.util.UUID;
+
+import org.codehaus.jackson.annotate.JsonCreator;
+import org.codehaus.jackson.annotate.JsonIgnore;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.joda.time.DateTime;
+
+import com.ning.billing.entitlement.api.SubscriptionTransitionType;
+import com.ning.billing.entitlement.api.user.Subscription.SubscriptionState;
+import com.ning.billing.entitlement.api.user.SubscriptionEvent;
+import com.ning.billing.util.bus.BusEvent.BusEventType;
+
+public class MockSubscriptionEvent implements SubscriptionEvent {
+
+ private final Long totalOrdering;
+ private final UUID subscriptionId;
+ private final UUID bundleId;
+ private final UUID eventId;
+ private final DateTime requestedTransitionTime;
+ private final DateTime effectiveTransitionTime;
+ private final SubscriptionState previousState;
+ private final String previousPriceList;
+ private final String previousPlan;
+ private final String previousPhase;
+ private final SubscriptionState nextState;
+ private final String nextPriceList;
+ private final String nextPlan;
+ private final String nextPhase;
+ private final Integer remainingEventsForUserOperation;
+ private final UUID userToken;
+ private final SubscriptionTransitionType transitionType;
+
+ private final DateTime startDate;
+
+ @JsonCreator
+ public MockSubscriptionEvent(@JsonProperty("eventId") UUID eventId,
+ @JsonProperty("subscriptionId") UUID subscriptionId,
+ @JsonProperty("bundleId") UUID bundleId,
+ @JsonProperty("requestedTransitionTime") DateTime requestedTransitionTime,
+ @JsonProperty("effectiveTransitionTime") DateTime effectiveTransitionTime,
+ @JsonProperty("previousState") SubscriptionState previousState,
+ @JsonProperty("previousPlan") String previousPlan,
+ @JsonProperty("previousPhase") String previousPhase,
+ @JsonProperty("previousPriceList") String previousPriceList,
+ @JsonProperty("nextState") SubscriptionState nextState,
+ @JsonProperty("nextPlan") String nextPlan,
+ @JsonProperty("nextPhase") String nextPhase,
+ @JsonProperty("nextPriceList") String nextPriceList,
+ @JsonProperty("totalOrdering") Long totalOrdering,
+ @JsonProperty("userToken") UUID userToken,
+ @JsonProperty("transitionType") SubscriptionTransitionType transitionType,
+ @JsonProperty("remainingEventsForUserOperation") Integer remainingEventsForUserOperation,
+ @JsonProperty("startDate") DateTime startDate) {
+ super();
+ this.eventId = eventId;
+ this.subscriptionId = subscriptionId;
+ this.bundleId = bundleId;
+ this.requestedTransitionTime = requestedTransitionTime;
+ this.effectiveTransitionTime = effectiveTransitionTime;
+ this.previousState = previousState;
+ this.previousPriceList = previousPriceList;
+ this.previousPlan = previousPlan;
+ this.previousPhase = previousPhase;
+ this.nextState = nextState;
+ this.nextPlan = nextPlan;
+ this.nextPriceList = nextPriceList;
+ this.nextPhase = nextPhase;
+ this.totalOrdering = totalOrdering;
+ this.userToken = userToken;
+ this.transitionType = transitionType;
+ this.remainingEventsForUserOperation = remainingEventsForUserOperation;
+ this.startDate = startDate;
+ }
+
+ @JsonIgnore
+ @Override
+ public BusEventType getBusEventType() {
+ return BusEventType.SUBSCRIPTION_TRANSITION;
+ }
+
+ @JsonProperty("eventId")
+ @Override
+ public UUID getId() {
+ return eventId;
+ }
+
+ @Override
+ public UUID getSubscriptionId() {
+ return subscriptionId;
+ }
+
+ @Override
+ public UUID getBundleId() {
+ return bundleId;
+ }
+
+
+ @Override
+ public SubscriptionState getPreviousState() {
+ return previousState;
+ }
+
+ @Override
+ public String getPreviousPlan() {
+ return previousPlan;
+ }
+
+ @Override
+ public String getPreviousPhase() {
+ return previousPhase;
+ }
+
+ @Override
+ public String getNextPlan() {
+ return nextPlan;
+ }
+
+ @Override
+ public String getNextPhase() {
+ return nextPhase;
+ }
+
+ @Override
+ public SubscriptionState getNextState() {
+ return nextState;
+ }
+
+
+ @Override
+ public String getPreviousPriceList() {
+ return previousPriceList;
+ }
+
+ @Override
+ public String getNextPriceList() {
+ return nextPriceList;
+ }
+
+ @Override
+ public UUID getUserToken() {
+ return userToken;
+ }
+
+ @Override
+ public Integer getRemainingEventsForUserOperation() {
+ return remainingEventsForUserOperation;
+ }
+
+
+ @Override
+ public DateTime getRequestedTransitionTime() {
+ return requestedTransitionTime;
+ }
+
+ @Override
+ public DateTime getEffectiveTransitionTime() {
+ return effectiveTransitionTime;
+ }
+
+ @Override
+ public Long getTotalOrdering() {
+ return totalOrdering;
+ }
+
+ @Override
+ public SubscriptionTransitionType getTransitionType() {
+ return transitionType;
+ }
+
+ @JsonProperty("startDate")
+ @Override
+ public DateTime getSubscriptionStartDate() {
+ return startDate;
+ }
+
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result
+ + ((bundleId == null) ? 0 : bundleId.hashCode());
+ result = prime
+ * result
+ + ((effectiveTransitionTime == null) ? 0
+ : effectiveTransitionTime.hashCode());
+ result = prime * result + ((eventId == null) ? 0 : eventId.hashCode());
+ result = prime * result
+ + ((nextPhase == null) ? 0 : nextPhase.hashCode());
+ result = prime * result
+ + ((nextPlan == null) ? 0 : nextPlan.hashCode());
+ result = prime * result
+ + ((nextPriceList == null) ? 0 : nextPriceList.hashCode());
+ result = prime * result
+ + ((nextState == null) ? 0 : nextState.hashCode());
+ result = prime * result
+ + ((previousPhase == null) ? 0 : previousPhase.hashCode());
+ result = prime * result
+ + ((previousPlan == null) ? 0 : previousPlan.hashCode());
+ result = prime
+ * result
+ + ((previousPriceList == null) ? 0 : previousPriceList
+ .hashCode());
+ result = prime * result
+ + ((previousState == null) ? 0 : previousState.hashCode());
+ result = prime
+ * result
+ + ((remainingEventsForUserOperation == null) ? 0
+ : remainingEventsForUserOperation.hashCode());
+ result = prime
+ * result
+ + ((requestedTransitionTime == null) ? 0
+ : requestedTransitionTime.hashCode());
+ result = prime * result
+ + ((subscriptionId == null) ? 0 : subscriptionId.hashCode());
+ result = prime * result
+ + ((totalOrdering == null) ? 0 : totalOrdering.hashCode());
+ result = prime * result
+ + ((transitionType == null) ? 0 : transitionType.hashCode());
+ result = prime * result
+ + ((userToken == null) ? 0 : userToken.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ MockSubscriptionEvent other = (MockSubscriptionEvent) obj;
+ if (bundleId == null) {
+ if (other.bundleId != null)
+ return false;
+ } else if (!bundleId.equals(other.bundleId))
+ return false;
+ if (effectiveTransitionTime == null) {
+ if (other.effectiveTransitionTime != null)
+ return false;
+ } else if (effectiveTransitionTime
+ .compareTo(other.effectiveTransitionTime) != 0)
+ return false;
+ if (eventId == null) {
+ if (other.eventId != null)
+ return false;
+ } else if (!eventId.equals(other.eventId))
+ return false;
+ if (nextPhase == null) {
+ if (other.nextPhase != null)
+ return false;
+ } else if (!nextPhase.equals(other.nextPhase))
+ return false;
+ if (nextPlan == null) {
+ if (other.nextPlan != null)
+ return false;
+ } else if (!nextPlan.equals(other.nextPlan))
+ return false;
+ if (nextPriceList == null) {
+ if (other.nextPriceList != null)
+ return false;
+ } else if (!nextPriceList.equals(other.nextPriceList))
+ return false;
+ if (nextState != other.nextState)
+ return false;
+ if (previousPhase == null) {
+ if (other.previousPhase != null)
+ return false;
+ } else if (!previousPhase.equals(other.previousPhase))
+ return false;
+ if (previousPlan == null) {
+ if (other.previousPlan != null)
+ return false;
+ } else if (!previousPlan.equals(other.previousPlan))
+ return false;
+ if (previousPriceList == null) {
+ if (other.previousPriceList != null)
+ return false;
+ } else if (!previousPriceList.equals(other.previousPriceList))
+ return false;
+ if (previousState != other.previousState)
+ return false;
+ if (remainingEventsForUserOperation == null) {
+ if (other.remainingEventsForUserOperation != null)
+ return false;
+ } else if (!remainingEventsForUserOperation
+ .equals(other.remainingEventsForUserOperation))
+ return false;
+ if (requestedTransitionTime == null) {
+ if (other.requestedTransitionTime != null)
+ return false;
+ } else if (requestedTransitionTime
+ .compareTo(other.requestedTransitionTime) != 0)
+ return false;
+ if (subscriptionId == null) {
+ if (other.subscriptionId != null)
+ return false;
+ } else if (!subscriptionId.equals(other.subscriptionId))
+ return false;
+ if (totalOrdering == null) {
+ if (other.totalOrdering != null)
+ return false;
+ } else if (!totalOrdering.equals(other.totalOrdering))
+ return false;
+ if (transitionType != other.transitionType)
+ return false;
+ if (userToken == null) {
+ if (other.userToken != null)
+ return false;
+ } else if (!userToken.equals(other.userToken))
+ return false;
+ return true;
+ }
+
+}
diff --git a/junction/src/test/java/com/ning/billing/junction/plumbing/billing/TestDefaultEntitlementBillingApi.java b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/TestDefaultEntitlementBillingApi.java
index cf5dd35..9dce3b0 100644
--- a/junction/src/test/java/com/ning/billing/junction/plumbing/billing/TestDefaultEntitlementBillingApi.java
+++ b/junction/src/test/java/com/ning/billing/junction/plumbing/billing/TestDefaultEntitlementBillingApi.java
@@ -51,22 +51,14 @@ import com.ning.billing.catalog.api.PlanPhase;
import com.ning.billing.catalog.api.Price;
import com.ning.billing.catalog.api.PriceList;
import com.ning.billing.catalog.api.PriceListSet;
+import com.ning.billing.entitlement.api.SubscriptionTransitionType;
import com.ning.billing.entitlement.api.billing.BillingEvent;
import com.ning.billing.entitlement.api.billing.BillingModeType;
-import com.ning.billing.entitlement.api.user.DefaultSubscriptionEvent;
-
-import com.ning.billing.entitlement.api.user.DefaultSubscriptionFactory.SubscriptionBuilder;
import com.ning.billing.entitlement.api.user.EntitlementUserApi;
import com.ning.billing.entitlement.api.user.Subscription;
import com.ning.billing.entitlement.api.user.Subscription.SubscriptionState;
import com.ning.billing.entitlement.api.user.SubscriptionBundle;
-import com.ning.billing.entitlement.api.user.SubscriptionBundleData;
-import com.ning.billing.entitlement.api.user.SubscriptionData;
import com.ning.billing.entitlement.api.user.SubscriptionEvent;
-
-import com.ning.billing.entitlement.api.user.SubscriptionTransitionData;
-import com.ning.billing.entitlement.events.EntitlementEvent.EventType;
-import com.ning.billing.entitlement.events.user.ApiEventType;
import com.ning.billing.junction.api.BillingApi;
import com.ning.billing.junction.api.Blockable;
import com.ning.billing.junction.api.Blockable.Type;
@@ -158,17 +150,18 @@ public class TestDefaultEntitlementBillingApi {
@BeforeMethod(groups={"fast", "slow"})
public void setupEveryTime() {
bundles = new ArrayList<SubscriptionBundle>();
- final SubscriptionBundle bundle = new SubscriptionBundleData( eventId,"TestKey", subId, clock.getUTCNow().minusDays(4), null);
+ final SubscriptionBundle bundle = BrainDeadProxyFactory.createBrainDeadProxyFor(SubscriptionBundle.class);
+ ((ZombieControl)bundle).addResult("getId", eventId);
+
+ //new SubscriptionBundleData( eventId,"TestKey", subId, clock.getUTCNow().minusDays(4), null);
bundles.add(bundle);
subscriptionTransitions = new LinkedList<SubscriptionEvent>();
subscriptions = new LinkedList<Subscription>();
- SubscriptionBuilder builder = new SubscriptionBuilder();
subscriptionStartDate = clock.getUTCNow().minusDays(3);
- builder.setStartDate(subscriptionStartDate).setId(subId).setBundleId(bunId);
- subscription = new SubscriptionData(builder) {
+ subscription = new MockSubscription() {
@Override
public List<SubscriptionEvent> getBillingTransitions() {
return subscriptionTransitions;
@@ -178,6 +171,22 @@ public class TestDefaultEntitlementBillingApi {
public Plan getCurrentPlan() {
return subscriptionPlan;
}
+
+ @Override
+ public UUID getId() {
+ return subId;
+ }
+
+ @Override
+ public UUID getBundleId() {
+ return bunId;
+ }
+
+ @Override
+ public DateTime getStartDate() {
+ return subscriptionStartDate;
+ }
+
};
@@ -219,9 +228,12 @@ public class TestDefaultEntitlementBillingApi {
PlanPhase nextPhase = nextPlan.getAllPhases()[0]; // The trial has no billing period
PriceList nextPriceList = catalogService.getFullCatalog().findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME, now);
- SubscriptionEvent t = new DefaultSubscriptionEvent(new SubscriptionTransitionData(
- eventId, subId, bunId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null,
- SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList, 1L, null, true), then);
+ SubscriptionEvent t = new MockSubscriptionEvent(
+ eventId, subId, bunId, then, now, null, null, null, null, SubscriptionState.ACTIVE,
+ nextPlan.getName(), nextPhase.getName(),
+ nextPriceList.getName(), 1L,null,
+ SubscriptionTransitionType.CREATE, 0, null);
+
subscriptionTransitions.add(t);
AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
@@ -235,7 +247,7 @@ public class TestDefaultEntitlementBillingApi {
BillingApi api = new DefaultBillingApi(null, factory, accountApi, bcdCalculator, entitlementApi, blockCalculator, catalogService);
SortedSet<BillingEvent> events = api.getBillingEventsForAccountAndUpdateAccountBCD(new UUID(0L,0L));
- checkFirstEvent(events, nextPlan, 32, subId, now, nextPhase, ApiEventType.CREATE.toString());
+ checkFirstEvent(events, nextPlan, 32, subId, now, nextPhase, SubscriptionTransitionType.CREATE.toString());
}
@Test(enabled=true, groups="fast")
@@ -245,9 +257,12 @@ public class TestDefaultEntitlementBillingApi {
Plan nextPlan = catalogService.getFullCatalog().findPlan("PickupTrialEvergreen10USD", now);
PlanPhase nextPhase = nextPlan.getAllPhases()[1];
PriceList nextPriceList = catalogService.getFullCatalog().findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME, now);
- SubscriptionEvent t = new DefaultSubscriptionEvent(new SubscriptionTransitionData(
- eventId, subId, bunId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE,
- nextPlan, nextPhase, nextPriceList, 1L, null, true), then);
+ SubscriptionEvent t = new MockSubscriptionEvent(
+ eventId, subId, bunId, then, now, null, null, null, null, SubscriptionState.ACTIVE,
+ nextPlan.getName(), nextPhase.getName(),
+ nextPriceList.getName(), 1L,null,
+ SubscriptionTransitionType.CREATE, 0, null);
+
subscriptionTransitions.add(t);
Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
@@ -265,7 +280,7 @@ public class TestDefaultEntitlementBillingApi {
BillingApi api = new DefaultBillingApi(null, factory, accountApi, bcdCalculator, entitlementApi, blockCalculator, catalogService);
SortedSet<BillingEvent> events = api.getBillingEventsForAccountAndUpdateAccountBCD(new UUID(0L,0L));
- checkFirstEvent(events, nextPlan, subscription.getStartDate().plusDays(30).getDayOfMonth(), subId, now, nextPhase, ApiEventType.CREATE.toString());
+ checkFirstEvent(events, nextPlan, subscription.getStartDate().plusDays(30).getDayOfMonth(), subId, now, nextPhase, SubscriptionTransitionType.CREATE.toString());
}
@Test(enabled=true, groups="fast")
@@ -276,9 +291,13 @@ public class TestDefaultEntitlementBillingApi {
PlanPhase nextPhase = nextPlan.getAllPhases()[1];
PriceList nextPriceList = catalogService.getFullCatalog().findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME, now);
- SubscriptionEvent t = new DefaultSubscriptionEvent(new SubscriptionTransitionData(
- eventId, subId, bunId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList,
- 1L, null, true), then);
+ SubscriptionEvent t = new MockSubscriptionEvent(
+ eventId, subId, bunId, then, now, null, null, null, null, SubscriptionState.ACTIVE,
+ nextPlan.getName(), nextPhase.getName(),
+ nextPriceList.getName(), 1L,null,
+ SubscriptionTransitionType.CREATE, 0, null);
+
+
subscriptionTransitions.add(t);
AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
@@ -295,7 +314,7 @@ public class TestDefaultEntitlementBillingApi {
SortedSet<BillingEvent> events = api.getBillingEventsForAccountAndUpdateAccountBCD(new UUID(0L,0L));
- checkFirstEvent(events, nextPlan, 32, subId, now, nextPhase, ApiEventType.CREATE.toString());
+ checkFirstEvent(events, nextPlan, 32, subId, now, nextPhase, SubscriptionTransitionType.CREATE.toString());
}
@Test(enabled=true, groups="fast")
@@ -306,9 +325,12 @@ public class TestDefaultEntitlementBillingApi {
PlanPhase nextPhase = nextPlan.getAllPhases()[0];
PriceList nextPriceList = catalogService.getFullCatalog().findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME, now);
- SubscriptionEvent t = new DefaultSubscriptionEvent(new SubscriptionTransitionData(
- eventId, subId, bunId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList, 1L,
- null, true), then);
+ SubscriptionEvent t = new MockSubscriptionEvent(
+ eventId, subId, bunId, then, now, null, null, null, null, SubscriptionState.ACTIVE,
+ nextPlan.getName(), nextPhase.getName(),
+ nextPriceList.getName(), 1L,null,
+ SubscriptionTransitionType.CREATE, 0, null);
+
subscriptionTransitions.add(t);
Account account = BrainDeadProxyFactory.createBrainDeadProxyFor(Account.class);
@@ -328,7 +350,7 @@ public class TestDefaultEntitlementBillingApi {
SortedSet<BillingEvent> events = api.getBillingEventsForAccountAndUpdateAccountBCD(new UUID(0L,0L));
- checkFirstEvent(events, nextPlan, subscription.getStartDate().plusDays(30).getDayOfMonth(), subId, now, nextPhase, ApiEventType.CREATE.toString());
+ checkFirstEvent(events, nextPlan, subscription.getStartDate().plusDays(30).getDayOfMonth(), subId, now, nextPhase, SubscriptionTransitionType.CREATE.toString());
}
@Test(enabled=true, groups="fast")
@@ -338,8 +360,14 @@ public class TestDefaultEntitlementBillingApi {
Plan nextPlan = catalogService.getFullCatalog().findPlan("PickupTrialEvergreen10USD", now);
PlanPhase nextPhase = nextPlan.getAllPhases()[1];
PriceList nextPriceList = catalogService.getFullCatalog().findPriceList(PriceListSet.DEFAULT_PRICELIST_NAME, now);
- SubscriptionEvent t = new DefaultSubscriptionEvent(new SubscriptionTransitionData(
- eventId, subId, bunId, EventType.API_USER, ApiEventType.CREATE, then, now, null, null, null, null, SubscriptionState.ACTIVE, nextPlan, nextPhase, nextPriceList, 1L, null, true), then);
+
+
+ SubscriptionEvent t = new MockSubscriptionEvent(
+ eventId, subId, bunId, then, now, null, null, null, null, SubscriptionState.ACTIVE,
+ nextPlan.getName(), nextPhase.getName(),
+ nextPriceList.getName(), 1L,null,
+ SubscriptionTransitionType.CREATE, 0, null);
+
subscriptionTransitions.add(t);
AccountUserApi accountApi = BrainDeadProxyFactory.createBrainDeadProxyFor(AccountUserApi.class);
@@ -392,9 +420,9 @@ public class TestDefaultEntitlementBillingApi {
Assert.assertEquals(events.size(), 3);
Iterator<BillingEvent> it = events.iterator();
- checkEvent(it.next(), nextPlan, 32, subId, now, nextPhase, ApiEventType.CREATE.toString(), nextPhase.getFixedPrice(), nextPhase.getRecurringPrice());
- checkEvent(it.next(), nextPlan, 32, subId, now.plusDays(1), nextPhase, ApiEventType.CANCEL.toString(), new MockPrice("0"), new MockPrice("0"));
- checkEvent(it.next(), nextPlan, 32, subId, now.plusDays(2), nextPhase, ApiEventType.RE_CREATE.toString(), nextPhase.getFixedPrice(), nextPhase.getRecurringPrice());
+ checkEvent(it.next(), nextPlan, 32, subId, now, nextPhase, SubscriptionTransitionType.CREATE.toString(), nextPhase.getFixedPrice(), nextPhase.getRecurringPrice());
+ checkEvent(it.next(), nextPlan, 32, subId, now.plusDays(1), nextPhase, SubscriptionTransitionType.CANCEL.toString(), new MockPrice("0"), new MockPrice("0"));
+ checkEvent(it.next(), nextPlan, 32, subId, now.plusDays(2), nextPhase, SubscriptionTransitionType.RE_CREATE.toString(), nextPhase.getFixedPrice(), nextPhase.getRecurringPrice());
}
overdue/pom.xml 14(+1 -13)
diff --git a/overdue/pom.xml b/overdue/pom.xml
index b6f64a0..1fc7dbf 100644
--- a/overdue/pom.xml
+++ b/overdue/pom.xml
@@ -55,19 +55,7 @@
<artifactId>commons-io</artifactId>
<scope>test</scope>
</dependency>
- <!-- Check if we need this one -->
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-junction</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-junction</artifactId>
- <type>test-jar</type>
- <scope>test</scope>
- </dependency>
-
+
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-util</artifactId>
diff --git a/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueRules.java b/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueRules.java
index 3095296..514c85f 100644
--- a/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueRules.java
+++ b/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueRules.java
@@ -18,15 +18,15 @@ package com.ning.billing.overdue.config;
import com.ning.billing.entitlement.api.user.SubscriptionBundle;
-import com.ning.billing.junction.MockBlockingModule;
public class MockOverdueRules extends OverdueConfig {
+ public static final String CLEAR_STATE="Clear";
@SuppressWarnings("unchecked")
public MockOverdueRules() {
OverdueStatesBundle bundleODS = new OverdueStatesBundle();
- bundleODS.setBundleOverdueStates(new DefaultOverdueState[] { new DefaultOverdueState<SubscriptionBundle>().setName(MockBlockingModule.CLEAR_STATE) });
+ bundleODS.setBundleOverdueStates(new DefaultOverdueState[] { new DefaultOverdueState<SubscriptionBundle>().setName(CLEAR_STATE) });
setOverdueStatesBundle(bundleODS);
}
diff --git a/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueState.java b/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueState.java
index 606556f..d1b9ab1 100644
--- a/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueState.java
+++ b/overdue/src/test/java/com/ning/billing/overdue/config/MockOverdueState.java
@@ -16,13 +16,12 @@
package com.ning.billing.overdue.config;
-import com.ning.billing.junction.MockBlockingModule;
import com.ning.billing.junction.api.Blockable;
public class MockOverdueState<T extends Blockable> extends DefaultOverdueState<T> {
public MockOverdueState() {
- setName(MockBlockingModule.CLEAR_STATE);
+ setName(MockOverdueRules.CLEAR_STATE);
}
public MockOverdueState(String name, boolean blockChanges, boolean disableEntitlementAndBlockChanges) {
diff --git a/overdue/src/test/java/com/ning/billing/overdue/notification/TestOverdueCheckNotifier.java b/overdue/src/test/java/com/ning/billing/overdue/notification/TestOverdueCheckNotifier.java
index 34890a4..dca8cb7 100644
--- a/overdue/src/test/java/com/ning/billing/overdue/notification/TestOverdueCheckNotifier.java
+++ b/overdue/src/test/java/com/ning/billing/overdue/notification/TestOverdueCheckNotifier.java
@@ -38,7 +38,6 @@ import org.testng.annotations.Test;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Stage;
-import com.ning.billing.account.api.AccountUserApi;
import com.ning.billing.catalog.DefaultCatalogService;
import com.ning.billing.catalog.api.CatalogService;
import com.ning.billing.config.CatalogConfig;
@@ -47,9 +46,7 @@ import com.ning.billing.dbi.MysqlTestingHelper;
import com.ning.billing.entitlement.api.billing.ChargeThruApi;
import com.ning.billing.entitlement.api.user.EntitlementUserApi;
import com.ning.billing.entitlement.api.user.Subscription;
-import com.ning.billing.junction.api.BillingApi;
import com.ning.billing.junction.api.Blockable;
-import com.ning.billing.junction.plumbing.billing.DefaultBillingApi;
import com.ning.billing.lifecycle.KillbillService.ServiceException;
import com.ning.billing.mock.BrainDeadProxyFactory;
import com.ning.billing.mock.BrainDeadProxyFactory.ZombieControl;
payment/pom.xml 25(+16 -9)
diff --git a/payment/pom.xml b/payment/pom.xml
index cb39ebf..b29f5a0 100644
--- a/payment/pom.xml
+++ b/payment/pom.xml
@@ -26,14 +26,6 @@
</dependency>
<dependency>
<groupId>com.ning.billing</groupId>
- <artifactId>killbill-invoice</artifactId>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-account</artifactId>
- </dependency>
- <dependency>
- <groupId>com.ning.billing</groupId>
<artifactId>killbill-util</artifactId>
</dependency>
<dependency>
@@ -78,12 +70,13 @@
<artifactId>slf4j-api</artifactId>
</dependency>
+ <!-- TEST SCOPE -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
+ <dependency>
<groupId>com.jayway.awaitility</groupId>
<artifactId>awaitility</artifactId>
<scope>test</scope>
@@ -94,18 +87,32 @@
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <!-- TODO: MDW REMOVE -->
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-account</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <!-- TODO: MDW REMOVE -->
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-invoice</artifactId>
<type>test-jar</type>
<scope>test</scope>
</dependency>
+ <!-- TODO: MDW REMOVE -->
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-invoice</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <!-- TODO: MDW REMOVE -->
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-account</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-mxj</artifactId>
diff --git a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
index b789999..2ed490c 100644
--- a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
+++ b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentApi.java
@@ -35,7 +35,6 @@ import com.ning.billing.account.api.AccountUserApi;
import com.ning.billing.config.PaymentConfig;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoicePaymentApi;
-import com.ning.billing.invoice.model.DefaultInvoicePayment;
import com.ning.billing.payment.RetryService;
import com.ning.billing.payment.dao.PaymentDao;
import com.ning.billing.payment.provider.PaymentProviderPlugin;
@@ -268,13 +267,14 @@ public class DefaultPaymentApi implements PaymentApi {
}
}
- invoicePaymentApi.notifyOfPaymentAttempt(new DefaultInvoicePayment(paymentAttempt.getPaymentAttemptId(),
+ invoicePaymentApi.notifyOfPaymentAttempt(
invoice.getId(),
- paymentAttempt.getPaymentAttemptDate(),
paymentInfo == null || paymentInfo.getStatus().equalsIgnoreCase("Error") ? null : paymentInfo.getAmount(),
// paymentInfo.getRefundAmount(), TODO
- paymentInfo == null || paymentInfo.getStatus().equalsIgnoreCase("Error") ? null : invoice.getCurrency()),
- context);
+ paymentInfo == null || paymentInfo.getStatus().equalsIgnoreCase("Error") ? null : invoice.getCurrency(),
+ paymentAttempt.getPaymentAttemptId(),
+ paymentAttempt.getPaymentAttemptDate(),
+ context);
return paymentOrError;
}
server/pom.xml 12(+8 -4)
diff --git a/server/pom.xml b/server/pom.xml
index 4bc0388..e740c10 100644
--- a/server/pom.xml
+++ b/server/pom.xml
@@ -155,10 +155,14 @@
</dependency>
<!-- FROM MASTER POM / LIBRARY -->
- <dependency>
- <groupId>com.ning.billing</groupId>
- <artifactId>killbill-api</artifactId>
- </dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.ning.billing</groupId>
+ <artifactId>killbill-account</artifactId>
+ </dependency>
<dependency>
<groupId>com.ning.billing</groupId>
<artifactId>killbill-jaxrs</artifactId>