Skip to content

Commit a7e5ef1

Browse files
committed
test: fix flakiness
Signed-off-by: Pierre-Alexandre Meyer <pierre@mouraf.org>
1 parent f77e7b6 commit a7e5ef1

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

pom.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@
125125
<artifactId>org.apache.felix.framework</artifactId>
126126
<scope>provided</scope>
127127
</dependency>
128+
<dependency>
129+
<groupId>org.awaitility</groupId>
130+
<artifactId>awaitility</artifactId>
131+
<scope>test</scope>
132+
</dependency>
128133
<dependency>
129134
<groupId>org.jooby</groupId>
130135
<artifactId>jooby</artifactId>

src/test/java/org/killbill/billing/plugin/stripe/TestStripePaymentPluginApi.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@
2626
import java.util.List;
2727
import java.util.Map;
2828
import java.util.UUID;
29+
import java.util.concurrent.Callable;
30+
import java.util.concurrent.TimeUnit;
2931
import java.util.stream.Collectors;
3032

33+
import org.awaitility.Awaitility;
3134
import org.joda.time.Period;
3235
import org.killbill.billing.ObjectType;
3336
import org.killbill.billing.catalog.api.Currency;
@@ -537,11 +540,16 @@ public void testExpired3DSPurchase() throws PaymentPluginApiException, StripeExc
537540
// See getPending3DsPaymentExpirationPeriod
538541
clock.addDeltaFromReality(new Period("PT3H").toStandardDuration().getMillis());
539542

540-
final List<PaymentTransactionInfoPlugin> paymentTransactionInfoPluginExpired = stripePaymentPluginApi.getPaymentInfo(account.getId(),
541-
payment.getId(),
542-
ImmutableList.of(),
543-
context);
544-
assertEquals(paymentTransactionInfoPluginExpired.get(0).getStatus(), PaymentPluginStatus.CANCELED);
543+
Awaitility.await().atMost(5, TimeUnit.SECONDS).until(new Callable<>() {
544+
@Override
545+
public Boolean call() throws Exception {
546+
final List<PaymentTransactionInfoPlugin> paymentTransactionInfoPluginExpired = stripePaymentPluginApi.getPaymentInfo(account.getId(),
547+
payment.getId(),
548+
ImmutableList.of(),
549+
context);
550+
return PaymentPluginStatus.CANCELED.equals(paymentTransactionInfoPluginExpired.get(0).getStatus());
551+
}
552+
});
545553
}
546554

547555
@Test(groups = "integration")

0 commit comments

Comments
 (0)