killbill-memoizeit

payment: make killbill manage updated_date fields Don't

2/28/2012 2:29:06 PM

Details

diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java b/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
index fcccf9b..b099739 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentAttempt.java
@@ -60,7 +60,7 @@ public class PaymentAttempt {
         this.invoiceDate = invoiceDate;
         this.paymentAttemptDate = paymentAttemptDate == null ? new DateTime(DateTimeZone.UTC) : paymentAttemptDate;
         this.paymentId = paymentId;
-        this.retryCount = retryCount;
+        this.retryCount = retryCount == null ? 0 : retryCount;
         this.nextRetryDate = nextRetryDate;
         this.createdDate = createdDate == null ? new DateTime(DateTimeZone.UTC) : createdDate;
         this.updatedDate = updatedDate == null ? new DateTime(DateTimeZone.UTC) : updatedDate;
@@ -285,26 +285,32 @@ public class PaymentAttempt {
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (getClass() == obj.getClass()) {
-            PaymentAttempt other = (PaymentAttempt)obj;
-            if (obj == other) {
-                return true;
-            }
-            else {
-                return Objects.equal(paymentAttemptId, other.paymentAttemptId) &&
-                       Objects.equal(invoiceId, other.invoiceId) &&
-                       Objects.equal(accountId, other.accountId) &&
-                       Objects.equal(amount, other.amount) &&
-                       Objects.equal(currency, other.currency) &&
-                       Objects.equal(invoiceDate, other.invoiceDate) &&
-                       Objects.equal(paymentAttemptDate, other.paymentAttemptDate) &&
-                       Objects.equal(retryCount, other.retryCount) &&
-                       Objects.equal(nextRetryDate, other.nextRetryDate) &&
-                       Objects.equal(paymentId, other.paymentId);
-            }
-        }
-        return false;
+    public boolean equals(final Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final PaymentAttempt that = (PaymentAttempt) o;
+
+        if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) return false;
+        if (amount != null ? !(amount.compareTo(that.amount) == 0) : that.amount != null) return false;
+        if (createdDate != null ? !(getUnixTimestamp(createdDate) == getUnixTimestamp(that.createdDate)) : that.createdDate != null) return false;
+        if (currency != that.currency) return false;
+        if (invoiceDate != null ? !(getUnixTimestamp(invoiceDate) == getUnixTimestamp(that.invoiceDate)) : that.invoiceDate != null) return false;
+        if (invoiceId != null ? !invoiceId.equals(that.invoiceId) : that.invoiceId != null) return false;
+        if (nextRetryDate != null ? !(getUnixTimestamp(nextRetryDate) == getUnixTimestamp(that.nextRetryDate)) : that.nextRetryDate != null)
+            return false;
+        if (paymentAttemptDate != null ? !(getUnixTimestamp(paymentAttemptDate) == getUnixTimestamp(that.paymentAttemptDate)) : that.paymentAttemptDate != null)
+            return false;
+        if (paymentAttemptId != null ? !paymentAttemptId.equals(that.paymentAttemptId) : that.paymentAttemptId != null)
+            return false;
+        if (paymentId != null ? !paymentId.equals(that.paymentId) : that.paymentId != null) return false;
+        if (retryCount != null ? !retryCount.equals(that.retryCount) : that.retryCount != null) return false;
+        if (updatedDate != null ? !(getUnixTimestamp(updatedDate) == getUnixTimestamp(that.updatedDate)) : that.updatedDate != null) return false;
+
+        return true;
     }
 
+    private static long getUnixTimestamp(final DateTime dateTime) {
+        return dateTime.getMillis() / 1000;
+    }
 }
