|
1 | 1 | package org.kohsuke.github; |
2 | 2 |
|
| 3 | +import org.assertj.core.util.Objects; |
3 | 4 | import org.awaitility.Awaitility; |
4 | 5 | import org.junit.Before; |
5 | 6 | import org.junit.Test; |
|
17 | 18 | import java.util.List; |
18 | 19 | import java.util.Optional; |
19 | 20 | import java.util.Scanner; |
| 21 | +import java.util.Spliterator; |
| 22 | +import java.util.Spliterators; |
20 | 23 | import java.util.function.Function; |
21 | 24 | import java.util.logging.Level; |
22 | 25 | import java.util.logging.Logger; |
23 | 26 | import java.util.stream.Collectors; |
| 27 | +import java.util.stream.StreamSupport; |
24 | 28 | import java.util.zip.ZipEntry; |
25 | 29 | import java.util.zip.ZipInputStream; |
26 | 30 |
|
@@ -523,9 +527,13 @@ public void testJobs() throws IOException { |
523 | 527 | latestPreexistingWorkflowRunId) |
524 | 528 | .orElseThrow(() -> new IllegalStateException("We must have a valid workflow run starting from here")); |
525 | 529 |
|
526 | | - List<GHWorkflowJob> jobs = workflowRun.listJobs() |
527 | | - .toList() |
528 | | - .stream() |
| 530 | + var endpointItems = workflowRun.listJobs().items(); |
| 531 | + var currentPage = endpointItems.getCurrentPage(); |
| 532 | + var firstPage = Objects.castIfBelongsToType(currentPage, GHWorkflowJobsPage.class); |
| 533 | + assertThat(firstPage.getTotalCount(), equalTo(2)); |
| 534 | + |
| 535 | + List<GHWorkflowJob> jobs = StreamSupport |
| 536 | + .stream(Spliterators.spliteratorUnknownSize(endpointItems, Spliterator.ORDERED), false) |
529 | 537 | .sorted((j1, j2) -> j1.getName().compareTo(j2.getName())) |
530 | 538 | .collect(Collectors.toList()); |
531 | 539 |
|
@@ -762,9 +770,13 @@ public void testStartupFailureConclusion() throws IOException { |
762 | 770 |
|
763 | 771 | GHWorkflow ghWorkflow = repo.getWorkflow("startup-failure-workflow.yml"); |
764 | 772 |
|
765 | | - List<GHWorkflowRun> ghWorkflowRunList = ghWorkflow.listRuns().toList(); |
| 773 | + var endpointItems = ghWorkflow.listRuns().items(); |
| 774 | + var currentPage = endpointItems.getCurrentPage(); |
| 775 | + var firstPage = Objects.castIfBelongsToType(currentPage, GHWorkflowRunsPage.class); |
| 776 | + assertThat(firstPage.getTotalCount(), equalTo(4)); |
766 | 777 |
|
767 | | - List<GHWorkflowRun> list = ghWorkflowRunList.stream() |
| 778 | + List<GHWorkflowRun> list = StreamSupport |
| 779 | + .stream(Spliterators.spliteratorUnknownSize(endpointItems, Spliterator.ORDERED), false) |
768 | 780 | .filter(ghWorkflowRun -> ghWorkflowRun.getConclusion().equals(Conclusion.STARTUP_FAILURE)) |
769 | 781 | .collect(Collectors.toList()); |
770 | 782 |
|
|
0 commit comments