GroovyRuntimeFactory { public GroovyRuntime create(final ClassLoader classLoader) { checkNotNull(classLoader); Iterator<GroovyRuntime> services = findServices(classLoader); checkState(services.hasNext(), "No GroovyRuntime service found"); GroovyRuntime runtime = services.next(); checkState(!services.hasNext(), "Multiple GroovyRuntime services found"); log.debug("Runtime: {}", runtime); return runtime; }  GroovyRuntime create(final ClassLoader classLoader);  }
@Test(expected = IllegalStateException.class) public void create_noServices() { underTest.create(classLoader); fail(); }
@Test(expected = IllegalStateException.class) public void create_multipuleServices() { services.add(mock(GroovyRuntime.class)); services.add(mock(GroovyRuntime.class)); underTest.create(classLoader); fail(); }
@Test public void create_singleService() { services.add(mock(GroovyRuntime.class)); GroovyRuntime runtime = underTest.create(classLoader); assertThat(runtime, notNullValue()); }