killbill-memoizeit
Changes
beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java 30(+14 -16)
osgi-bundles/bundles/meter/pom.xml 23(+15 -8)
pom.xml 9(+0 -9)
Details
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
index 54dc510..80e5b29 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/osgi/TestPaymentOSGIWithTestPaymentBundle.java
@@ -16,19 +16,6 @@
package com.ning.billing.beatrix.integration.osgi;
-import java.math.BigDecimal;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.UUID;
-
-import javax.inject.Inject;
-
-import org.joda.time.LocalDate;
-import org.testng.Assert;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
import com.ning.billing.account.api.Account;
import com.ning.billing.account.api.AccountData;
import com.ning.billing.api.TestApiListener.NextEvent;
@@ -48,6 +35,17 @@ import com.ning.billing.payment.api.PaymentStatus;
import com.ning.billing.payment.plugin.api.PaymentPluginApi;
import com.ning.billing.payment.plugin.api.PaymentPluginApiException;
import com.ning.billing.payment.plugin.api.PaymentPluginApiWithTestControl;
+import org.joda.time.LocalDate;
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.inject.Inject;
+import java.math.BigDecimal;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.UUID;
public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
@@ -159,10 +157,10 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
if (expectedException == null && expectedRuntimeException == null) {
expectedEvents.add(NextEvent.PAYMENT);
} else if (expectedException != null) {
- //expectedEvents.add(NextEvent.PAYMENT_ERROR);
+ expectedEvents.add(NextEvent.PAYMENT_PLUGIN_ERROR);
paymentPluginApi.setPaymentPluginApiExceptionOnNextCalls(expectedException);
} else if (expectedRuntimeException != null) {
- //expectedEvents.add(NextEvent.PAYMENT_ERROR);
+ expectedEvents.add(NextEvent.PAYMENT_PLUGIN_ERROR);
paymentPluginApi.setPaymentRuntimeExceptionOnNextCalls(expectedRuntimeException);
}
@@ -181,7 +179,7 @@ public class TestPaymentOSGIWithTestPaymentBundle extends TestOSGIBase {
private PaymentPluginApiWithTestControl getTestPluginPaymentApi() {
PaymentPluginApiWithTestControl result = (PaymentPluginApiWithTestControl) paymentPluginApiOSGIServiceRegistration.getServiceForName(BeatrixIntegrationModule.OSGI_PLUGIN_NAME);
- Assert.assertNotNull(result);
+ Assert.assertNotNull(result);
return result;
}
}
osgi-bundles/bundles/meter/pom.xml 23(+15 -8)
diff --git a/osgi-bundles/bundles/meter/pom.xml b/osgi-bundles/bundles/meter/pom.xml
index a505cc8..0bc7acc 100644
--- a/osgi-bundles/bundles/meter/pom.xml
+++ b/osgi-bundles/bundles/meter/pom.xml
@@ -1,12 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- ~ 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. -->
+<!--
+ ~ Copyright 2010-2013 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.
+ -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
diff --git a/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentPluginErrorEvent.java b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentPluginErrorEvent.java
new file mode 100644
index 0000000..28f24b3
--- /dev/null
+++ b/payment/src/main/java/com/ning/billing/payment/api/DefaultPaymentPluginErrorEvent.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2010-2013 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.payment.api;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.ning.billing.util.events.BusEventBase;
+import com.ning.billing.util.events.PaymentErrorInternalEvent;
+import com.ning.billing.util.events.PaymentPluginErrorInternalEvent;
+
+import java.util.UUID;
+
+public class DefaultPaymentPluginErrorEvent extends BusEventBase implements PaymentPluginErrorInternalEvent {
+
+ private final String message;
+ private final UUID accountId;
+ private final UUID invoiceId;
+ private final UUID paymentId;
+
+ @JsonCreator
+ public DefaultPaymentPluginErrorEvent(@JsonProperty("accountId") final UUID accountId,
+ @JsonProperty("invoiceId") final UUID invoiceId,
+ @JsonProperty("paymentId") final UUID paymentId,
+ @JsonProperty("message") final String message,
+ @JsonProperty("searchKey1") final Long searchKey1,
+ @JsonProperty("searchKey2") final Long searchKey2,
+ @JsonProperty("userToken") final UUID userToken) {
+ super(searchKey1, searchKey2, userToken);
+ this.message = message;
+ this.accountId = accountId;
+ this.invoiceId = invoiceId;
+ this.paymentId = paymentId;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public UUID getAccountId() {
+ return accountId;
+ }
+
+ public UUID getInvoiceId() {
+ return invoiceId;
+ }
+
+ public UUID getPaymentId() {
+ return paymentId;
+ }
+
+ @JsonIgnore
+ @Override
+ public BusInternalEventType getBusEventType() {
+ return BusInternalEventType.PAYMENT_ERROR;
+ }
+
+ @Override
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof DefaultPaymentPluginErrorEvent)) {
+ return false;
+ }
+
+ final DefaultPaymentPluginErrorEvent that = (DefaultPaymentPluginErrorEvent) o;
+
+ if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) {
+ return false;
+ }
+ if (invoiceId != null ? !invoiceId.equals(that.invoiceId) : that.invoiceId != null) {
+ return false;
+ }
+ if (message != null ? !message.equals(that.message) : that.message != null) {
+ return false;
+ }
+ if (paymentId != null ? !paymentId.equals(that.paymentId) : that.paymentId != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = message != null ? message.hashCode() : 0;
+ result = 31 * result + (accountId != null ? accountId.hashCode() : 0);
+ result = 31 * result + (invoiceId != null ? invoiceId.hashCode() : 0);
+ result = 31 * result + (paymentId != null ? paymentId.hashCode() : 0);
+ return result;
+ }
+}
diff --git a/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
index a18ddd1..eeb652f 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/PaymentProcessor.java
@@ -30,6 +30,13 @@ import java.util.concurrent.TimeoutException;
import javax.annotation.Nullable;
import javax.inject.Inject;
+import com.ning.billing.payment.api.DefaultPayment;
+import com.ning.billing.payment.api.DefaultPaymentErrorEvent;
+import com.ning.billing.payment.api.DefaultPaymentInfoEvent;
+import com.ning.billing.payment.api.DefaultPaymentPluginErrorEvent;
+import com.ning.billing.payment.api.Payment;
+import com.ning.billing.payment.api.PaymentApiException;
+import com.ning.billing.payment.api.PaymentStatus;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -40,12 +47,6 @@ import com.ning.billing.bus.api.PersistentBus;
import com.ning.billing.invoice.api.Invoice;
import com.ning.billing.invoice.api.InvoiceApiException;
import com.ning.billing.osgi.api.OSGIServiceRegistration;
-import com.ning.billing.payment.api.DefaultPayment;
-import com.ning.billing.payment.api.DefaultPaymentErrorEvent;
-import com.ning.billing.payment.api.DefaultPaymentInfoEvent;
-import com.ning.billing.payment.api.Payment;
-import com.ning.billing.payment.api.PaymentApiException;
-import com.ning.billing.payment.api.PaymentStatus;
import com.ning.billing.payment.dao.PaymentAttemptModelDao;
import com.ning.billing.payment.dao.PaymentDao;
import com.ning.billing.payment.dao.PaymentModelDao;
@@ -332,6 +333,7 @@ public class PaymentProcessor extends ProcessorBase {
}
public void retryPluginFailure(final UUID paymentId, final InternalCallContext context) {
+
retryFailedPaymentInternal(paymentId, context, PaymentStatus.PLUGIN_FAILURE);
}
@@ -558,6 +560,9 @@ public class PaymentProcessor extends ProcessorBase {
paymentDao.updateStatusAndEffectiveDateForPaymentWithAttempt(paymentInput.getId(), paymentStatus, clock.getUTCNow(), attemptInput.getId(), null, e.getMessage(), context);
+ event = new DefaultPaymentPluginErrorEvent(account.getId(), invoice.getId(), paymentInput.getId(), e.getMessage(),
+ context.getAccountRecordId(), context.getTenantRecordId(), context.getUserToken()
+ );
throw new PaymentApiException(ErrorCode.PAYMENT_CREATE_PAYMENT, account.getId(), e.toString());
} catch (InvoiceApiException e) {
pom.xml 9(+0 -9)
diff --git a/pom.xml b/pom.xml
index 7c5e8ab..1eadbc7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -57,13 +57,4 @@
<properties>
<killbill.version>${project.version}</killbill.version>
</properties>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>12.0</version>
- </dependency>
- </dependencies>
- </dependencyManagement>
</project>
diff --git a/util/src/main/java/com/ning/billing/util/events/PaymentPluginErrorInternalEvent.java b/util/src/main/java/com/ning/billing/util/events/PaymentPluginErrorInternalEvent.java
new file mode 100644
index 0000000..a85270e
--- /dev/null
+++ b/util/src/main/java/com/ning/billing/util/events/PaymentPluginErrorInternalEvent.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2010-2013 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.util.events;
+
+import java.util.UUID;
+
+
+public interface PaymentPluginErrorInternalEvent extends BusInternalEvent {
+
+ public String getMessage();
+
+ public UUID getInvoiceId();
+
+ public UUID getAccountId();
+
+ public UUID getPaymentId();
+}
diff --git a/util/src/test/java/com/ning/billing/api/TestApiListener.java b/util/src/test/java/com/ning/billing/api/TestApiListener.java
index aa92992..e01ff24 100644
--- a/util/src/test/java/com/ning/billing/api/TestApiListener.java
+++ b/util/src/test/java/com/ning/billing/api/TestApiListener.java
@@ -22,19 +22,19 @@ import java.util.Stack;
import javax.inject.Inject;
-import org.joda.time.DateTime;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import com.ning.billing.util.events.CustomFieldEvent;
import com.ning.billing.util.events.EffectiveSubscriptionInternalEvent;
import com.ning.billing.util.events.InvoiceAdjustmentInternalEvent;
import com.ning.billing.util.events.InvoiceCreationInternalEvent;
import com.ning.billing.util.events.PaymentErrorInternalEvent;
import com.ning.billing.util.events.PaymentInfoInternalEvent;
+import com.ning.billing.util.events.PaymentPluginErrorInternalEvent;
import com.ning.billing.util.events.RepairEntitlementInternalEvent;
import com.ning.billing.util.events.TagDefinitionInternalEvent;
import com.ning.billing.util.events.TagInternalEvent;
+import org.joda.time.DateTime;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Joiner;
import com.google.common.eventbus.Subscribe;
@@ -75,6 +75,7 @@ public class TestApiListener {
INVOICE_ADJUSTMENT,
PAYMENT,
PAYMENT_ERROR,
+ PAYMENT_PLUGIN_ERROR,
REPAIR_BUNDLE,
TAG,
TAG_DEFINITION,
@@ -189,6 +190,12 @@ public class TestApiListener {
assertEqualsNicely(NextEvent.PAYMENT_ERROR);
notifyIfStackEmpty();
}
+ @Subscribe
+ public void handlePaymentPluginErrorEvents(final PaymentPluginErrorInternalEvent event) {
+ log.info(String.format("Got PaymentPluginError event %s", event.toString()));
+ assertEqualsNicely(NextEvent.PAYMENT_PLUGIN_ERROR);
+ notifyIfStackEmpty();
+ }
public void reset() {
synchronized (this) {