ServiceMonitorImpl implements ServiceMonitor, AntiServiceMonitor { @Override public ServiceModel getServiceModelSnapshot() { try (LatencyMeasurement measurement = metrics.startServiceModelSnapshotLatencyMeasurement()) { return modelGenerator.toServiceModel(duperModelManager.getApplicationInfos(), serviceStatusProvider); } } @Inject  ServiceMonitorImpl(DuperModelManager duperModelManager,
                              UnionMonitorManager monitorManager,
                              Metric metric,
                              Timer timer,
                              Zone zone);   ServiceMonitorImpl(MonitorManager monitorManager,
                       ServiceMonitorMetrics metrics,
                       DuperModelManager duperModelManager,
                       ModelGenerator modelGenerator); @Override ServiceModel getServiceModelSnapshot(); @Override Set<ApplicationInstanceReference> getAllApplicationInstanceReferences(); @Override Optional<ApplicationInstanceReference> getApplicationInstanceReference(HostName hostname); @Override Optional<ApplicationInstance> getApplication(HostName hostname); @Override Optional<ApplicationInstance> getApplication(ApplicationInstanceReference reference); @Override Optional<ApplicationInstance> getApplicationNarrowedTo(HostName hostname); @Override void registerListener(ServiceHostListener listener); @Override CriticalRegion disallowDuperModelLockAcquisition(String regionDescription);  }
@Test public void sanityCheck() { SlobrokMonitorManagerImpl slobrokMonitorManager = mock(SlobrokMonitorManagerImpl.class); DuperModelManager duperModelManager = mock(DuperModelManager.class); ModelGenerator modelGenerator = mock(ModelGenerator.class); ServiceMonitorImpl serviceMonitor = new ServiceMonitorImpl( slobrokMonitorManager, mock(ServiceMonitorMetrics.class), duperModelManager, modelGenerator); ApplicationInfo application1 = mock(ApplicationInfo.class); ApplicationInfo application2 = mock(ApplicationInfo.class); List<ApplicationInfo> applications = Stream.of(application1, application2) .collect(Collectors.toList()); when(duperModelManager.getApplicationInfos()).thenReturn(applications); ServiceModel serviceModel = serviceMonitor.getServiceModelSnapshot(); verify(duperModelManager, times(1)).getApplicationInfos(); verify(modelGenerator).toServiceModel(applications, slobrokMonitorManager); }