This commit is contained in:
iliax 2023-08-07 19:30:27 +04:00
parent 94c460447e
commit a035232213

View file

@ -33,18 +33,10 @@ class MessagesProcessingTest {
var shuffled = new ArrayList<>(messagesInOrder);
Collections.shuffle(shuffled);
var sortedList = MessagesProcessing.sorted(shuffled, true).toList();
var sortedList = MessagesProcessing.sorted(shuffled, true);
assertThat(sortedList).containsExactlyElementsOf(messagesInOrder);
}
private ConsumerRecord<Bytes, Bytes> consumerRecord(int partition, long offset, String ts) {
return new ConsumerRecord<>(
"topic", partition, offset, OffsetDateTime.parse(ts).toInstant().toEpochMilli(),
TimestampType.CREATE_TIME,
0, 0, null, null, new RecordHeaders(), Optional.empty()
);
}
@RepeatedTest(5)
void testSortingDesc() {
var messagesInOrder = List.of(
@ -62,8 +54,16 @@ class MessagesProcessingTest {
var shuffled = new ArrayList<>(messagesInOrder);
Collections.shuffle(shuffled);
var sortedList = MessagesProcessing.sorted(shuffled, false).toList();
var sortedList = MessagesProcessing.sorted(shuffled, false);
assertThat(sortedList).containsExactlyElementsOf(messagesInOrder);
}
private ConsumerRecord<Bytes, Bytes> consumerRecord(int partition, long offset, String ts) {
return new ConsumerRecord<>(
"topic", partition, offset, OffsetDateTime.parse(ts).toInstant().toEpochMilli(),
TimestampType.CREATE_TIME,
0, 0, null, null, new RecordHeaders(), Optional.empty()
);
}
}