### Question:
DefaultPluginPersistentState implements Serializable, PluginPersistentState { public Map<String, Boolean> getPluginStateMap(final Plugin plugin) { final Map<String, Boolean> state = new HashMap<String, Boolean>(getMap()); CollectionUtils.filter(state.keySet(), new StringStartsWith(plugin.getKey())); return state; } @Deprecated  DefaultPluginPersistentState(); @Deprecated  DefaultPluginPersistentState(final Map<String, Boolean> map);   DefaultPluginPersistentState(final Map<String, Boolean> map, final boolean ignore); @Deprecated  DefaultPluginPersistentState(final PluginPersistentState state); Map<String, Boolean> getMap(); boolean isEnabled(final Plugin plugin); boolean isEnabled(final ModuleDescriptor<?> pluginModule); Map<String, Boolean> getPluginStateMap(final Plugin plugin); PluginRestartState getPluginRestartState(final String pluginKey);  }### Answer:
@Test public void testDefaultModuleStateIsNotStored() { final String pluginKey = "mock.plugin.key"; StaticPlugin plugin = createMockPlugin(pluginKey, true); final PluginPersistentState.Builder builder = PluginPersistentState.Builder.create(); builder.setEnabled(plugin, true); Map<String, Boolean> pluginStateMap = builder.toState().getPluginStateMap(plugin); assertTrue(pluginStateMap.isEmpty()); builder.setEnabled(plugin, false); pluginStateMap = builder.toState().getPluginStateMap(plugin); assertFalse(pluginStateMap.isEmpty()); builder.removeState(pluginKey); plugin = createMockPlugin(pluginKey, false); builder.setEnabled(plugin, false); pluginStateMap = builder.toState().getPluginStateMap(plugin); assertTrue(pluginStateMap.isEmpty()); builder.setEnabled(plugin, true); pluginStateMap = builder.toState().getPluginStateMap(plugin); assertFalse(pluginStateMap.isEmpty()); }
@Test public void testGetPluginStateMap() { final StaticPlugin plugin1 = createMockPlugin("mock.plugin.key", true); final StaticPlugin plugin2 = createMockPlugin("two.mock.plugin.key", true); final ModuleDescriptor<?> module1 = createModule("mock.plugin.key", "module.key.1"); final ModuleDescriptor<?> module2 = createModule("mock.plugin.key", "module.key.2"); final ModuleDescriptor<?> module3 = createModule("mock.plugin.key", "module.key.3"); final PluginPersistentState.Builder builder = PluginPersistentState.Builder.create(); builder.setEnabled(plugin1, !plugin1.isEnabledByDefault()); builder.setEnabled(plugin2, !plugin1.isEnabledByDefault()); builder.setEnabled(module1, !module1.isEnabledByDefault()); builder.setEnabled(module2, !module2.isEnabledByDefault()); builder.setEnabled(module3, !module3.isEnabledByDefault()); final PluginPersistentState state = builder.toState(); final Map<String, Boolean> pluginStateMap = state.getPluginStateMap(plugin1); final PluginPersistentState pluginState = new DefaultPluginPersistentState(pluginStateMap); assertFalse(pluginState.isEnabled(plugin1) == plugin1.isEnabledByDefault()); assertFalse(pluginState.isEnabled(module1) == module1.isEnabledByDefault()); assertFalse(pluginState.isEnabled(module2) == module2.isEnabledByDefault()); assertFalse(pluginState.isEnabled(module3) == module3.isEnabledByDefault()); assertTrue(pluginState.isEnabled(plugin2) == plugin2.isEnabledByDefault()); }