Skip to content

Commit

Permalink
Replace hardcoded wait with loop
Browse files Browse the repository at this point in the history
  • Loading branch information
gmokki committed Apr 27, 2020
1 parent d430723 commit e74ce27
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
import static org.joda.time.Period.seconds;
import static org.junit.jupiter.api.Assertions.assertThrows;

import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;

import javax.ws.rs.NotFoundException;

Expand Down Expand Up @@ -76,7 +79,17 @@ public void createWorkflows() {
@Test
@Order(4)
public void waitForCleanup() throws InterruptedException {
SECONDS.sleep(6);
Set<Long> waiting = new HashSet<>(ids);
for (int i=0; i<10 && !waiting.isEmpty(); ++i) {
SECONDS.sleep(1);
for (Iterator<Long> it = waiting.iterator(); it.hasNext(); ) {
try {
getWorkflowInstance(it.next());
} catch (NotFoundException ex) {
it.remove();
}
}
}
}

@Test
Expand Down

0 comments on commit e74ce27

Please sign in to comment.