AbstractExtensionFinder implements ExtensionFinder, PluginStateListener { @Override public Set<String> findClassNames(String pluginId) { return getEntries().get(pluginId); } AbstractExtensionFinder(PluginManager pluginManager); abstract Map<String, Set<String>> readPluginsStorages(); abstract Map<String, Set<String>> readClasspathStorages(); @Override @SuppressWarnings("unchecked") List<ExtensionWrapper<T>> find(Class<T> type); @Override @SuppressWarnings("unchecked") List<ExtensionWrapper<T>> find(Class<T> type, String pluginId); @Override List<ExtensionWrapper> find(String pluginId); @Override Set<String> findClassNames(String pluginId); @Override void pluginStateChanged(PluginStateEvent event); final boolean isCheckForExtensionDependencies(); void setCheckForExtensionDependencies(boolean checkForExtensionDependencies); static Extension findExtensionAnnotation(Class<?> clazz);  }
@Test public void testFindClassNames() { ExtensionFinder instance = new AbstractExtensionFinder(pluginManager) { @Override public Map<String, Set<String>> readPluginsStorages() { Map<String, Set<String>> entries = new LinkedHashMap<>(); Set<String> bucket = new HashSet<>(); bucket.add("org.pf4j.plugin.TestExtension"); entries.put("plugin1", bucket); return entries; } @Override public Map<String, Set<String>> readClasspathStorages() { Map<String, Set<String>> entries = new LinkedHashMap<>(); Set<String> bucket = new HashSet<>(); bucket.add("org.pf4j.plugin.TestExtension"); bucket.add("org.pf4j.plugin.FailTestExtension"); entries.put(null, bucket); return entries; } }; Set<String> result = instance.findClassNames(null); assertEquals(2, result.size()); result = instance.findClassNames("plugin1"); assertEquals(1, result.size()); }