boolean valid(int nodeId, MetadataImage image) {
        TopicImage topicImage = image.topics().getTopic(topicIdPartition.topicId());
        if (topicImage == null) {
            return false; // The topic has been deleted.
        }
        PartitionRegistration partition = topicImage.partitions().get(topicIdPartition.partitionId());
        if (partition == null) {
            return false; // The partition no longer exists.
        }
        // Check if this broker is still a replica.
        return Replicas.contains(partition.replicas, nodeId);
    }
@Test
    public void testAssignmentForNonExistentTopicIsNotValid() {
        assertFalse(new Assignment(
            new TopicIdPartition(Uuid.fromString("uuOi4qGPSsuM0QwnYINvOw"), 0),
            Uuid.fromString("rzRT8XZaSbKsP6j238zogg"),
            0,
            NoOpRunnable.INSTANCE).valid(0, TEST_IMAGE));
    }