### Question:
NativePluginLoader implements PluginLoader { @Override public void loadInto(Application application) { Preconditions.checkNotNull(application, "Application cannot be null."); LOGGER.info("Loading plugins using the native ServiceLoader."); for (Plugin plugin : ServiceLoader.load(Plugin.class)) { LOGGER.debug("Loading Plugin: {}", plugin.getClass().getCanonicalName()); application.loadPlugin(plugin); } } NativePluginLoader(); static NativePluginLoader newLoader(); @Override void loadInto(Application application);  }### Answer:
@Test public void gets_plugins_from_serviceloader() { Plugin plugin1 = mock(Plugin.class); Plugin plugin2 = mock(Plugin.class); Plugin plugin3 = mock(Plugin.class); ServiceLoader dummyLoader = PowerMockito.mock(ServiceLoader.class); when(dummyLoader.iterator()).thenReturn(ImmutableList.of(plugin1, plugin2, plugin3).iterator()); PowerMockito.mockStatic(ServiceLoader.class); when(ServiceLoader.load(any(Class.class))).thenReturn(dummyLoader); pluginLoader.loadInto(application); verify(application).loadPlugin(eq(plugin1)); verify(application).loadPlugin(eq(plugin2)); verify(application).loadPlugin(eq(plugin3)); }