SamzaRestService { public void start() throws Exception { metricsReporters.forEach((reporterName, metricsReporter) -> { log.info("Registering the metrics reporter : {}, with source : {}.", reporterName, METRICS_SOURCE); metricsReporter.register(METRICS_SOURCE, metricsRegistry); log.info("Starting the metrics reporter : {}.", reporterName); metricsReporter.start(); }); log.info("Starting server on port {}", ((NetworkConnector) server.getConnectors()[0]).getPort()); server.start(); log.info("Server is running"); } SamzaRestService(Server server,
      ReadableMetricsRegistry metricsRegistry,
      Map<String, MetricsReporter> metricsReporters,
      ServletContextHandler context); static void main(String[] args); void addServlet(Servlet servlet, String path); void start(); void stop();  }
@Test public void testStartShouldStartTheMetricsReportersAndServer() throws Exception { NetworkConnector connector = Mockito.mock(NetworkConnector.class); int testServerPort = 100; Mockito.doReturn(testServerPort).when(connector).getPort(); Mockito.when(server.getConnectors()).thenReturn(new NetworkConnector[]{connector}); Mockito.doNothing().when(server).start(); samzaRestService.start(); Mockito.verify(metricsReporter).start(); Mockito.verify(metricsReporter).register("SamzaRest", metricsRegistry); Mockito.verify(server).start(); }