zentol commented on code in PR #21127:
URL: https://github.com/apache/flink/pull/21127#discussion_r1001669758
##########
flink-clients/src/test/java/org/apache/flink/client/cli/CliFrontendListTest.java:
##########
@@ -28,21 +28,100 @@
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
-import org.mockito.Mockito;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
import java.util.concurrent.CompletableFuture;
+import java.util.stream.Collectors;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
/** Tests for the LIST command. */
class CliFrontendListTest extends CliFrontendTestBase {
+ private static final List<Long> TRICKY_START_TIMES =
+ Arrays.asList(
+ 1664177946934L,
Review Comment:
Should be easy enough to modify the code to make the testing easier.
```
private static void printJobStatusMessages(List<JobStatusMessage> jobs) {
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy
HH:mm:ss");
sortJobStatusMessages(jobs)
.forEachOrdered(
job ->
System.out.println(
dateFormat.format(new
Date(job.getStartTime()))
+ " : "
+ job.getJobId()
+ " : "
+ job.getJobName()
+ " ("
+ job.getJobState()
+ ")"));
}
@VisibleForTesting
static Stream<JobStatusMessage>
sortJobStatusMessages(List<JobStatusMessage> jobs) {
Comparator<JobStatusMessage> startTimeComparator =
(o1, o2) -> (int) (o1.getStartTime() - o2.getStartTime());
Comparator<Map.Entry<JobStatus, List<JobStatusMessage>>>
statusComparator =
(o1, o2) ->
String.CASE_INSENSITIVE_ORDER.compare(
o1.getKey().toString(),
o2.getKey().toString());
Map<JobStatus, List<JobStatusMessage>> jobsByState =
jobs.stream().collect(Collectors.groupingBy(JobStatusMessage::getJobState));
return jobsByState.entrySet().stream()
.sorted(statusComparator)
.map(Map.Entry::getValue)
.flatMap(List::stream)
.sorted(startTimeComparator);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]