public int distanceOf(PartitionTableView partitionTableView) {
        int distance = 0;
        for (int i = 0; i < partitions.length; i++) {
            distance += distanceOf(partitions[i], partitionTableView.partitions[i]);
        }
        return distance;
    }
@Test
    public void testDistance_whenSomeReplicasNull() throws Exception {
        // distanceOf([A, B, C, D...], [A, B, null...]) == count(null) * MAX_REPLICA_COUNT
        PartitionTableView table1 = createRandomPartitionTable();

        InternalPartition[] partitions = extractPartitions(table1);
        PartitionReplica[] replicas = partitions[0].getReplicasCopy();
        for (int i = 3; i < MAX_REPLICA_COUNT; i++) {
            replicas[i] = null;
        }
        partitions[0] = new ReadonlyInternalPartition(replicas, 0, partitions[0].version());
        PartitionTableView table2 = new PartitionTableView(partitions);

        assertEquals((MAX_REPLICA_COUNT - 3) * MAX_REPLICA_COUNT, table2.distanceOf(table1));
    }