ServiceManager { public final ServiceManager addConfiguration(@Nullable final String... configurations) { addConfiguration(configurations != null ? asList(configurations) : 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 addConfiguration() throws Exception { serviceManager.addConfiguration("foo"); ServiceResource<String> configurations = getInternalState(serviceManager, "configurations"); Collection<String> resources = configurations.getResources(); assertThat(resources.size(), is(1)); assertThat(resources, hasItem("foo")); }
@Test public void addConfigurationsAsVargs() throws Exception { serviceManager.addConfiguration("foo", "bar"); ServiceResource<String> configurations = getInternalState(serviceManager, "configurations"); Collection<String> resources = configurations.getResources(); assertThat(resources.size(), is(2)); assertThat(resources, hasItems("foo", "bar")); }
@Test public void addConfigurationsAsCollection() throws Exception { serviceManager.addConfiguration(asList("foo", "bar")); ServiceResource<String> configurations = getInternalState(serviceManager, "configurations"); Collection<String> resources = configurations.getResources(); assertThat(resources.size(), is(2)); assertThat(resources, hasItems("foo", "bar")); }
@Test public void addNullConfiguration() throws Exception { serviceManager.addConfiguration((String) null); ServiceResource<String> configurations = getInternalState(serviceManager, "configurations"); Collection<String> resources = configurations.getResources(); assertThat(resources, is(empty())); }
@Test public void addEmptyConfiguration() throws Exception { serviceManager.addConfiguration(); ServiceResource<String> configurations = getInternalState(serviceManager, "configurations"); Collection<String> resources = configurations.getResources(); assertThat(resources, is(empty())); }
@Ignore @Test(expected = IllegalStateException.class) public void addConfigurationWhenStarted() throws Exception { field(ServiceManager.class, "serviceManager").set(serviceManager, internalServiceManager); serviceManager.addConfiguration("foo"); }