DefaultPluginStatusProvider implements PluginStatusProvider { @Override public void disablePlugin(String pluginId) { if (isPluginDisabled(pluginId)) { return; } if (Files.exists(getEnabledFilePath())) { enabledPlugins.remove(pluginId); try { FileUtils.writeLines(enabledPlugins, getEnabledFilePath()); } catch (IOException e) { throw new PluginRuntimeException(e); } } else { disabledPlugins.add(pluginId); try { FileUtils.writeLines(disabledPlugins, getDisabledFilePath()); } catch (IOException e) { throw new PluginRuntimeException(e); } } } DefaultPluginStatusProvider(Path pluginsRoot); @Override boolean isPluginDisabled(String pluginId); @Override void disablePlugin(String pluginId); @Override void enablePlugin(String pluginId); Path getEnabledFilePath(); Path getDisabledFilePath(); static Path getEnabledFilePath(Path pluginsRoot); static Path getDisabledFilePath(Path pluginsRoot);  }
@Test public void testDisablePlugin() throws Exception { createEnabledFile(); createDisabledFile(); PluginStatusProvider statusProvider = new DefaultPluginStatusProvider(pluginsPath); statusProvider.disablePlugin("plugin-1"); assertTrue(statusProvider.isPluginDisabled("plugin-1")); assertTrue(statusProvider.isPluginDisabled("plugin-2")); assertTrue(statusProvider.isPluginDisabled("plugin-3")); }