public AtomicLong getNextIndex(String virtualHostname, boolean secure) {
        Map<String, VipIndexSupport> index = (secure) ? secureVirtualHostNameAppMap : virtualHostNameAppMap;
        return Optional.ofNullable(index.get(virtualHostname.toUpperCase(Locale.ROOT)))
                .map(VipIndexSupport::getRoundRobinIndex)
                .orElse(null);
    }
@Test
    public void testGetNextIndex() {
        DataCenterInfo myDCI = new DataCenterInfo() {
            public DataCenterInfo.Name getName() {
                return DataCenterInfo.Name.MyOwn;
            }
        };
        InstanceInfo instanceInfo = InstanceInfo.Builder.newBuilder()
                .setAppName("test")
                .setVIPAddress("test.testname:1")
                .setSecureVIPAddress("securetest.testname:7102")
                .setDataCenterInfo(myDCI)
                .setHostName("test.hostname")
                .setStatus(InstanceStatus.UP)
                .build();

        Application application = new Application("TestApp");
        application.addInstance(instanceInfo);

        Applications applications = new Applications();
        applications.addApplication(application);

        assertNotNull(applications.getNextIndex("test.testname:1", false));
        assertEquals(0L, applications.getNextIndex("test.testname:1", false).get());
        assertNotNull(applications.getNextIndex("securetest.testname:7102", true));
        assertEquals(0L, applications.getNextIndex("securetest.testname:7102", true).get());
        assertNotSame(applications.getNextIndex("test.testname:1", false), applications.getNextIndex("securetest.testname:7102", true));
    }