diff --git a/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java b/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
index 943c5f7..b0fbca6 100644
--- a/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
+++ b/api/src/main/java/com/ning/billing/payment/api/PaymentInfo.java
@@ -310,31 +310,34 @@ public class PaymentInfo implements BusEvent {
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (getClass() == obj.getClass()) {
-            PaymentInfo other = (PaymentInfo)obj;
-            if (obj == other) {
-                return true;
-            }
-            else {
-                return Objects.equal(amount, other.amount) &&
-                       Objects.equal(bankIdentificationNumber, other.bankIdentificationNumber) &&
-                       Objects.equal(paymentId, other.paymentId) &&
-                       Objects.equal(paymentNumber, other.paymentNumber) &&
-                       Objects.equal(referenceId, other.referenceId) &&
-                       Objects.equal(refundAmount, other.refundAmount) &&
-                       Objects.equal(status, other.status) &&
-                       Objects.equal(type, other.type) &&
-                       Objects.equal(paymentMethodId, other.paymentMethodId) &&
-                       Objects.equal(paymentMethod, other.paymentMethod) &&
-                       Objects.equal(cardType, other.cardType) &&
-                       Objects.equal(cardCoutry, other.cardCoutry) &&
-                       Objects.equal(effectiveDate, other.effectiveDate) &&
-                       Objects.equal(createdDate, other.createdDate) &&
-                       Objects.equal(updatedDate, other.updatedDate);
-            }
-        }
-        return false;
+    public boolean equals(final Object o) {
+        if (this == o) return true;
+        if (o == null || getClass() != o.getClass()) return false;
+
+        final PaymentInfo that = (PaymentInfo) o;
+
+        if (amount != null ? !(amount.compareTo(that.amount) == 0) : that.amount != null) return false;
+        if (bankIdentificationNumber != null ? !bankIdentificationNumber.equals(that.bankIdentificationNumber) : that.bankIdentificationNumber != null)
+            return false;
+        if (cardCoutry != null ? !cardCoutry.equals(that.cardCoutry) : that.cardCoutry != null) return false;
+        if (cardType != null ? !cardType.equals(that.cardType) : that.cardType != null) return false;
+        if (createdDate != null ? !(getUnixTimestamp(createdDate) == getUnixTimestamp(that.createdDate)) : that.createdDate != null) return false;
+        if (effectiveDate != null ? !(getUnixTimestamp(effectiveDate) == getUnixTimestamp(that.effectiveDate)) : that.effectiveDate != null)
+            return false;
+        if (paymentId != null ? !paymentId.equals(that.paymentId) : that.paymentId != null) return false;
+        if (paymentMethod != null ? !paymentMethod.equals(that.paymentMethod) : that.paymentMethod != null)
+            return false;
+        if (paymentMethodId != null ? !paymentMethodId.equals(that.paymentMethodId) : that.paymentMethodId != null)
+            return false;
+        if (paymentNumber != null ? !paymentNumber.equals(that.paymentNumber) : that.paymentNumber != null)
+            return false;
+        if (referenceId != null ? !referenceId.equals(that.referenceId) : that.referenceId != null) return false;
+        if (refundAmount != null ? !refundAmount.equals(that.refundAmount) : that.refundAmount != null) return false;
+        if (status != null ? !status.equals(that.status) : that.status != null) return false;
+        if (type != null ? !type.equals(that.type) : that.type != null) return false;
+        if (updatedDate != null ? !(getUnixTimestamp(updatedDate) == getUnixTimestamp(that.updatedDate)) : that.updatedDate != null) return false;
+
+        return true;
     }
 
     @Override
@@ -342,4 +345,7 @@ public class PaymentInfo implements BusEvent {
         return "PaymentInfo [paymentId=" + paymentId + ", amount=" + amount + ", refundAmount=" + refundAmount + ", paymentNumber=" + paymentNumber + ", bankIdentificationNumber=" + bankIdentificationNumber + ", status=" + status + ", type=" + type + ", referenceId=" + referenceId + ", paymentMethodId=" + paymentMethodId + ", paymentMethod=" + paymentMethod + ", cardType=" + cardType + ", cardCountry=" + cardCoutry + ", effectiveDate=" + effectiveDate + ", createdDate=" + createdDate + ", updatedDate=" + updatedDate + "]";
     }
 
+    private static long getUnixTimestamp(final DateTime dateTime) {
+        return dateTime.getMillis() / 1000;
+    }
 }
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java b/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
index a86db13..b505fa0 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/DefaultPaymentDao.java
@@ -16,9 +16,11 @@
 
 package com.ning.billing.payment.dao;
 
