killbill-memoizeit
Changes
payment/pom.xml 1(+1 -0)
Details
payment/pom.xml 1(+1 -0)
diff --git a/payment/pom.xml b/payment/pom.xml
index 6debb70..ee99669 100644
--- a/payment/pom.xml
+++ b/payment/pom.xml
@@ -170,6 +170,7 @@
<dependency>
<groupId>org.kill-bill.commons</groupId>
<artifactId>killbill-xmlloader</artifactId>
+ <version>0.2.29-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
diff --git a/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java b/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
index 72741f9..7bcf32e 100644
--- a/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
+++ b/payment/src/main/java/org/killbill/billing/payment/glue/PaymentModule.java
@@ -60,6 +60,7 @@ import org.killbill.commons.concurrent.WithProfilingThreadPoolExecutor;
import org.killbill.xmlloader.XMLLoader;
import org.skife.config.ConfigurationObjectFactory;
+import com.google.common.annotations.VisibleForTesting;
import com.google.common.io.Resources;
import com.google.inject.Key;
import com.google.inject.TypeLiteral;
@@ -76,6 +77,11 @@ public class PaymentModule extends KillBillModule {
public static final String STATE_MACHINE_RETRY = "RetryStateMachine";
public static final String STATE_MACHINE_PAYMENT = "PaymentStateMachine";
+ @VisibleForTesting
+ static final String DEFAULT_STATE_MACHINE_RETRY_XML = "org/killbill/billing/payment/retry/RetryStates.xml";
+ @VisibleForTesting
+ static final String DEFAULT_STATE_MACHINE_PAYMENT_XML = "org/killbill/billing/payment/PaymentStates.xml";
+
public PaymentModule(final KillbillConfigSource configSource) {
super(configSource);
}
@@ -106,11 +112,11 @@ public class PaymentModule extends KillBillModule {
protected void installStateMachines() {
- bind(StateMachineProvider.class).annotatedWith(Names.named(STATE_MACHINE_RETRY)).toInstance(new StateMachineProvider("org/killbill/billing/payment/retry/RetryStates.xml"));
+ bind(StateMachineProvider.class).annotatedWith(Names.named(STATE_MACHINE_RETRY)).toInstance(new StateMachineProvider(DEFAULT_STATE_MACHINE_RETRY_XML));
bind(StateMachineConfig.class).annotatedWith(Names.named(STATE_MACHINE_RETRY)).toProvider(Key.get(StateMachineProvider.class, Names.named(STATE_MACHINE_RETRY)));
bind(RetryStateMachineHelper.class).asEagerSingleton();
- bind(StateMachineProvider.class).annotatedWith(Names.named(STATE_MACHINE_PAYMENT)).toInstance(new StateMachineProvider("org/killbill/billing/payment/PaymentStates.xml"));
+ bind(StateMachineProvider.class).annotatedWith(Names.named(STATE_MACHINE_PAYMENT)).toInstance(new StateMachineProvider(DEFAULT_STATE_MACHINE_PAYMENT_XML));
bind(StateMachineConfig.class).annotatedWith(Names.named(STATE_MACHINE_PAYMENT)).toProvider(Key.get(StateMachineProvider.class, Names.named(STATE_MACHINE_PAYMENT)));
bind(PaymentStateMachineHelper.class).asEagerSingleton();
}
diff --git a/payment/src/test/java/org/killbill/billing/payment/glue/TestStateMachineProvider.java b/payment/src/test/java/org/killbill/billing/payment/glue/TestStateMachineProvider.java
new file mode 100644
index 0000000..7ab6922
--- /dev/null
+++ b/payment/src/test/java/org/killbill/billing/payment/glue/TestStateMachineProvider.java
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2014 Groupon, Inc
+ * Copyright 2014 The Billing Project, LLC
+ *
+ * The Billing Project 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 org.killbill.billing.payment.glue;
+
+import org.killbill.automaton.StateMachineConfig;
+import org.killbill.billing.payment.PaymentTestSuiteNoDB;
+import org.killbill.billing.payment.glue.PaymentModule.StateMachineProvider;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+public class TestStateMachineProvider extends PaymentTestSuiteNoDB {
+
+ @Test(groups = "fast", description = "https://github.com/killbill/killbill/issues/226")
+ public void testStateMachineProvider() throws Exception {
+ final StateMachineProvider retryStateMachineProvider = new StateMachineProvider(PaymentModule.DEFAULT_STATE_MACHINE_RETRY_XML);
+ final StateMachineConfig retryStateMachineConfig = retryStateMachineProvider.get();
+ Assert.assertEquals(retryStateMachineConfig.getStateMachines().length, 1);
+
+ final StateMachineProvider paymentStateMachineProvider = new StateMachineProvider(PaymentModule.DEFAULT_STATE_MACHINE_PAYMENT_XML);
+ final StateMachineConfig paymentStateMachineConfig = paymentStateMachineProvider.get();
+ Assert.assertEquals(paymentStateMachineConfig.getStateMachines().length, 8);
+ }
+}