Skip to content

Commit

Permalink
Using awaitility to improve the consistency of the RSSSourceTest.
Browse files Browse the repository at this point in the history
Signed-off-by: David Venable <[email protected]>
  • Loading branch information
dlvenable committed Jul 12, 2023
1 parent d122289 commit 6d152bd
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import java.time.Duration;

import static org.awaitility.Awaitility.await;
import static org.mockito.ArgumentMatchers.anyCollection;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.atLeast;
Expand Down Expand Up @@ -62,9 +63,15 @@ public void tearDown() {
@Test
void test_ExecutorService_keep_writing_Events_to_Buffer() throws Exception {
rssSource.start(buffer);
Thread.sleep(pollingFrequency.toMillis());
await().atMost(pollingFrequency.multipliedBy(2))
.untilAsserted(() -> {
verify(buffer, atLeastOnce()).writeAll(anyCollection(), anyInt());
});
verify(buffer, atLeastOnce()).writeAll(anyCollection(), anyInt());
Thread.sleep(pollingFrequency.toMillis());
await().atMost(pollingFrequency.multipliedBy(2))
.untilAsserted(() -> {
verify(buffer, atLeast(2)).writeAll(anyCollection(), anyInt());
});
verify(buffer, atLeast(2)).writeAll(anyCollection(), anyInt());
}
}

0 comments on commit 6d152bd

Please sign in to comment.