killbill-memoizeit

Fix issue with context in RefundProcessor where accountRecord_id

2/5/2013 1:45:22 AM

Details

diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixIntegrationModule.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixIntegrationModule.java
index 6851311..076e883 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixIntegrationModule.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/BeatrixIntegrationModule.java
@@ -39,6 +39,7 @@ import com.ning.billing.beatrix.util.AuditChecker;
 import com.ning.billing.beatrix.util.EntitlementChecker;
 import com.ning.billing.beatrix.util.InvoiceChecker;
 import com.ning.billing.beatrix.util.PaymentChecker;
+import com.ning.billing.beatrix.util.RefundChecker;
 import com.ning.billing.catalog.api.CatalogService;
 import com.ning.billing.catalog.glue.CatalogModule;
 import com.ning.billing.dbi.DBIProvider;
@@ -134,6 +135,7 @@ public class BeatrixIntegrationModule extends AbstractModule {
         bind(EntitlementChecker.class).asEagerSingleton();
         bind(InvoiceChecker.class).asEagerSingleton();
         bind(PaymentChecker.class).asEagerSingleton();
+        bind(RefundChecker.class).asEagerSingleton();
         bind(AuditChecker.class).asEagerSingleton();
 
         installPublicBus();
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
index dfac2df..265a751 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestIntegrationBase.java
@@ -18,6 +18,7 @@ package com.ning.billing.beatrix.integration;
 
 import java.math.BigDecimal;
 import java.util.List;
+import java.util.Set;
 import java.util.UUID;
 
 import javax.annotation.Nullable;
@@ -49,6 +50,7 @@ import com.ning.billing.beatrix.util.AccountChecker;
 import com.ning.billing.beatrix.util.EntitlementChecker;
 import com.ning.billing.beatrix.util.InvoiceChecker;
 import com.ning.billing.beatrix.util.PaymentChecker;
+import com.ning.billing.beatrix.util.RefundChecker;
 import com.ning.billing.catalog.api.BillingPeriod;
 import com.ning.billing.catalog.api.Currency;
 import com.ning.billing.catalog.api.PlanPhaseSpecifier;
@@ -187,6 +189,9 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implemen
     protected ExternalBus externalBus;
 
     @Inject
+    protected RefundChecker refundChecker;
+
+    @Inject
     protected EntitlementChecker entitlementChecker;
 
     @Inject
@@ -414,6 +419,34 @@ public class TestIntegrationBase extends BeatrixTestSuiteWithEmbeddedDB implemen
         }, events);
     }
 
