@Test
  public void startShutdownTestWithReporterFactory() throws Exception {
    Properties properties = new Properties();
    VerifiableProperties verifiableProperties = getVProps(properties);
    ClusterMap clusterMap = new MockClusterMap();
    NotificationSystem notificationSystem = new LoggingNotificationSystem();
    ObjectNameFactory spyObjectNameFactory = spy(new DefaultObjectNameFactory());
    Function<MetricRegistry, JmxReporter> reporterFactory =
        reporter -> JmxReporter.forRegistry(reporter).createsObjectNamesWith(spyObjectNameFactory).build();
    RestServer server =
        new RestServer(verifiableProperties, clusterMap, notificationSystem, SSL_FACTORY, Collections.emptyList(),
            reporterFactory);
    server.start();
    // check that the custom ObjectNameFactory specified in reporterFactory was used.
    verify(spyObjectNameFactory, atLeastOnce()).createName(anyString(), anyString(), anyString());
    server.shutdown();
    server.awaitShutdown();
  }
Tests {@link RestServer#start()} and {@link RestServer#shutdown()} with a custom {@link JmxReporter} factory.
@throws Exception
ambry-rest/src/test/java/com/github/ambry/rest/RestServerTest.java