From bcd9ac8c1a8d614e2bcaed8026d3e2300a291ef4 Mon Sep 17 00:00:00 2001 From: Bilal Al Date: Thu, 5 Sep 2024 13:29:56 -0700 Subject: [PATCH] tyring to work around sleep code smell --- .../java/io/split/client/SplitFactoryImplTest.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/test/java/io/split/client/SplitFactoryImplTest.java b/client/src/test/java/io/split/client/SplitFactoryImplTest.java index 0eaaf9ad..48b702b2 100644 --- a/client/src/test/java/io/split/client/SplitFactoryImplTest.java +++ b/client/src/test/java/io/split/client/SplitFactoryImplTest.java @@ -220,13 +220,22 @@ public void testFactoryConsumerInstantiationRetryReadiness() throws Exception { modifiersField.setAccessible(true); modifiersField.setInt(splitFactoryImpl, splitFactoryImpl.getModifiers() & ~Modifier.FINAL); splitFactoryImpl.set(splitFactory, userStorageWrapper); - Thread.sleep(2000); assertNotNull(splitFactory.client()); assertNotNull(splitFactory.manager()); - Thread.sleep(1000); + Thread.sleep(2000); + await().atMost(3, TimeUnit.SECONDS).until(didTheThing(userStorageWrapper)); Mockito.verify(userStorageWrapper, Mockito.times(2)).connect(); } + private Callable didTheThing(UserStorageWrapper userStorageWrapper) { + return new Callable() { + public Boolean call() throws Exception { + Thread.sleep(1000); + return true; + } + }; + } + @Test public void testFactoryConsumerDestroy() throws NoSuchFieldException, URISyntaxException, IllegalAccessException { CustomStorageWrapper customStorageWrapper = Mockito.mock(CustomStorageWrapper.class);