+import java.util.Date;
 import java.util.List;
 import java.util.UUID;
 
+import com.ning.billing.util.clock.Clock;
 import org.joda.time.DateTime;
 import org.skife.jdbi.v2.IDBI;
 
@@ -29,10 +31,12 @@ import com.ning.billing.payment.api.PaymentInfo;
 
 public class DefaultPaymentDao implements PaymentDao {
     private final PaymentSqlDao sqlDao;
+    private final Clock clock;
 
     @Inject
-    public DefaultPaymentDao(IDBI dbi) {
+    public DefaultPaymentDao(IDBI dbi, Clock clock) {
         this.sqlDao = dbi.onDemand(PaymentSqlDao.class);
+        this.clock = clock;
     }
 
     @Override
@@ -66,12 +70,12 @@ public class DefaultPaymentDao implements PaymentDao {
 
     @Override
     public void updatePaymentAttemptWithPaymentId(UUID paymentAttemptId, String paymentId) {
-        sqlDao.updatePaymentAttemptWithPaymentId(paymentAttemptId.toString(), paymentId);
+        sqlDao.updatePaymentAttemptWithPaymentId(paymentAttemptId.toString(), paymentId, clock.getUTCNow().toDate());
     }
 
     @Override
     public void updatePaymentInfo(String type, String paymentId, String cardType, String cardCountry) {
-        sqlDao.updatePaymentInfo(type, paymentId, cardType, cardCountry);
+        sqlDao.updatePaymentInfo(type, paymentId, cardType, cardCountry, clock.getUTCNow().toDate());
     }
 
     @Override
@@ -86,7 +90,8 @@ public class DefaultPaymentDao implements PaymentDao {
 
     @Override
     public void updatePaymentAttemptWithRetryInfo(UUID paymentAttemptId, int retryCount, DateTime nextRetryDate) {
-        sqlDao.updatePaymentAttemptWithRetryInfo(paymentAttemptId.toString(), retryCount, nextRetryDate);
+        final Date retryDate = nextRetryDate == null ? null : nextRetryDate.toDate();
+        sqlDao.updatePaymentAttemptWithRetryInfo(paymentAttemptId.toString(), retryCount, retryDate, clock.getUTCNow().toDate());
     }
 
     @Override
diff --git a/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java b/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
index 9919d34..ea564f3 100644
--- a/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
+++ b/payment/src/main/java/com/ning/billing/payment/dao/PaymentSqlDao.java
@@ -71,18 +71,22 @@ public interface PaymentSqlDao extends Transactional<PaymentSqlDao>, CloseMe, Tr
 
     @SqlUpdate
     void updatePaymentAttemptWithPaymentId(@Bind("payment_attempt_id") String paymentAttemptId,
-                                           @Bind("payment_id") String paymentId);
+                                           @Bind("payment_id") String paymentId,
+                                           @Bind("updated_dt") Date updatedDate);
 
     @SqlUpdate
     void updatePaymentAttemptWithRetryInfo(@Bind("payment_attempt_id") String paymentAttemptId,
                                            @Bind("retry_count") int retryCount,
-                                           @Bind("next_retry_dt") DateTime nextRetryDate);
+                                           @Bind("next_retry_dt") Date nextRetryDate,
+                                           @Bind("updated_dt") Date updatedDate);
 
     @SqlUpdate
+
     void updatePaymentInfo(@Bind("payment_method") String paymentMethod,
                            @Bind("payment_id") String paymentId,
                            @Bind("card_type") String cardType,
-                           @Bind("card_country") String cardCountry);
+                           @Bind("card_country") String cardCountry,
+                           @Bind("updated_dt") Date updatedDate);
 
     @SqlQuery
     @Mapper(PaymentInfoMapper.class)
diff --git a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
index 6576ecb..b349b5e 100644
--- a/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
+++ b/payment/src/main/resources/com/ning/billing/payment/dao/PaymentSqlDao.sql.stg
@@ -65,7 +65,7 @@ getPaymentAttemptForInvoiceId() ::= <<
 updatePaymentAttemptWithPaymentId() ::= <<
     UPDATE payment_attempts
        SET payment_id = :payment_id,
-           updated_dt = NOW()
+           updated_dt = :updated_dt
      WHERE payment_attempt_id = :payment_attempt_id
 >>
 
@@ -79,7 +79,7 @@ updatePaymentInfo() ::= <<
        SET payment_method = :payment_method,
            card_type = :card_type,
            card_country = :card_country,
-           updated_dt = NOW()
+           updated_dt = :updated_dt
      WHERE payment_id = :payment_id
 >>
 
@@ -87,7 +87,7 @@ updatePaymentAttemptWithRetryInfo() ::= <<
     UPDATE payment_attempts
        SET retry_count = :retry_count,
            next_retry_dt = :next_retry_dt,
-           updated_dt = NOW()
+           updated_dt = :updated_dt
      WHERE payment_attempt_id = :payment_attempt_id
 >>
 
diff --git a/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java b/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
index b245e55..10b81da 100644
--- a/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
+++ b/payment/src/test/java/com/ning/billing/payment/dao/MockPaymentDao.java
@@ -29,6 +29,7 @@ import com.google.common.collect.Collections2;
 import com.ning.billing.invoice.api.Invoice;
 import com.ning.billing.payment.api.PaymentAttempt;
 import com.ning.billing.payment.api.PaymentInfo;
+import org.joda.time.DateTimeZone;
 
 public class MockPaymentDao implements PaymentDao {
     private final Map<String, PaymentInfo> payments = new ConcurrentHashMap<String, PaymentInfo>();
@@ -86,7 +87,13 @@ public class MockPaymentDao implements PaymentDao {
     public void updatePaymentInfo(String paymentMethodType, String paymentId, String cardType, String cardCountry) {
         PaymentInfo existingPayment = payments.get(paymentId);
         if (existingPayment != null) {
-            PaymentInfo payment = existingPayment.cloner().setPaymentMethod(paymentMethodType).setCardType(cardType).setCardCountry(cardCountry).build();
+            PaymentInfo payment = existingPayment.cloner()
+                    .setPaymentMethod(paymentMethodType)
+                    .setCardType(cardType)
+                    .setCardCountry(cardCountry)
+                    // TODO pass the clock?
+                    .setUpdatedDate(new DateTime(DateTimeZone.UTC))
+                    .build();
             payments.put(paymentId, payment);
         }
     }
diff --git a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
index 18b0a15..6318d28 100644
--- a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
+++ b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDao.java
@@ -16,19 +16,18 @@
 
 package com.ning.billing.payment.dao;
 
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.UUID;
-
+import com.ning.billing.account.api.AccountApiException;
+import com.ning.billing.catalog.api.Currency;
+import com.ning.billing.payment.api.PaymentAttempt;
+import com.ning.billing.payment.api.PaymentInfo;
 import org.joda.time.DateTime;
 import org.joda.time.DateTimeZone;
 import org.testng.Assert;
 import org.testng.annotations.Test;
 
-import com.ning.billing.account.api.AccountApiException;
-import com.ning.billing.catalog.api.Currency;
-import com.ning.billing.payment.api.PaymentAttempt;
-import com.ning.billing.payment.api.PaymentInfo;
+import java.math.BigDecimal;
+import java.util.Arrays;
+import java.util.UUID;
 
 public abstract class TestPaymentDao {
 
@@ -37,35 +36,35 @@ public abstract class TestPaymentDao {
     @Test
     public void testCreatePayment() {
         PaymentInfo paymentInfo = new PaymentInfo.Builder().setPaymentId(UUID.randomUUID().toString())
-                                                           .setAmount(BigDecimal.TEN)
-                                                           .setStatus("Processed")
-                                                           .setBankIdentificationNumber("1234")
-                                                           .setPaymentNumber("12345")
-                                                           .setPaymentMethodId("12345")
-                                                           .setReferenceId("12345")
-                                                           .setType("Electronic")
-                                                           .setCreatedDate(new DateTime(DateTimeZone.UTC))
-                                                           .setUpdatedDate(new DateTime(DateTimeZone.UTC))
-                                                           .setEffectiveDate(new DateTime(DateTimeZone.UTC))
-                                                           .build();
+                .setAmount(BigDecimal.TEN)
+                .setStatus("Processed")
+                .setBankIdentificationNumber("1234")
+                .setPaymentNumber("12345")
+                .setPaymentMethodId("12345")
+                .setReferenceId("12345")
+                .setType("Electronic")
+                .setCreatedDate(new DateTime(DateTimeZone.UTC))
+                .setUpdatedDate(new DateTime(DateTimeZone.UTC))
+                .setEffectiveDate(new DateTime(DateTimeZone.UTC))
+                .build();
 
         paymentDao.savePaymentInfo(paymentInfo);
     }
 
     @Test
-    public void testUpdatePayment() {
+    public void testUpdatePaymenInfo() {
         PaymentInfo paymentInfo = new PaymentInfo.Builder().setPaymentId(UUID.randomUUID().toString())
-                                                           .setAmount(BigDecimal.TEN)
-                                                           .setStatus("Processed")
-                                                           .setBankIdentificationNumber("1234")
-                                                           .setPaymentNumber("12345")
-                                                           .setPaymentMethodId("12345")
-                                                           .setReferenceId("12345")
-                                                           .setType("Electronic")
-                                                           .setCreatedDate(new DateTime(DateTimeZone.UTC))
-                                                           .setUpdatedDate(new DateTime(DateTimeZone.UTC))
-                                                           .setEffectiveDate(new DateTime(DateTimeZone.UTC))
-                                                           .build();
+                .setAmount(BigDecimal.TEN)
+                .setStatus("Processed")
+                .setBankIdentificationNumber("1234")
+                .setPaymentNumber("12345")
+                .setPaymentMethodId("12345")
+                .setReferenceId("12345")
+                .setType("Electronic")
+                .setCreatedDate(new DateTime(DateTimeZone.UTC))
+                .setUpdatedDate(new DateTime(DateTimeZone.UTC))
+                .setEffectiveDate(new DateTime(DateTimeZone.UTC))
+                .build();
 
         paymentDao.savePaymentInfo(paymentInfo);
 
@@ -74,6 +73,24 @@ public abstract class TestPaymentDao {
     }
 
     @Test
+    public void testUpdatePaymentAttempt() {
+        PaymentAttempt paymentAttempt = new PaymentAttempt.Builder().setPaymentAttemptId(UUID.randomUUID())
+                .setPaymentId(UUID.randomUUID().toString())
+                .setInvoiceId(UUID.randomUUID())
+                .setAccountId(UUID.randomUUID())
+                .setAmount(BigDecimal.TEN)
+                .setCurrency(Currency.USD)
+                .setInvoiceDate(new DateTime(DateTimeZone.UTC))
+                .setCreatedDate(new DateTime(DateTimeZone.UTC))
+                .setUpdatedDate(new DateTime(DateTimeZone.UTC))
+                .build();
+
+        paymentDao.createPaymentAttempt(paymentAttempt);
+
+        paymentDao.updatePaymentAttemptWithRetryInfo(paymentAttempt.getPaymentAttemptId(), 1, paymentAttempt.getCreatedDate().plusDays(1));
+    }
+
+    @Test
     public void testGetPaymentForInvoice() throws AccountApiException {
         final UUID invoiceId = UUID.randomUUID();
         final UUID paymentAttemptId = UUID.randomUUID();
@@ -81,7 +98,8 @@ public abstract class TestPaymentDao {
         final String paymentId = UUID.randomUUID().toString();
         final BigDecimal invoiceAmount = BigDecimal.TEN;
 
-        final DateTime now = new DateTime(DateTimeZone.UTC);
+        // Move the clock backwards to test the updated_date field (see below)
+        final DateTime now = new DateTime(DateTimeZone.UTC).minusDays(1);
 
         PaymentAttempt originalPaymenAttempt = new PaymentAttempt(paymentAttemptId, invoiceId, accountId, invoiceAmount, Currency.USD, now, now, paymentId, null, null);
 
@@ -100,22 +118,25 @@ public abstract class TestPaymentDao {
         Assert.assertEquals(attempt3, attempt4);
 
         PaymentInfo originalPaymentInfo = new PaymentInfo.Builder().setPaymentId(paymentId)
-                                                           .setAmount(invoiceAmount)
-                                                           .setStatus("Processed")
-                                                           .setBankIdentificationNumber("1234")
-                                                           .setPaymentNumber("12345")
-                                                           .setPaymentMethodId("12345")
-                                                           .setReferenceId("12345")
-                                                           .setType("Electronic")
-                                                           .setCreatedDate(now)
-                                                           .setUpdatedDate(now)
-                                                           .setEffectiveDate(now)
-                                                           .build();
+                .setAmount(invoiceAmount)
+                .setStatus("Processed")
+                .setBankIdentificationNumber("1234")
+                .setPaymentNumber("12345")
+                .setPaymentMethodId("12345")
+                .setReferenceId("12345")
+                .setType("Electronic")
+                .setCreatedDate(now)
+                .setUpdatedDate(now)
+                .setEffectiveDate(now)
+                .build();
 
         paymentDao.savePaymentInfo(originalPaymentInfo);
         PaymentInfo paymentInfo = paymentDao.getPaymentInfo(Arrays.asList(invoiceId.toString())).get(0);
+        Assert.assertEquals(paymentInfo, originalPaymentInfo);
 
-        Assert.assertEquals(originalPaymentInfo, paymentInfo);
+        paymentDao.updatePaymentInfo(originalPaymentInfo.getPaymentMethod(), originalPaymentInfo.getPaymentId(), originalPaymentInfo.getCardType(), originalPaymentInfo.getCardCountry());
+        paymentInfo = paymentDao.getPaymentInfo(Arrays.asList(invoiceId.toString())).get(0);
+        Assert.assertEquals(paymentInfo.getCreatedDate().getMillis() / 1000, originalPaymentInfo.getCreatedDate().getMillis() / 1000);
+        Assert.assertTrue(paymentInfo.getUpdatedDate().isAfter(originalPaymentInfo.getUpdatedDate()));
     }
-
 }
diff --git a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDaoWithEmbeddedDb.java b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDaoWithEmbeddedDb.java
index 19ca39d..a5da11b 100644
--- a/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDaoWithEmbeddedDb.java
+++ b/payment/src/test/java/com/ning/billing/payment/dao/TestPaymentDaoWithEmbeddedDb.java
@@ -18,6 +18,7 @@ package com.ning.billing.payment.dao;
 
 import java.io.IOException;
 
+import com.ning.billing.util.clock.DefaultClock;
 import org.apache.commons.io.IOUtils;
 import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
@@ -45,6 +46,6 @@ public class TestPaymentDaoWithEmbeddedDb extends TestPaymentDao {
 
     @BeforeMethod(alwaysRun = true)
     public void setUp() throws IOException {
-        paymentDao = new DefaultPaymentDao(helper.getDBI());
+        paymentDao = new DefaultPaymentDao(helper.getDBI(), new DefaultClock());
     }
 }