killbill-memoizeit

Details

diff --git a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
index f62e802..e2de445 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestJanitor.java
@@ -80,6 +80,8 @@ import static org.testng.Assert.fail;
 
 public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
 
+    private static final int TIMEOUT = 10;
+
     final PaymentOptions INVOICE_PAYMENT = new PaymentOptions() {
         @Override
         public boolean isExternalPayment() {
@@ -205,7 +207,7 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
     }
 
     @Test(groups = "slow")
-    public void testCreateSuccessRefundPaymentControlWithItemAdjustments() throws PaymentApiException, InvoiceApiException, EventBusException {
+    public void testCreateSuccessRefundPaymentControlWithItemAdjustments() throws Exception {
 
         final BigDecimal requestedAmount = BigDecimal.TEN;
         final UUID subscriptionId = UUID.randomUUID();
@@ -263,13 +265,14 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
         assertEquals(attempt2.getStateName(), "INIT");
 
         clock.addDays(1);
-        try {
-            Thread.sleep(1500);
-        } catch (InterruptedException e) {
-        }
 
-        final PaymentAttemptModelDao attempt3 = paymentDao.getPaymentAttempt(refundAttempt.getId(), internalCallContext);
-        assertEquals(attempt3.getStateName(), "SUCCESS");
+        await().atMost(TIMEOUT, TimeUnit.SECONDS).until(new Callable<Boolean>() {
+            @Override
+            public Boolean call() throws Exception {
+                final PaymentAttemptModelDao attempt3 = paymentDao.getPaymentAttempt(refundAttempt.getId(), internalCallContext);
+                return "SUCCESS".equals(attempt3.getStateName());
+            }
+        });
     }
 
     @Test(groups = "slow")
@@ -466,7 +469,7 @@ public class TestJanitor extends PaymentTestSuiteWithEmbeddedDB {
             Assert.assertEquals(updatedPayment.getTransactions().get(0).getTransactionStatus(), TransactionStatus.PENDING);
         }
 
-        await().atMost(5, TimeUnit.SECONDS).until(new Callable<Boolean>() {
+        await().atMost(TIMEOUT, TimeUnit.SECONDS).until(new Callable<Boolean>() {
             @Override
             public Boolean call() throws Exception {
                 return getPendingNotificationCnt(internalCallContext) == 0;
diff --git a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
index cbc23e5..f289f57 100644
--- a/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
+++ b/payment/src/test/java/org/killbill/billing/payment/TestRetryService.java
@@ -58,6 +58,8 @@ import static org.testng.Assert.fail;
 
 public class TestRetryService extends PaymentTestSuiteNoDB {
 
+    private static final int TIMEOUT = 10;
+
     private MockPaymentProviderPlugin mockPaymentProviderPlugin;
 
     @Override
@@ -174,7 +176,7 @@ public class TestRetryService extends PaymentTestSuiteNoDB {
         moveClockForFailureType(FailureType.PAYMENT_FAILURE, 0);
 
         try {
-            await().atMost(5, SECONDS).until(new Callable<Boolean>() {
+            await().atMost(TIMEOUT, SECONDS).until(new Callable<Boolean>() {
                 @Override
                 public Boolean call() throws Exception {
                     final List<PaymentAttemptModelDao> attempts = paymentDao.getPaymentAttempts(paymentExternalKey, internalCallContext);
@@ -260,7 +262,7 @@ public class TestRetryService extends PaymentTestSuiteNoDB {
             final int curFailureCondition = curFailure;
 
             try {
-                await().atMost(5, SECONDS).until(new Callable<Boolean>() {
+                await().atMost(TIMEOUT, SECONDS).until(new Callable<Boolean>() {
                     @Override
                     public Boolean call() throws Exception {
                         final List<PaymentAttemptModelDao> attempts = paymentDao.getPaymentAttempts(paymentExternalKey, internalCallContext);
@@ -345,7 +347,7 @@ public class TestRetryService extends PaymentTestSuiteNoDB {
             final int curFailureCondition = curFailure;
 
             try {
-                await().atMost(5, SECONDS).until(new Callable<Boolean>() {
+                await().atMost(TIMEOUT, SECONDS).until(new Callable<Boolean>() {
                     @Override
                     public Boolean call() throws Exception {
                         final List<PaymentAttemptModelDao> attempts = paymentDao.getPaymentAttempts(paymentExternalKey, internalCallContext);