AbstractPluginManager implements PluginManager { @Override public <T> List<T> getExtensions(Class<T> type) { return getExtensions(extensionFinder.find(type)); } AbstractPluginManager();  AbstractPluginManager(Path pluginsRoot); @Override void setSystemVersion(String version); @Override String getSystemVersion(); @Override List<PluginWrapper> getPlugins(); @Override List<PluginWrapper> getPlugins(PluginState pluginState); @Override List<PluginWrapper> getResolvedPlugins(); @Override List<PluginWrapper> getUnresolvedPlugins(); @Override List<PluginWrapper> getStartedPlugins(); @Override PluginWrapper getPlugin(String pluginId); @Override String loadPlugin(Path pluginPath); @Override void loadPlugins(); @Override void unloadPlugins(); @Override boolean unloadPlugin(String pluginId); @Override boolean deletePlugin(String pluginId); @Override void startPlugins(); @Override PluginState startPlugin(String pluginId); @Override void stopPlugins(); @Override PluginState stopPlugin(String pluginId); @Override boolean disablePlugin(String pluginId); @Override boolean enablePlugin(String pluginId); @Override ClassLoader getPluginClassLoader(String pluginId); @SuppressWarnings("rawtypes") @Override List<Class<?>> getExtensionClasses(String pluginId); @Override List<Class<? extends T>> getExtensionClasses(Class<T> type); @Override List<Class<? extends T>> getExtensionClasses(Class<T> type, String pluginId); @Override List<T> getExtensions(Class<T> type); @Override List<T> getExtensions(Class<T> type, String pluginId); @Override @SuppressWarnings("unchecked") List getExtensions(String pluginId); @Override Set<String> getExtensionClassNames(String pluginId); @Override ExtensionFactory getExtensionFactory(); PluginLoader getPluginLoader(); Path getPluginsRoot(); @Override RuntimeMode getRuntimeMode(); @Override PluginWrapper whichPlugin(Class<?> clazz); @Override synchronized void addPluginStateListener(PluginStateListener listener); @Override synchronized void removePluginStateListener(PluginStateListener listener); String getVersion(); boolean isExactVersionAllowed(); void setExactVersionAllowed(boolean exactVersionAllowed); @Override VersionManager getVersionManager(); static final String PLUGINS_DIR_PROPERTY_NAME; static final String MODE_PROPERTY_NAME; static final String DEFAULT_PLUGINS_DIR; static final String DEVELOPMENT_PLUGINS_DIR; }
@Test public void getExtensionsByType() { AbstractPluginManager pluginManager = mock(AbstractPluginManager.class, CALLS_REAL_METHODS); ExtensionFinder extensionFinder = mock(ExtensionFinder.class); List<ExtensionWrapper<TestExtensionPoint>> extensionList = new ArrayList<>(1); extensionList.add(new ExtensionWrapper<>(new ExtensionDescriptor(0, TestExtension.class), new DefaultExtensionFactory())); when(extensionFinder.find(TestExtensionPoint.class)).thenReturn(extensionList); pluginManager.extensionFinder = extensionFinder; List<TestExtensionPoint> extensions = pluginManager.getExtensions(TestExtensionPoint.class); assertEquals(1, extensions.size()); }