@Test public void niceMessageWhenProviderNotFound() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("provider foo not in set of configured providers: [mock]"); Providers.getByName("foo"); }
public static Provider getByName(String providerName) { checkNotNull(providerName, "providerName"); Provider matchedProvider = null; List<String> providerNames = new ArrayList<String>(); for (Provider provider : list()) { if (provider.name().equals(providerName)) { matchedProvider = provider; break; } providerNames.add(provider.name()); } checkArgument(matchedProvider != null, "provider %s not in set of configured providers: %s", providerName, providerNames); return matchedProvider; }
Providers { public static Provider getByName(String providerName) { checkNotNull(providerName, "providerName"); Provider matchedProvider = null; List<String> providerNames = new ArrayList<String>(); for (Provider provider : list()) { if (provider.name().equals(providerName)) { matchedProvider = provider; break; } providerNames.add(provider.name()); } checkArgument(matchedProvider != null, "provider %s not in set of configured providers: %s", providerName, providerNames); return matchedProvider; } }
Providers { public static Provider getByName(String providerName) { checkNotNull(providerName, "providerName"); Provider matchedProvider = null; List<String> providerNames = new ArrayList<String>(); for (Provider provider : list()) { if (provider.name().equals(providerName)) { matchedProvider = provider; break; } providerNames.add(provider.name()); } checkArgument(matchedProvider != null, "provider %s not in set of configured providers: %s", providerName, providerNames); return matchedProvider; }  }
Providers { public static Provider getByName(String providerName) { checkNotNull(providerName, "providerName"); Provider matchedProvider = null; List<String> providerNames = new ArrayList<String>(); for (Provider provider : list()) { if (provider.name().equals(providerName)) { matchedProvider = provider; break; } providerNames.add(provider.name()); } checkArgument(matchedProvider != null, "provider %s not in set of configured providers: %s", providerName, providerNames); return matchedProvider; }  static Iterable<Provider> list(); static Provider getByName(String providerName); static Provider withUrl(Provider provider, String url); static Object instantiateModule(Provider in); static Object provide(denominator.Provider provider); }
Providers { public static Provider getByName(String providerName) { checkNotNull(providerName, "providerName"); Provider matchedProvider = null; List<String> providerNames = new ArrayList<String>(); for (Provider provider : list()) { if (provider.name().equals(providerName)) { matchedProvider = provider; break; } providerNames.add(provider.name()); } checkArgument(matchedProvider != null, "provider %s not in set of configured providers: %s", providerName, providerNames); return matchedProvider; }  static Iterable<Provider> list(); static Provider getByName(String providerName); static Provider withUrl(Provider provider, String url); static Object instantiateModule(Provider in); static Object provide(denominator.Provider provider);  }