@Override
    public String toString() {
        return String.format("Partition(topic = %s, partition = %d, leader = %s, replicas = %s, isr = %s, offlineReplicas = %s)",
                             topic,
                             partition,
                             leader == null ? "none" : leader.idString(),
                             formatNodeIds(replicas),
                             formatNodeIds(inSyncReplicas),
                             formatNodeIds(offlineReplicas));
    }
@Test
    public void testToString() {
        String topic = "sample";
        int partition = 0;
        Node leader = new Node(0, "localhost", 9092);
        Node r1 = new Node(1, "localhost", 9093);
        Node r2 = new Node(2, "localhost", 9094);
        Node[] replicas = new Node[] {leader, r1, r2};
        Node[] inSyncReplicas = new Node[] {leader, r1};
        Node[] offlineReplicas = new Node[] {r2};
        PartitionInfo partitionInfo = new PartitionInfo(topic, partition, leader, replicas, inSyncReplicas, offlineReplicas);

        String expected = String.format("Partition(topic = %s, partition = %d, leader = %s, replicas = %s, isr = %s, offlineReplicas = %s)",
                topic, partition, leader.idString(), "[0,1,2]", "[0,1]", "[2]");
        assertEquals(expected, partitionInfo.toString());
    }