killbill-uncached
Changes
beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java 12(+8 -4)
overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckPoster.java 22(+12 -10)
overdue/src/test/java/com/ning/billing/ovedue/notification/TestDefaultOverdueCheckPoster.java 8(+4 -4)
subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java 5(+0 -5)
Details
diff --git a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
index 41bea4a..c158f31 100644
--- a/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
+++ b/account/src/main/java/com/ning/billing/account/api/DefaultAccount.java
@@ -235,12 +235,6 @@ public class DefaultAccount extends EntityBase implements Account {
return new DefaultMutableAccountData(this);
}
- @Override
- public BlockingState getBlockingState() {
- // STEPH_ENT How to return blocking state??????
- return null;
- }
-
/**
* @param currentAccount existing account data
* @return merged account data
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
index c42df7d..a7b7d05 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/overdue/TestOverdueIntegration.java
@@ -198,6 +198,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -292,6 +293,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, BillingPeriod.ANNUAL, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -375,6 +377,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Create subscription
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -462,6 +465,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Create a subscription without failing payments
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -482,8 +486,6 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Should still be in clear state - the invoice for the bundle has been paid, but not the invoice with the external charge
// We refresh overdue just to be safe, see below
- // STEPH_ENT account level
- //overdueUserApi.refreshOverdueStateFor(bundle, callContext);
checkODState(DefaultBlockingState.CLEAR_STATE_NAME);
// Past 30 days since the external charge
@@ -491,8 +493,6 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Note! We need to explicitly refresh here because overdue won't get notified to refresh up until the next
// payment (when the next invoice is generated)
// TODO - we should fix this
- // STEPH_ENT account level
- //overdueUserApi.refreshOverdueStateFor(bundle, callContext);
// We should now be in OD1
checkODState("OD1");
@@ -509,6 +509,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Create subscription and don't fail payments
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -551,6 +552,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Create subscription and don't fail payments
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -594,6 +596,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
@@ -644,6 +647,7 @@ public class TestOverdueIntegration extends TestOverdueBase {
// Set next invoice to fail and create subscription
paymentPlugin.makeAllInvoicesFailWithError(true);
final DefaultEntitlement baseEntitlement = createBaseEntitlementAndCheckForCompletion(account.getId(), "externalKey", productName, ProductCategory.BASE, term, NextEvent.CREATE, NextEvent.INVOICE);
+ bundle = subscriptionApi.getSubscriptionBundle(baseEntitlement.getBundleId(), callContext);
invoiceChecker.checkInvoice(account.getId(), 1, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 5, 1), null, InvoiceItemType.FIXED, new BigDecimal("0")));
invoiceChecker.checkChargedThroughDate(baseEntitlement.getId(), new LocalDate(2012, 5, 1), callContext);
diff --git a/entitlement/src/test/java/com/ning/billing/entitlement/block/TestBlockingChecker.java b/entitlement/src/test/java/com/ning/billing/entitlement/block/TestBlockingChecker.java
index 8d7b6f5..6026b73 100644
--- a/entitlement/src/test/java/com/ning/billing/entitlement/block/TestBlockingChecker.java
+++ b/entitlement/src/test/java/com/ning/billing/entitlement/block/TestBlockingChecker.java
@@ -66,9 +66,9 @@ public class TestBlockingChecker extends EntitlementTestSuiteNoDB {
((MockBlockingStateDao) blockingStateDao).clear();
}
+
private void setStateBundle(final boolean bC, final boolean bE, final boolean bB) {
final BlockingState bundleState = new DefaultBlockingState(bundle.getId(), BlockingStateType.BUNDLE,"state", "test-service", bC, bE, bB, clock.getUTCNow());
- Mockito.when(bundle.getBlockingState()).thenReturn(bundleState);
blockingStateDao.setBlockingState(bundleState, clock, internalCallContext);
}
@@ -79,7 +79,6 @@ public class TestBlockingChecker extends EntitlementTestSuiteNoDB {
private void setStateSubscription(final boolean bC, final boolean bE, final boolean bB) {
final BlockingState subscriptionState = new DefaultBlockingState(subscription.getId(), BlockingStateType.SUBSCRIPTION, "state", "test-service", bC, bE, bB, clock.getUTCNow());
- Mockito.when(subscription.getBlockingState()).thenReturn(subscriptionState);
blockingStateDao.setBlockingState(subscriptionState, clock, internalCallContext);
}
diff --git a/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckPoster.java b/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckPoster.java
index 3adfb28..e2578a4 100644
--- a/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckPoster.java
+++ b/overdue/src/main/java/com/ning/billing/ovedue/notification/DefaultOverdueCheckPoster.java
@@ -27,8 +27,8 @@ import org.skife.jdbi.v2.IDBI;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.ning.billing.account.api.Account;
import com.ning.billing.clock.Clock;
-import com.ning.billing.entitlement.api.Blockable;
import com.ning.billing.notificationq.api.NotificationEventWithMetadata;
import com.ning.billing.notificationq.api.NotificationQueue;
import com.ning.billing.notificationq.api.NotificationQueueService;
@@ -63,7 +63,7 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
}
@Override
- public void insertOverdueCheckNotification(final Blockable overdueable, final DateTime futureNotificationTime, final InternalCallContext context) {
+ public void insertOverdueCheckNotification(final Account account, final DateTime futureNotificationTime, final InternalCallContext context) {
final NotificationQueue checkOverdueQueue;
try {
checkOverdueQueue = notificationQueueService.getNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME,
@@ -75,7 +75,7 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
boolean shouldInsertNewNotification = true;
// Check if we already have notifications for that key
- final Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> futureNotifications = getFutureNotificationsForAccountAndOverdueableInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, overdueable, context);
+ final Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> futureNotifications = getFutureNotificationsForAccountAndOverdueableInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, account, context);
if (futureNotifications.size() > 0) {
// Results are ordered by effective date asc
final DateTime earliestExistingNotificationDate = futureNotifications.iterator().next().getEffectiveDate();
@@ -102,11 +102,11 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
}
if (shouldInsertNewNotification) {
- log.debug("Queuing overdue check notification. Overdueable id: {}, timestamp: {}", overdueable.getId().toString(), futureNotificationTime.toString());
- final OverdueCheckNotificationKey notificationKey = new OverdueCheckNotificationKey(overdueable.getId());
+ log.debug("Queuing overdue check notification. Account id: {}, timestamp: {}", account.getId().toString(), futureNotificationTime.toString());
+ final OverdueCheckNotificationKey notificationKey = new OverdueCheckNotificationKey(account.getId());
checkOverdueQueue.recordFutureNotificationFromTransaction(entitySqlDaoWrapperFactory.getSqlDao(), futureNotificationTime, notificationKey, context.getUserToken(), context.getAccountRecordId(), context.getTenantRecordId());
} else {
- log.debug("Skipping queuing overdue check notification. Overdueable id: {}, timestamp: {}", overdueable.getId().toString(), futureNotificationTime.toString());
+ log.debug("Skipping queuing overdue check notification. Account id: {}, timestamp: {}", account.getId().toString(), futureNotificationTime.toString());
}
return null;
@@ -118,7 +118,7 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
}
@Override
- public void clearNotificationsFor(final Blockable overdueable, final InternalCallContext context) {
+ public void clearNotificationsFor(final Account account, final InternalCallContext context) {
try {
final NotificationQueue checkOverdueQueue = notificationQueueService.getNotificationQueue(DefaultOverdueService.OVERDUE_SERVICE_NAME,
DefaultOverdueCheckNotifier.OVERDUE_CHECK_NOTIFIER_QUEUE);
@@ -126,7 +126,9 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
@Override
public Void inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
- final Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> futureNotifications = getFutureNotificationsForAccountAndOverdueableInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, overdueable, context);
+ final Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> futureNotifications = getFutureNotificationsForAccountAndOverdueableInTransaction(entitySqlDaoWrapperFactory, checkOverdueQueue, account
+
+ , context);
for (final NotificationEventWithMetadata<OverdueCheckNotificationKey> notification : futureNotifications) {
checkOverdueQueue.removeNotificationFromTransaction(entitySqlDaoWrapperFactory.getSqlDao(), notification.getRecordId());
}
@@ -142,7 +144,7 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
@VisibleForTesting
Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> getFutureNotificationsForAccountAndOverdueableInTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory,
final NotificationQueue checkOverdueQueue,
- final Blockable overdueable,
+ final Account account,
final InternalCallContext context) {
final List<NotificationEventWithMetadata<OverdueCheckNotificationKey>> notifications = checkOverdueQueue.getFutureNotificationFromTransactionForSearchKey1(OverdueCheckNotificationKey.class, context.getAccountRecordId(), entitySqlDaoWrapperFactory.getSqlDao());
@@ -151,7 +153,7 @@ public class DefaultOverdueCheckPoster implements OverdueCheckPoster {
@Override
public boolean apply(@Nullable final NotificationEventWithMetadata<OverdueCheckNotificationKey> input) {
final OverdueCheckNotificationKey notificationKey = input.getEvent();
- return (overdueable.getId().equals(notificationKey.getUuidKey()));
+ return (account.getId().equals(notificationKey.getUuidKey()));
}
});
diff --git a/overdue/src/main/java/com/ning/billing/ovedue/notification/OverdueCheckPoster.java b/overdue/src/main/java/com/ning/billing/ovedue/notification/OverdueCheckPoster.java
index 9f24c10..095cba7 100644
--- a/overdue/src/main/java/com/ning/billing/ovedue/notification/OverdueCheckPoster.java
+++ b/overdue/src/main/java/com/ning/billing/ovedue/notification/OverdueCheckPoster.java
@@ -18,12 +18,13 @@ package com.ning.billing.ovedue.notification;
import org.joda.time.DateTime;
+import com.ning.billing.account.api.Account;
import com.ning.billing.entitlement.api.Blockable;
import com.ning.billing.util.callcontext.InternalCallContext;
public interface OverdueCheckPoster {
- void insertOverdueCheckNotification(Blockable blockable, DateTime futureNotificationTime, final InternalCallContext context);
+ void insertOverdueCheckNotification(Account blockable, DateTime futureNotificationTime, final InternalCallContext context);
- void clearNotificationsFor(Blockable blockable, final InternalCallContext context);
+ void clearNotificationsFor(Account blockable, final InternalCallContext context);
}
diff --git a/overdue/src/test/java/com/ning/billing/ovedue/notification/TestDefaultOverdueCheckPoster.java b/overdue/src/test/java/com/ning/billing/ovedue/notification/TestDefaultOverdueCheckPoster.java
index 94e40ed..3bf770f 100644
--- a/overdue/src/test/java/com/ning/billing/ovedue/notification/TestDefaultOverdueCheckPoster.java
+++ b/overdue/src/test/java/com/ning/billing/ovedue/notification/TestDefaultOverdueCheckPoster.java
@@ -64,7 +64,7 @@ public class TestDefaultOverdueCheckPoster extends OverdueTestSuiteWithEmbeddedD
@Test(groups = "slow")
public void testShouldntInsertMultipleNotificationsPerOverdueable() throws Exception {
final UUID accountId = UUID.randomUUID();
- final Blockable overdueable = Mockito.mock(Account.class);
+ final Account overdueable = Mockito.mock(Account.class);
Mockito.when(overdueable.getId()).thenReturn(accountId);
insertOverdueCheckAndVerifyQueueContent(overdueable, 10, 10);
@@ -73,7 +73,7 @@ public class TestDefaultOverdueCheckPoster extends OverdueTestSuiteWithEmbeddedD
// Check we don't conflict with other overdueables
final UUID bundleId = UUID.randomUUID();
- final Blockable otherOverdueable = Mockito.mock(Account.class);
+ final Account otherOverdueable = Mockito.mock(Account.class);
Mockito.when(otherOverdueable.getId()).thenReturn(bundleId);
insertOverdueCheckAndVerifyQueueContent(otherOverdueable, 10, 10);
@@ -84,7 +84,7 @@ public class TestDefaultOverdueCheckPoster extends OverdueTestSuiteWithEmbeddedD
Assert.assertEquals(overdueQueue.getFutureNotificationForSearchKey1(OverdueCheckNotificationKey.class, internalCallContext.getAccountRecordId()).size(), 2);
}
- private void insertOverdueCheckAndVerifyQueueContent(final Blockable overdueable, final int nbDaysInFuture, final int expectedNbDaysInFuture) throws IOException {
+ private void insertOverdueCheckAndVerifyQueueContent(final Account overdueable, final int nbDaysInFuture, final int expectedNbDaysInFuture) throws IOException {
final DateTime futureNotificationTime = testReferenceTime.plusDays(nbDaysInFuture);
poster.insertOverdueCheckNotification(overdueable, futureNotificationTime, internalCallContext);
@@ -96,7 +96,7 @@ public class TestDefaultOverdueCheckPoster extends OverdueTestSuiteWithEmbeddedD
Assert.assertEquals(nm.getEffectiveDate(), testReferenceTime.plusDays(expectedNbDaysInFuture));
}
- private Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> getNotificationsForOverdueable(final Blockable overdueable) {
+ private Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> getNotificationsForOverdueable(final Account overdueable) {
return entitySqlDaoTransactionalJdbiWrapper.execute(new EntitySqlDaoTransactionWrapper<Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>>>() {
@Override
public Collection<NotificationEventWithMetadata<OverdueCheckNotificationKey>> inTransaction(final EntitySqlDaoWrapperFactory<EntitySqlDao> entitySqlDaoWrapperFactory) throws Exception {
diff --git a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
index 3a2b71d..8969799 100644
--- a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
+++ b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBase.java
@@ -244,11 +244,6 @@ public class DefaultSubscriptionBase extends EntityBase implements SubscriptionB
}
@Override
- public BlockingState getBlockingState() {
- throw new UnsupportedOperationException();
- }
-
- @Override
public SubscriptionBaseTransition getPendingTransition() {
if (transitions == null) {
return null;
diff --git a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBaseBundle.java b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBaseBundle.java
index a2312b6..581901d 100644
--- a/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBaseBundle.java
+++ b/subscription/src/main/java/com/ning/billing/subscription/api/user/DefaultSubscriptionBaseBundle.java
@@ -57,11 +57,6 @@ public class DefaultSubscriptionBaseBundle extends EntityBase implements Subscri
}
@Override
- public BlockingState getBlockingState() {
- throw new UnsupportedOperationException();
- }
-
- @Override
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append("DefaultSubscriptionBaseBundle");
diff --git a/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java b/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
index 189548f..e412721 100644
--- a/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
+++ b/util/src/test/java/com/ning/billing/mock/MockAccountBuilder.java
@@ -321,11 +321,6 @@ public class MockAccountBuilder {
}
@Override
- public BlockingState getBlockingState() {
- return null; // STEPH_ENT do we need it ? DefaultBlockingState.getClearState(BlockingStateType.ACCOUNT, );
- }
-
- @Override
public MutableAccountData toMutableAccountData() {
throw new UnsupportedOperationException();
}
diff --git a/util/src/test/java/com/ning/billing/mock/MockSubscription.java b/util/src/test/java/com/ning/billing/mock/MockSubscription.java
index 3ea3c4d..a498cea 100644
--- a/util/src/test/java/com/ning/billing/mock/MockSubscription.java
+++ b/util/src/test/java/com/ning/billing/mock/MockSubscription.java
@@ -115,11 +115,6 @@ public class MockSubscription implements SubscriptionBase {
}
@Override
- public BlockingState getBlockingState() {
- throw new UnsupportedOperationException();
- }
-
- @Override
public DateTime getCreatedDate() {
throw new UnsupportedOperationException();
}