+    protected void refundPaymentWithAdjustmenttAndCheckForCompletion(final Account account, final Payment payment, final NextEvent... events) {
+        doCallAndCheckForCompletion(new Function<Void, Void>() {
+            @Override
+            public Void apply(@Nullable final Void input) {
+                try {
+                    paymentApi.createRefundWithAdjustment(account, payment.getId(), payment.getPaidAmount(), callContext);
+                } catch (PaymentApiException e) {
+                    fail(e.toString());
+                }
+                return null;
+            }
+        }, events);
+    }
+
+    protected void refundPaymentWithInvoiceItemAdjAndCheckForCompletion(final Account account, final Payment payment, final Set<UUID> invoiceItems, final NextEvent... events) {
+        doCallAndCheckForCompletion(new Function<Void, Void>() {
+            @Override
+            public Void apply(@Nullable final Void input) {
+                try {
+                    paymentApi.createRefundWithItemsAdjustments(account, payment.getId(), invoiceItems, callContext);
+                } catch (PaymentApiException e) {
+                    fail(e.toString());
+                }
+                return null;
+            }
+        }, events);
+    }
+
     protected void createChargeBackAndCheckForCompletion(final InvoicePayment payment, final NextEvent... events) {
         doCallAndCheckForCompletion(new Function<Void, Void>() {
             @Override
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java
new file mode 100644
index 0000000..d77e519
--- /dev/null
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/integration/TestPaymentRefund.java
@@ -0,0 +1,139 @@
+/*
+ * 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.beatrix.integration;
+
+import java.math.BigDecimal;
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+import org.joda.time.DateTime;
+import org.joda.time.LocalDate;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Guice;
+import org.testng.annotations.Test;
+
+import com.ning.billing.account.api.Account;
+import com.ning.billing.api.TestApiListener.NextEvent;
+import com.ning.billing.beatrix.util.InvoiceChecker.ExpectedInvoiceItemCheck;
+import com.ning.billing.beatrix.util.PaymentChecker.ExpectedPaymentCheck;
+import com.ning.billing.beatrix.util.RefundChecker.ExpectedRefundCheck;
+import com.ning.billing.catalog.api.BillingPeriod;
+import com.ning.billing.catalog.api.Currency;
+import com.ning.billing.catalog.api.ProductCategory;
+import com.ning.billing.entitlement.api.user.SubscriptionBundle;
+import com.ning.billing.entitlement.api.user.SubscriptionData;
+import com.ning.billing.invoice.api.Invoice;
+import com.ning.billing.invoice.api.InvoiceItem;
+import com.ning.billing.invoice.api.InvoiceItemType;
+import com.ning.billing.payment.api.Payment;
+import com.ning.billing.payment.api.PaymentStatus;
+
+import com.google.common.base.Function;
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+
+@Guice(modules = {BeatrixIntegrationModule.class})
+public class TestPaymentRefund extends TestIntegrationBase {
+
+    // Setup for all tests below
+    private Account account;
+    private Invoice invoice;
+    private Payment payment;
+    private Set<UUID> invoiceItems;
+    private DateTime initialCreationDate;
+    private int invoiceItemCount;
+
+    @BeforeMethod(groups = "slow")
+    public void setupTest() throws Exception {
+        super.setupTest();
+        invoiceItemCount = 1;
+        setupRefundTest();
+    }
+
+    @Test(groups = "slow")
+    public void testRefundWithNoAdjustments() throws Exception {
+        refundPaymentAndCheckForCompletion(account, payment);
+        refundChecker.checkRefund(payment.getId(), callContext, new ExpectedRefundCheck(payment.getId(), false, new BigDecimal("233.83"), Currency.USD, initialCreationDate.toLocalDate()));
+    }
+
+    @Test(groups = "slow")
+    public void testRefundWithInvoiceItemAdjustemts() throws Exception {
+        refundPaymentWithInvoiceItemAdjAndCheckForCompletion(account, payment, invoiceItems, NextEvent.INVOICE_ADJUSTMENT);
+        refundChecker.checkRefund(payment.getId(), callContext, new ExpectedRefundCheck(payment.getId(), true, new BigDecimal("233.83"), Currency.USD, initialCreationDate.toLocalDate()));
+        invoice = invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext,
+                                              new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2),
+                                                                           new LocalDate(2012, 3, 31), InvoiceItemType.RECURRING, new BigDecimal("233.83")),
+                                              new ExpectedInvoiceItemCheck(InvoiceItemType.ITEM_ADJ, new BigDecimal("-233.83")));
+    }
+
+    @Test(groups = "slow")
+    public void testRefundWithInvoiceAdjustment() throws Exception {
+        refundPaymentWithAdjustmenttAndCheckForCompletion(account, payment, NextEvent.INVOICE_ADJUSTMENT);
+        refundChecker.checkRefund(payment.getId(), callContext, new ExpectedRefundCheck(payment.getId(), true, new BigDecimal("233.83"), Currency.USD, initialCreationDate.toLocalDate()));
+        invoice = invoiceChecker.checkInvoice(account.getId(), invoiceItemCount++, callContext,
+                                              new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2),
+                                                                           new LocalDate(2012, 3, 31), InvoiceItemType.RECURRING, new BigDecimal("233.83")),
+                                              new ExpectedInvoiceItemCheck(InvoiceItemType.REFUND_ADJ, new BigDecimal("-233.83")));
+
+    }
+
+    private void setupRefundTest() throws Exception {
+
+        final int billingDay = 31;
+        initialCreationDate = new DateTime(2012, 2, 1, 0, 3, 42, 0, testTimeZone);
+
+        account = createAccountWithPaymentMethod(getAccountData(billingDay));
+
+        // set clock to the initial start date
+        clock.setTime(initialCreationDate);
+        final SubscriptionBundle bundle = entitlementUserApi.createBundleForAccount(account.getId(), "whatever", callContext);
+
+        invoiceItemCount = 0;
+
+        //
+        // CREATE SUBSCRIPTION AND EXPECT BOTH EVENTS: NextEvent.CREATE NextEvent.INVOICE
+        //
+        SubscriptionData subscription = subscriptionDataFromSubscription(createSubscriptionAndCheckForCompletion(bundle.getId(), "Shotgun", ProductCategory.BASE, BillingPeriod.MONTHLY, NextEvent.CREATE, NextEvent.INVOICE));
+        invoiceChecker.checkInvoice(account.getId(), ++invoiceItemCount, callContext, new ExpectedInvoiceItemCheck(initialCreationDate.toLocalDate(), null, InvoiceItemType.FIXED, new BigDecimal("0")));
+        // No end date for the trial item (fixed price of zero), and CTD should be today (i.e. when the trial started)
+        invoiceChecker.checkChargedThroughDate(subscription.getId(), clock.getUTCToday(), callContext);
+
+        setDateAndCheckForCompletion(new DateTime(2012, 3, 2, 23, 59, 59, 0, testTimeZone), NextEvent.PHASE, NextEvent.INVOICE, NextEvent.PAYMENT);
+        invoice = invoiceChecker.checkInvoice(account.getId(), ++invoiceItemCount, callContext, new ExpectedInvoiceItemCheck(new LocalDate(2012, 3, 2),
+                                                                                                                             new LocalDate(2012, 3, 31), InvoiceItemType.RECURRING, new BigDecimal("233.83")));
+        payment = paymentChecker.checkPayment(account.getId(), 1, callContext, new ExpectedPaymentCheck(new LocalDate(2012, 3, 2), new BigDecimal("233.83"), PaymentStatus.SUCCESS, invoice.getId(), Currency.USD));
+
+
+        // Filter and extract UUId from all Recuring invoices
+        invoiceItems = new HashSet<UUID>(Collections2.transform(Collections2.filter(invoice.getInvoiceItems(), new Predicate<InvoiceItem>() {
+            @Override
+            public boolean apply(@Nullable final InvoiceItem invoiceItem) {
+                return invoiceItem.getInvoiceItemType() == InvoiceItemType.RECURRING;
+            }
+        }), new Function<InvoiceItem, UUID>() {
+            @Nullable
+            @Override
+            public UUID apply(@Nullable final InvoiceItem invoiceItem) {
+                return invoiceItem.getId();
+            }
+        }));
+    }
+}
+
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/util/InvoiceChecker.java b/beatrix/src/test/java/com/ning/billing/beatrix/util/InvoiceChecker.java
index cad8138..c7fff39 100644
--- a/beatrix/src/test/java/com/ning/billing/beatrix/util/InvoiceChecker.java
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/util/InvoiceChecker.java
@@ -94,7 +94,7 @@ public class InvoiceChecker {
             boolean found = false;
             for (final InvoiceItem in : actual) {
                 // Match first on type and start date
-                if (in.getInvoiceItemType() != cur.getType() || (in.getStartDate().compareTo(cur.getStartDate()) != 0)) {
+                if (in.getInvoiceItemType() != cur.getType() || (cur.shouldCheckDates() && in.getStartDate().compareTo(cur.getStartDate()) != 0)) {
                     continue;
                 }
                 if (in.getAmount().compareTo(cur.getAmount()) != 0) {
@@ -103,7 +103,8 @@ public class InvoiceChecker {
                     continue;
                 }
 
-                if ((cur.getEndDate() == null && in.getEndDate() == null) ||
+                if (!cur.shouldCheckDates() ||
+                    (cur.getEndDate() == null && in.getEndDate() == null) ||
                     (cur.getEndDate() != null && in.getEndDate() != null && cur.getEndDate().compareTo(in.getEndDate()) == 0)) {
                     found = true;
                     break;
@@ -143,19 +144,34 @@ public class InvoiceChecker {
 
     public static class ExpectedInvoiceItemCheck {
 
+        private final boolean checkDates;
         private final LocalDate startDate;
         private final LocalDate endDate;
         private final InvoiceItemType type;
         private final BigDecimal Amount;
 
+
+        public ExpectedInvoiceItemCheck(final InvoiceItemType type, final BigDecimal amount) {
+            this.checkDates = false;
+            this.type = type;
+            this.startDate = null;
+            this.endDate = null;
+            Amount = amount;
+        }
+
         public ExpectedInvoiceItemCheck(final LocalDate startDate, final LocalDate endDate,
                                         final InvoiceItemType type, final BigDecimal amount) {
+            this.checkDates = true;
             this.startDate = startDate;
             this.endDate = endDate;
             this.type = type;
             Amount = amount;
         }
 
+        public boolean shouldCheckDates() {
+            return checkDates;
+        }
+
         public LocalDate getStartDate() {
             return startDate;
         }
diff --git a/beatrix/src/test/java/com/ning/billing/beatrix/util/RefundChecker.java b/beatrix/src/test/java/com/ning/billing/beatrix/util/RefundChecker.java
new file mode 100644
index 0000000..fbc0f7d
--- /dev/null
+++ b/beatrix/src/test/java/com/ning/billing/beatrix/util/RefundChecker.java
@@ -0,0 +1,140 @@
+/*
+ * 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.beatrix.util;
+
+import java.math.BigDecimal;
+import java.util.Collection;
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.Nullable;
+
+import org.joda.time.LocalDate;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testng.Assert;
+
+import com.ning.billing.beatrix.util.PaymentChecker.ExpectedPaymentCheck;
+import com.ning.billing.catalog.api.Currency;
+import com.ning.billing.invoice.api.InvoiceApiException;
+import com.ning.billing.invoice.api.InvoicePayment;
+import com.ning.billing.invoice.api.InvoicePayment.InvoicePaymentType;
+import com.ning.billing.invoice.api.InvoicePaymentApi;
+import com.ning.billing.invoice.api.InvoiceUserApi;
+import com.ning.billing.payment.api.Payment;
+import com.ning.billing.payment.api.PaymentApi;
+import com.ning.billing.payment.api.PaymentApiException;
+import com.ning.billing.payment.api.Refund;
+import com.ning.billing.util.callcontext.CallContext;
+
+import com.google.common.base.Predicate;
+import com.google.common.collect.Collections2;
+import com.google.inject.Inject;
+
+public class RefundChecker {
+
+    private static final Logger log = LoggerFactory.getLogger(RefundChecker.class);
+
+
+    private final PaymentApi paymentApi;
+    private final InvoicePaymentApi invoicePaymentApi;
+    private final AuditChecker auditChecker;
+    private final InvoiceUserApi invoiceUserApi;
+
+    @Inject
+    public RefundChecker(final PaymentApi paymentApi, final InvoicePaymentApi invoicePaymentApi, final InvoiceUserApi invoiceApi, final AuditChecker auditChecker) {
+        this.paymentApi = paymentApi;
+        this.invoicePaymentApi = invoicePaymentApi;
+        this.auditChecker = auditChecker;
+        this.invoiceUserApi = invoiceApi;
+    }
+
+    public Refund checkRefund(final UUID paymentId,  final CallContext context, ExpectedRefundCheck expected) throws PaymentApiException {
+
+        final List<Refund> refunds = paymentApi.getPaymentRefunds(paymentId, context);
+        Assert.assertEquals(refunds.size(), 1);
+
+        final InvoicePayment refundInvoicePayment = getInvoicePaymentEntry(paymentId, InvoicePaymentType.REFUND , context);
+        final InvoicePayment invoicePayment = getInvoicePaymentEntry(paymentId, InvoicePaymentType.ATTEMPT, context);
+
+        final Refund refund = refunds.get(0);
+        Assert.assertEquals(refund.getPaymentId(), expected.getPaymentId());
+        Assert.assertEquals(refund.getCurrency(), expected.getCurrency());
+        Assert.assertEquals(refund.isAdjusted(), expected.isAdjusted);
+        Assert.assertEquals(refund.getRefundAmount().compareTo(expected.getRefundAmount()), 0);
+
+        Assert.assertEquals(refundInvoicePayment.getPaymentId(), paymentId);
+        Assert.assertEquals(refundInvoicePayment.getLinkedInvoicePaymentId(), invoicePayment.getId());
+        Assert.assertEquals(refundInvoicePayment.getPaymentCookieId(), refund.getId());
+        Assert.assertEquals(refundInvoicePayment.getInvoiceId(), invoicePayment.getInvoiceId());
+        Assert.assertEquals(refundInvoicePayment.getAmount().compareTo(expected.getRefundAmount().negate()), 0);
+        Assert.assertEquals(refundInvoicePayment.getCurrency(), expected.getCurrency());
+
+        return refund;
+    }
+
+
+    private InvoicePayment getInvoicePaymentEntry(final UUID paymentId, final InvoicePaymentType type, final CallContext context) {
+        final List<InvoicePayment> invoicePayments =  invoicePaymentApi.getInvoicePayments(paymentId, context);
+        final Collection<InvoicePayment> refundInvoicePayments = Collections2.filter(invoicePayments, new Predicate<InvoicePayment>() {
+            @Override
+            public boolean apply(@Nullable final InvoicePayment invoicePayment) {
+                return invoicePayment.getType() == type && invoicePayment.getPaymentId().equals(paymentId);
+            }
+        });
+        Assert.assertEquals(refundInvoicePayments.size(), 1);
+        return refundInvoicePayments.iterator().next();
+    }
+
+
+    public static class ExpectedRefundCheck {
+
+        private final UUID paymentId;
+        private final boolean isAdjusted;
+        private final BigDecimal refundAmount;
+        private final Currency currency;
+        private final LocalDate refundDate;
+
+        public ExpectedRefundCheck(final UUID paymentId, final boolean adjusted, final BigDecimal refundAmount, final Currency currency, final LocalDate refundDate) {
+            this.paymentId = paymentId;
+            isAdjusted = adjusted;
+            this.refundAmount = refundAmount;
+            this.currency = currency;
+            this.refundDate = refundDate;
+        }
+
+        public UUID getPaymentId() {
+            return paymentId;
+        }
+
+        public boolean isAdjusted() {
+            return isAdjusted;
+        }
+
+        public BigDecimal getRefundAmount() {
+            return refundAmount;
+        }
+
+        public Currency getCurrency() {
+            return currency;
+        }
+
+        public LocalDate getRefundDate() {
+            return refundDate;
+        }
+    }
+}
diff --git a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
index baa5f0d..c826777 100644
--- a/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
+++ b/payment/src/main/java/com/ning/billing/payment/core/RefundProcessor.java
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.ning.billing.ErrorCode;
+import com.ning.billing.ObjectType;
 import com.ning.billing.account.api.Account;
 import com.ning.billing.account.api.AccountApiException;
 import com.ning.billing.invoice.api.InvoiceApiException;
@@ -170,7 +171,7 @@ public class RefundProcessor extends ProcessorBase {
 
                     paymentDao.updateRefundStatus(refundInfo.getId(), RefundStatus.COMPLETED, context);
 
-                    return new DefaultRefund(refundInfo.getId(),refundInfo.getCreatedDate(), refundInfo.getUpdatedDate(),
+                    return new DefaultRefund(refundInfo.getId(), refundInfo.getCreatedDate(), refundInfo.getUpdatedDate(),
                                              paymentId, refundInfo.getAmount(), account.getCurrency(),
                                              isAdjusted, refundInfo.getCreatedDate());
                 } catch (PaymentPluginApiException e) {
@@ -199,7 +200,7 @@ public class RefundProcessor extends ProcessorBase {
             BigDecimal amountFromItems = BigDecimal.ZERO;
             for (final UUID itemId : invoiceItemIdsWithAmounts.keySet()) {
                 amountFromItems = amountFromItems.add(Objects.firstNonNull(invoiceItemIdsWithAmounts.get(itemId),
-                        getAmountFromItem(items, itemId)));
+                                                                           getAmountFromItem(items, itemId)));
             }
 
             // Sanity check: if some items were specified, then the sum should be equal to specified refund amount, if specified
@@ -295,7 +296,11 @@ public class RefundProcessor extends ProcessorBase {
         }
 
         try {
-            final InternalCallContext context = internalCallContextFactory.createInternalCallContext(tenantContext.getTenantRecordId(), tenantContext.getAccountRecordId(), "RefundProcessor", CallOrigin.INTERNAL, UserType.SYSTEM, null);
+
+            // TODO context should be created for each refund and have the correct userToken
+            final InternalCallContext context = internalCallContextFactory.createInternalCallContext(refundsToBeFixed.iterator().next().getId(), ObjectType.REFUND, "RefundProcessor",
+                                                                                                     CallOrigin.INTERNAL, UserType.SYSTEM, null);
+
             final Account account = accountInternalApi.getAccountById(refundsToBeFixed.iterator().next().getAccountId(), context);
             new WithAccountLock<Void>().processAccountWithLock(locker, account.getExternalKey(), new WithAccountLockCallback<Void>() {
 
@@ -303,6 +308,7 @@ public class RefundProcessor extends ProcessorBase {
                 public Void doOperation() throws PaymentApiException {
                     try {
                         for (final RefundModelDao cur : refundsToBeFixed) {
+
                             // TODO - we currently don't save the items to be adjusted. If we crash, they won't be adjusted...
                             invoiceApi.createRefund(cur.getPaymentId(), cur.getAmount(), cur.isAdjusted(), ImmutableMap.<UUID, BigDecimal>of(), cur.getId(), context);
                             paymentDao.updateRefundStatus(cur.getId(), RefundStatus.COMPLETED, context);
diff --git a/util/src/test/java/com/ning/billing/mock/glue/TestDbiModule.java b/util/src/test/java/com/ning/billing/mock/glue/TestDbiModule.java
index 77dc191..4ad2ec0 100644
--- a/util/src/test/java/com/ning/billing/mock/glue/TestDbiModule.java
+++ b/util/src/test/java/com/ning/billing/mock/glue/TestDbiModule.java
@@ -19,6 +19,8 @@ package com.ning.billing.mock.glue;
 import org.skife.config.ConfigurationObjectFactory;
 import org.skife.jdbi.v2.IDBI;
 
+import com.ning.billing.GuicyKillbillTestSuiteWithEmbeddedDB;
+import com.ning.billing.GuicyKillbillTestWithEmbeddedDBModule;
 import com.ning.billing.KillbillTestSuiteWithEmbeddedDB;
 import com.ning.billing.dbi.DBIProvider;
 import com.ning.billing.dbi.DBTestingHelper;
@@ -28,7 +30,7 @@ import com.google.inject.AbstractModule;
 
 public class TestDbiModule extends AbstractModule {
     protected void configure() {
-        final DBTestingHelper helper = KillbillTestSuiteWithEmbeddedDB.getDBTestingHelper();
+        final DBTestingHelper helper = GuicyKillbillTestWithEmbeddedDBModule.getDBTestingHelper();
         if (helper.isUsingLocalInstance()) {
             bind(IDBI.class).toProvider(DBIProvider.class).asEagerSingleton();
             final DbiConfig config = new ConfigurationObjectFactory(System.getProperties()).build(DbiConfig.class);