### Question:
ServiceProviders { @VisibleForTesting static <T> Iterable<T> getCandidatesViaHardCoded(Class<T> klass, Iterable<Class<?>> hardcoded) { List<T> list = new ArrayList<>(); for (Class<?> candidate : hardcoded) { list.add(create(klass, candidate)); } return list; } private  ServiceProviders(); static T load(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      PriorityAccessor<T> priorityAccessor); static List<T> loadAll(
      Class<T> klass,
      Iterable<Class<?>> hardcoded,
      ClassLoader cl,
      final PriorityAccessor<T> priorityAccessor); @VisibleForTesting static Iterable<T> getCandidatesViaServiceLoader(Class<T> klass, ClassLoader cl);  }### Answer:
@Test public void getCandidatesViaHardCoded_multipleProvider() throws Exception { Iterator<ServiceProvidersTestAbstractProvider> candidates = ServiceProviders.getCandidatesViaHardCoded( ServiceProvidersTestAbstractProvider.class, ImmutableList.<Class<?>>of( Available7Provider.class, Available0Provider.class)) .iterator(); assertEquals(Available7Provider.class, candidates.next().getClass()); assertEquals(Available0Provider.class, candidates.next().getClass()); assertFalse(candidates.hasNext()); }
@Test public void getCandidatesViaHardCoded_failAtInit() throws Exception { try { Iterable<ServiceProvidersTestAbstractProvider> ignored = ServiceProviders.getCandidatesViaHardCoded( ServiceProvidersTestAbstractProvider.class, Collections.<Class<?>>singletonList(FailAtInitProvider.class)); fail("Expected exception"); } catch (ServiceConfigurationError expected) { } }
@Test public void getCandidatesViaHardCoded_failAtInit_moreCandidates() throws Exception { try { Iterable<ServiceProvidersTestAbstractProvider> ignored = ServiceProviders.getCandidatesViaHardCoded( ServiceProvidersTestAbstractProvider.class, ImmutableList.<Class<?>>of(FailAtInitProvider.class, Available0Provider.class)); fail("Expected exception"); } catch (ServiceConfigurationError expected) { } }