Map<ServiceId, HealthEndpoint> extractHealthEndpoints(ApplicationInfo application) {
        Map<ServiceId, HealthEndpoint> endpoints = new HashMap<>();

        for (HostInfo hostInfo : application.getModel().getHosts()) {
            DomainName hostname = DomainName.of(hostInfo.getHostname());
            for (ServiceInfo serviceInfo : hostInfo.getServices()) {
                ServiceId serviceId = ApplicationInstanceGenerator.getServiceId(application, serviceInfo);
                for (PortInfo portInfo : serviceInfo.getPorts()) {
                    if (portTaggedWith(portInfo, HTTP_HEALTH_PORT_TAGS)) {
                        StateV1HealthEndpoint endpoint = new StateV1HealthEndpoint(
                                serviceId,
                                hostname,
                                portInfo.getPort(),
                                targetHealthStaleness,
                                requestTimeout,
                                connectionKeepAlive,
                                executor);
                        endpoints.put(serviceId, endpoint);
                        break; // Avoid >1 endpoints per serviceId
                    }
                }
            }
        }

        return endpoints;
    }
@Test
    public void test() {
        Map<ServiceId, HealthEndpoint> endpoints = model.extractHealthEndpoints(proxyHostApplicationInfo);
        assertEquals(2, endpoints.size());

        ApplicationId applicationId = ApplicationId.from("hosted-vespa", "proxy-host", "default");
        ClusterId clusterId = new ClusterId("proxy-host");
        ServiceId hostAdmin1 = new ServiceId(applicationId, clusterId, ServiceType.HOST_ADMIN, new ConfigId("proxy-host/host1"));
        ServiceId hostAdmin2 = new ServiceId(applicationId, clusterId, ServiceType.HOST_ADMIN, new ConfigId("proxy-host/host2"));

        HealthEndpoint endpoint1 = endpoints.get(hostAdmin1);
        assertNotNull(endpoint1);
        assertEquals("http://host1:8080/state/v1/health", endpoint1.description());

        HealthEndpoint endpoint2 = endpoints.get(hostAdmin2);
        assertNotNull(endpoint2);
        assertEquals("http://host2:8080/state/v1/health", endpoint2.description());

        Cancellable cancellable = mock(Cancellable.class);
        when(executor.scheduleWithFixedDelay(any(), any())).thenReturn(cancellable);
        try (HealthMonitor healthMonitor = endpoint1.startMonitoring()) {
            assertEquals(ServiceStatus.UNKNOWN, healthMonitor.getStatus().serviceStatus());
        }
    }