@Test
public void testProtocolMetadataOrder() {

    RoundRobinAssignor roundRobin = new RoundRobinAssignor();
    RangeAssignor range = new RangeAssignor();
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(roundRobin, range),
                ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(roundRobin.name(), metadata.get(0).name());
        assertEquals(range.name(), metadata.get(1).name());
    }
    try (Metrics metrics = new Metrics(time)) {
        ConsumerCoordinator coordinator = buildCoordinator(metrics, Arrays.<PartitionAssignor>asList(range, roundRobin),
                ConsumerConfig.DEFAULT_EXCLUDE_INTERNAL_TOPICS, false);
        List<ProtocolMetadata> metadata = coordinator.metadata();
        assertEquals(2, metadata.size());
        assertEquals(range.name(), metadata.get(0).name());
        assertEquals(roundRobin.name(), metadata.get(1).name());
    }
}