public ServiceModel toServiceModel(List<ApplicationInfo> allApplicationInfos,
                                       ServiceStatusProvider serviceStatusProvider) {
        Map<ApplicationInstanceReference, ApplicationInstance> applicationInstances =
                allApplicationInfos.stream()
                        .map(info -> new ApplicationInstanceGenerator(info, zone)
                                .makeApplicationInstance(serviceStatusProvider))
                        .collect(Collectors.toMap(ApplicationInstance::reference, Function.identity()));

        return new ServiceModel(applicationInstances);
    }
@Test
    public void toApplicationModel() throws Exception {
        Zone zone = new Zone(Environment.from(ENVIRONMENT), RegionName.from(REGION));
        ModelGenerator modelGenerator = new ModelGenerator(zone);


        SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class);
        when(slobrokMonitorManager.getStatus(any(), any(), any(), any()))
                .thenReturn(new ServiceStatusInfo(ServiceStatus.UP));

        ServiceModel serviceModel =
                modelGenerator.toServiceModel(
                        getExampleApplicationInfos(),
                        slobrokMonitorManager);

        Map<ApplicationInstanceReference,
                ApplicationInstance> applicationInstances =
                serviceModel.getAllApplicationInstances();

        assertEquals(2, applicationInstances.size());

        Iterator<Map.Entry<ApplicationInstanceReference,
                        ApplicationInstance>> iterator =
                applicationInstances.entrySet().iterator();

        ApplicationInstance applicationInstance1 = iterator.next().getValue();
        ApplicationInstance applicationInstance2 = iterator.next().getValue();

        if (applicationInstance1.applicationInstanceId().equals(configServerApplication.getApplicationInstanceId())) {
            verifyConfigServerApplication(applicationInstance1);
            verifyOtherApplication(applicationInstance2);
        } else {
            verifyConfigServerApplication(applicationInstance2);
            verifyOtherApplication(applicationInstance1);
        }
    }