killbill-aplcache

util: move RetryException to killbill-plugin-api Signed-off-by:

8/3/2017 2:46:00 PM

Details

diff --git a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithInvoicePlugin.java b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithInvoicePlugin.java
index 080f161..e24cc39 100644
--- a/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithInvoicePlugin.java
+++ b/beatrix/src/test/java/org/killbill/billing/beatrix/integration/TestWithInvoicePlugin.java
@@ -42,11 +42,11 @@ import org.killbill.billing.invoice.api.InvoiceItemType;
 import org.killbill.billing.invoice.model.TaxInvoiceItem;
 import org.killbill.billing.invoice.notification.DefaultNextBillingDateNotifier;
 import org.killbill.billing.invoice.plugin.api.InvoicePluginApi;
+import org.killbill.billing.invoice.plugin.api.InvoicePluginApiRetryException;
 import org.killbill.billing.osgi.api.OSGIServiceDescriptor;
 import org.killbill.billing.osgi.api.OSGIServiceRegistration;
 import org.killbill.billing.payment.api.PluginProperty;
 import org.killbill.billing.util.callcontext.CallContext;
-import org.killbill.billing.util.listener.RetryException;
 import org.killbill.billing.util.listener.RetryableService;
 import org.killbill.notificationq.api.NotificationEventWithMetadata;
 import org.killbill.notificationq.api.NotificationQueue;
