ServiceManager { @SafeVarargs public final ServiceManager addModules(final Class<? extends Module>... modules) { addModules(modules != null ? asList(modules) : EMPTY_LIST); return this; }  final ServiceManager addConfiguration(@Nullable final String... configurations); final ServiceManager addConfiguration(final Collection<String> configuration); @SafeVarargs final ServiceManager addModules(final Class<? extends Module>... modules); final ServiceManager addModules(final Collection<Class<? extends Module>> modules); @SafeVarargs final ServiceManager addServices(final Class<? extends Service>... services); final ServiceManager addServices(final Collection<Class<? extends Service>> services); void start(); void stop();  }
@Test public void addModule() throws Exception { serviceManager.addModules(TestModule.class); ServiceResource<Class<? extends Module>> modules = getInternalState(serviceManager, "modules"); Collection<Class<? extends Module>> resources = modules.getResources(); assertThat(resources.size(), is(1)); assertThat(TestModule.class, isIn(resources)); }
@Test public void addModules() throws Exception { serviceManager.addModules(TestModule.class, AnotherTestModule.class); ServiceResource<Class<? extends Module>> modules = getInternalState(serviceManager, "modules"); Collection<Class<? extends Module>> resources = modules.getResources(); assertThat(resources.size(), is(2)); assertThat(TestModule.class, isIn(resources)); assertThat(AnotherTestModule.class, isIn(resources)); }
@Test public void addNullModule() throws Exception { serviceManager.addModules((Class<? extends Module>[]) null); ServiceResource<Class<? extends Module>> modules = getInternalState(serviceManager, "configurations"); Collection<Class<? extends Module>> resources = modules.getResources(); assertThat(resources, is(empty())); }
@Test public void addEmptyModule() throws Exception { serviceManager.addModules(); ServiceResource<Class<? extends Module>> modules = getInternalState(serviceManager, "configurations"); Collection<Class<? extends Module>> resources = modules.getResources(); assertThat(resources, is(empty())); }