@Test
    public void testNodeIfOnlineNonExistentTopicPartition() {
        MetadataResponse metadataResponse = RequestTestUtils.metadataUpdateWith(2, Collections.emptyMap());
        metadata.updateWithCurrentRequestVersion(metadataResponse, false, 0L);

        TopicPartition tp = new TopicPartition("topic-1", 0);

        assertEquals(metadata.fetch().nodeById(0).id(), 0);
        assertNull(metadata.fetch().partition(tp));
        assertEquals(metadata.fetch().nodeIfOnline(tp, 0), Optional.empty());
    }
Prior to Kafka version 2.4 (which coincides with Metadata version 9), the broker does not propagate leader epoch
information accurately while a reassignment is in progress, so we cannot rely on it. This is explained in more
detail in MetadataResponse's constructor.
clients/src/test/java/org/apache/kafka/clients/MetadataTest.java