@@ -253,7 +253,7 @@ public class TestWithInvoicePlugin extends TestIntegrationBase {
         @Override
         public List<InvoiceItem> getAdditionalInvoiceItems(final Invoice invoice, final boolean isDryRun, final Iterable<PluginProperty> pluginProperties, final CallContext callContext) {
             if (shouldThrowException) {
-                throw new RetryException();
+                throw new InvoicePluginApiRetryException();
             }
             return ImmutableList.<InvoiceItem>of(createTaxInvoiceItem(invoice));
         }

util/pom.xml 4(+4 -0)

diff --git a/util/pom.xml b/util/pom.xml
index 9f16602..330b5a3 100644
--- a/util/pom.xml
+++ b/util/pom.xml
@@ -213,6 +213,10 @@
             <artifactId>killbill-plugin-api-notification</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.kill-bill.billing.plugin</groupId>
+            <artifactId>killbill-plugin-api-invoice</artifactId>
+        </dependency>
+        <dependency>
             <groupId>org.kill-bill.commons</groupId>
             <artifactId>killbill-clock</artifactId>
         </dependency>
diff --git a/util/src/main/java/org/killbill/billing/util/listener/RetryableHandler.java b/util/src/main/java/org/killbill/billing/util/listener/RetryableHandler.java
index 7eda919..547e84c 100644
--- a/util/src/main/java/org/killbill/billing/util/listener/RetryableHandler.java
+++ b/util/src/main/java/org/killbill/billing/util/listener/RetryableHandler.java
@@ -21,6 +21,7 @@ import java.util.UUID;
 
 import org.joda.time.DateTime;
 import org.killbill.billing.callcontext.InternalCallContext;
+import org.killbill.billing.invoice.plugin.api.InvoicePluginApiRetryException;
 import org.killbill.billing.util.callcontext.CallOrigin;
 import org.killbill.billing.util.callcontext.InternalCallContextFactory;
 import org.killbill.billing.util.callcontext.UserType;
@@ -51,7 +52,7 @@ public class RetryableHandler implements NotificationQueueHandler {
     public void handleReadyNotification(final NotificationEvent notificationEvent, final DateTime eventDateTime, final UUID userToken, final Long searchKey1, final Long searchKey2) {
         try {
             handlerDelegate.handleReadyNotification(notificationEvent, eventDateTime, userToken, searchKey1, searchKey2);
-        } catch (final RetryException e) {
+        } catch (final InvoicePluginApiRetryException e) {
             // Let the retry queue handle the exception
             final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(searchKey2,
                                                                                                                  searchKey1,
diff --git a/util/src/main/java/org/killbill/billing/util/listener/RetryableService.java b/util/src/main/java/org/killbill/billing/util/listener/RetryableService.java
index 685e7b9..bd88ce4 100644
--- a/util/src/main/java/org/killbill/billing/util/listener/RetryableService.java
+++ b/util/src/main/java/org/killbill/billing/util/listener/RetryableService.java
@@ -24,6 +24,7 @@ import java.util.UUID;
 import org.joda.time.DateTime;
 import org.joda.time.Period;
 import org.killbill.billing.callcontext.InternalCallContext;
+import org.killbill.billing.invoice.plugin.api.InvoicePluginApiRetryException;
 import org.killbill.billing.util.callcontext.CallOrigin;
 import org.killbill.billing.util.callcontext.InternalCallContextFactory;
 import org.killbill.billing.util.callcontext.UserType;
@@ -86,7 +87,7 @@ public abstract class RetryableService {
                                                                          userToken,
                                                                          searchKey1,
                                                                          searchKey2);
-                        } catch (final RetryException e) {
+                        } catch (final InvoicePluginApiRetryException e) {
                             final InternalCallContext internalCallContext = internalCallContextFactory.createInternalCallContext(searchKey2,
                                                                                                                                  searchKey1,
                                                                                                                                  "RetryableService",
@@ -124,7 +125,7 @@ public abstract class RetryableService {
         }
     }
 
-    public void scheduleRetry(final RetryException exception,
+    public void scheduleRetry(final InvoicePluginApiRetryException exception,
                               final QueueEvent originalNotificationEvent,
                               final DateTime originalEffectiveDate,
                               final InternalCallContext context,
@@ -144,8 +145,8 @@ public abstract class RetryableService {
         }
     }
 
-    private DateTime computeRetryDate(final RetryException retryException, final DateTime initialEventDateTime, final int retryNb) {
-        final List<Period> retrySchedule = retryException.getRetrySchedule();
+    private DateTime computeRetryDate(final InvoicePluginApiRetryException invoicePluginApiRetryException, final DateTime initialEventDateTime, final int retryNb) {
+        final List<Period> retrySchedule = invoicePluginApiRetryException.getRetrySchedule();
         if (retrySchedule == null || retryNb > retrySchedule.size()) {
             return null;
         } else {
diff --git a/util/src/test/java/org/killbill/billing/util/listener/TestRetryableService.java b/util/src/test/java/org/killbill/billing/util/listener/TestRetryableService.java
index c09312f..3a104a0 100644
--- a/util/src/test/java/org/killbill/billing/util/listener/TestRetryableService.java
+++ b/util/src/test/java/org/killbill/billing/util/listener/TestRetryableService.java
@@ -30,6 +30,7 @@ import org.killbill.billing.callcontext.InternalTenantContext;
 import org.killbill.billing.events.BusInternalEvent;
 import org.killbill.billing.events.ControlTagCreationInternalEvent;
 import org.killbill.billing.events.ControlTagDeletionInternalEvent;
+import org.killbill.billing.invoice.plugin.api.InvoicePluginApiRetryException;
 import org.killbill.billing.util.UtilTestSuiteWithEmbeddedDB;
 import org.killbill.billing.util.listener.RetryableSubscriber.SubscriberAction;
 import org.killbill.billing.util.listener.RetryableSubscriber.SubscriberQueueHandler;
@@ -186,7 +187,7 @@ public class TestRetryableService extends UtilTestSuiteWithEmbeddedDB {
                                                  @Override
                                                  public void run(final ControlTagCreationInternalEvent event) {
                                                      if (throwRetryableException) {
-                                                         throw new RetryException(RETRY_SCHEDULE);
+                                                         throw new InvoicePluginApiRetryException(RETRY_SCHEDULE);
                                                      } else if (throwOtherException) {
                                                          throw new IllegalArgumentException("EXPECTED");
                                                      } else {