ManifestPluginDescriptorFinder implements PluginDescriptorFinder { @Override public PluginDescriptor find(Path pluginPath) { Manifest manifest = readManifest(pluginPath); return createPluginDescriptor(manifest); }  @Override boolean isApplicable(Path pluginPath); @Override PluginDescriptor find(Path pluginPath); static final String PLUGIN_ID; static final String PLUGIN_DESCRIPTION; static final String PLUGIN_CLASS; static final String PLUGIN_VERSION; static final String PLUGIN_PROVIDER; static final String PLUGIN_DEPENDENCIES; static final String PLUGIN_REQUIRES; static final String PLUGIN_LICENSE; }
@Test public void testFind() throws Exception { PluginDescriptorFinder descriptorFinder = new ManifestPluginDescriptorFinder(); PluginDescriptor plugin1 = descriptorFinder.find(pluginsPath.resolve("test-plugin-1")); PluginDescriptor plugin2 = descriptorFinder.find(pluginsPath.resolve("test-plugin-2")); assertEquals("test-plugin-1", plugin1.getPluginId()); assertEquals("Test Plugin 1", plugin1.getPluginDescription()); assertEquals("org.pf4j.plugin.TestPlugin", plugin1.getPluginClass()); assertEquals("0.0.1", plugin1.getVersion()); assertEquals("Decebal Suiu", plugin1.getProvider()); assertEquals(2, plugin1.getDependencies().size()); assertEquals("test-plugin-2", plugin1.getDependencies().get(0).getPluginId()); assertEquals("test-plugin-3", plugin1.getDependencies().get(1).getPluginId()); assertEquals("~1.0", plugin1.getDependencies().get(1).getPluginVersionSupport()); assertEquals("Apache-2.0", plugin1.getLicense()); assertTrue(versionManager.checkVersionConstraint("1.0.0", plugin1.getRequires())); assertEquals("test-plugin-2", plugin2.getPluginId()); assertEquals("", plugin2.getPluginDescription()); assertEquals("org.pf4j.plugin.TestPlugin", plugin2.getPluginClass()); assertEquals("0.0.1", plugin2.getVersion()); assertEquals("Decebal Suiu", plugin2.getProvider()); assertEquals(0, plugin2.getDependencies().size()); assertTrue(versionManager.checkVersionConstraint("1.0.0", plugin2.getRequires())); }
@Test public void testFindNotFound() { PluginDescriptorFinder descriptorFinder = new ManifestPluginDescriptorFinder(); assertThrows(PluginRuntimeException.class, () -> descriptorFinder.find(pluginsPath.resolve("test-plugin-3"))); }