-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathawait
35 lines (28 loc) · 1.08 KB
/
await
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.awaitility.Awaitility;
import java.time.Duration;
import static org.awaitility.Awaitility.await;
@ExtendWith(SpringExtension.class)
@SpringBootTest
public class FeedStatusTest {
@Autowired
private FeedStatusRepository feedStatusRepository;
private static final Duration TIMEOUT = Duration.ofSeconds(30);
private static final Duration POLLING_INTERVAL = Duration.ofSeconds(2);
@Test
void waitForSuccessStatus() {
Long jobId = 1L; // Replace with your job ID
await()
.atMost(TIMEOUT)
.pollInterval(POLLING_INTERVAL)
.until(() -> isStatusSuccess(jobId));
}
private boolean isStatusSuccess(Long jobId) {
String status = feedStatusRepository.findStatusByJobId(jobId);
return "SUCCESS".equals(status);
}
}