@Override
    public boolean shouldFailover(SortedSet<BrokerStatus> brokerStatus) {
        return this.autoFailoverPolicy.shouldFailoverToSecondary(brokerStatus);
    }
@Test
    public void testShouldFailover() throws Exception {
        NamespaceIsolationPolicyImpl defaultPolicy = this.getDefaultPolicy();
        List<BrokerStatus> brokerStatus = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            BrokerStatus status = BrokerStatus.builder()
                    .brokerAddress(String.format("broker-%s", i))
                    .active(true)
                    .loadFactor(i * 10)
                    .build();
            brokerStatus.add(status);
        }
        assertFalse(defaultPolicy.shouldFailover(new TreeSet<>(brokerStatus)));
        for (int i = 0; i < 8; i++) {
            brokerStatus.set(i, BrokerStatus.builder()
                    .brokerAddress(brokerStatus.get(i).getBrokerAddress())
                    .active(false)
                    .loadFactor(brokerStatus.get(i).getLoadFactor())
                    .build());
        }
        assertTrue(defaultPolicy.shouldFailover(new TreeSet<>(brokerStatus)));
        brokerStatus.set(7, BrokerStatus.builder()
                .brokerAddress(brokerStatus.get(7).getBrokerAddress())
                .active(true)
                .loadFactor(brokerStatus.get(7).getLoadFactor())
                .build());
        assertTrue(defaultPolicy.shouldFailover(new TreeSet<>(brokerStatus)));
        brokerStatus.set(9, BrokerStatus.builder()
                .brokerAddress(brokerStatus.get(9).getBrokerAddress())
                .active(brokerStatus.get(9).isActive())
                .loadFactor(80)
                .build());
        assertFalse(defaultPolicy.shouldFailover(new TreeSet<>(brokerStatus)));

        brokerStatus = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            BrokerStatus status = BrokerStatus.builder().brokerAddress(String.format("broker-%d", 2 * i))
                    .active(true)
                    .loadFactor(i * 20)
                    .build();
            brokerStatus.add(status);
            status = BrokerStatus.builder()
                    .brokerAddress(String.format("broker-%d", 2 * i + 1))
                    .active(true)
                    .loadFactor(i * 20)
                    .build();
            brokerStatus.add(status);
        }
        assertEquals(brokerStatus.size(), 10);
    }