Code review comment: Under the hood `isNotEmpty()`, `isEmpty()` check for is not null, also could be joined ```suggestion         assertThat(consumerFunction.getSubscribedPartitionsToStartOffsets())                 .isNotEmpty()                 .isEqualTo(expectedSubscribedPartitionsWithStartOffsets); ```

Code before review:
public void testRestoreFromEmptyStateWithPartitions() throws Exception {
final List<KafkaTopicPartition> partitions = new ArrayList<>(PARTITION_STATE.keySet());
final DummyFlinkKafkaConsumer<String> consumerFunction =
new DummyFlinkKafkaConsumer<>(
TOPICS, partitions, FlinkKafkaConsumerBase.PARTITION_DISCOVERY_DISABLED);
StreamSource<String, DummyFlinkKafkaConsumer<String>> consumerOperator =
new StreamSource<>(consumerFunction);
final AbstractStreamOperatorTestHarness<String> testHarness =
new AbstractStreamOperatorTestHarness<>(consumerOperator, 1, 1, 0);
testHarness.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
testHarness.setup();
testHarness.initializeState(
OperatorSnapshotUtil.getResourceFilename(
"kafka-consumer-migration-test-flink"
+ testMigrateVersion
+ "-empty-state-snapshot"));
testHarness.open();
final HashMap<KafkaTopicPartition, Long> expectedSubscribedPartitionsWithStartOffsets =
new HashMap<>();
for (KafkaTopicPartition partition : PARTITION_STATE.keySet()) {
expectedSubscribedPartitionsWithStartOffsets.put(
partition, KafkaTopicPartitionStateSentinel.EARLIEST_OFFSET);
}
assertThat(consumerFunction.getSubscribedPartitionsToStartOffsets()).isNotNull();
assertThat(!consumerFunction.getSubscribedPartitionsToStartOffsets().isEmpty()).isTrue();
assertThat(consumerFunction.getSubscribedPartitionsToStartOffsets())
.isEqualTo(expectedSubscribedPartitionsWithStartOffsets);
assertThat(consumerFunction.getRestoredState()).isNotNull();
assertThat(!consumerFunction.getSubscribedPartitionsToStartOffsets().isEmpty()).isTrue();
for (Map.Entry<KafkaTopicPartition, Long> expectedEntry :
expectedSubscribedPartitionsWithStartOffsets.entrySet()) {
assertThat(consumerFunction.getRestoredState().get(expectedEntry.getKey()))
.isEqualTo(expectedEntry.getValue());
}
consumerOperator.close();
consumerOperator.cancel();
}

Line under review: assertThat(!consumerFunction.getSubscribedPartitionsToStartOffsets().isEmpty()).isTrue();

Code after addressing the review:
public void testRestoreFromEmptyStateWithPartitions() throws Exception {
final List<KafkaTopicPartition> partitions = new ArrayList<>(PARTITION_STATE.keySet());
final DummyFlinkKafkaConsumer<String> consumerFunction =
new DummyFlinkKafkaConsumer<>(
TOPICS, partitions, FlinkKafkaConsumerBase.PARTITION_DISCOVERY_DISABLED);
StreamSource<String, DummyFlinkKafkaConsumer<String>> consumerOperator =
new StreamSource<>(consumerFunction);
final AbstractStreamOperatorTestHarness<String> testHarness =
new AbstractStreamOperatorTestHarness<>(consumerOperator, 1, 1, 0);
testHarness.setTimeCharacteristic(TimeCharacteristic.ProcessingTime);
testHarness.setup();
testHarness.initializeState(
OperatorSnapshotUtil.getResourceFilename(
"kafka-consumer-migration-test-flink"
+ testMigrateVersion
+ "-empty-state-snapshot"));
testHarness.open();
final HashMap<KafkaTopicPartition, Long> expectedSubscribedPartitionsWithStartOffsets =
new HashMap<>();
for (KafkaTopicPartition partition : PARTITION_STATE.keySet()) {
expectedSubscribedPartitionsWithStartOffsets.put(
partition, KafkaTopicPartitionStateSentinel.EARLIEST_OFFSET);
}
assertThat(consumerFunction.getSubscribedPartitionsToStartOffsets())
.isNotEmpty()
.isEqualTo(expectedSubscribedPartitionsWithStartOffsets);
assertThat(consumerFunction.getRestoredState()).isNotNull();
assertThat(consumerFunction.getSubscribedPartitionsToStartOffsets()).isNotEmpty();
for (Map.Entry<KafkaTopicPartition, Long> expectedEntry :
expectedSubscribedPartitionsWithStartOffsets.entrySet()) {
assertThat(consumerFunction.getRestoredState())
.containsEntry(expectedEntry.getKey(), expectedEntry.getValue());
}
consumerOperator.close();
consumerOperator.cancel();
}