### Question:
ModuleStateManagerImpl implements ModuleStateManager { @Override public Collection<? extends String> getModulesThatCanSaveState() { Collection<String> moduleNames = New.set(); synchronized (myControllerMap) { for (Entry<String, List<Reference<ModuleStateController>>> entry : myControllerMap.entrySet()) { for (Reference<ModuleStateController> ref : entry.getValue()) { ModuleStateController moduleStateController = ref.get(); if (moduleStateController != null && moduleStateController.canSaveState() && !moduleStateController.isAlwaysSaveState()) { moduleNames.add(entry.getKey()); } } } } return moduleNames; } ModuleStateManagerImpl(PreferencesRegistry preferencesRegistry); @Override void deactivateAllStates(); @Override Collection<String> detectModules(Node node); @Override Collection<String> detectModules(StateType state); @Override Collection<? extends String> getActiveStateIds(); @Override Collection<? extends String> getModuleNames(); @Override Collection<? extends String> getModulesThatCanSaveState(); @Override Collection<? extends String> getModulesThatSaveStateByDefault(); @Override Collection<String> getRegisteredStateIds(); @Override StateType getState(String state); @Override Map<String, Collection<? extends String>> getStateDependenciesForModules(Collection<? extends String> modules); @Override String getStateDescription(String state); @Override Collection<? extends String> getStateTags(String state); @Override boolean isStateActive(String state); @Override void registerModuleStateController(String moduleName, ModuleStateController controller); @Override void registerState(String id, String description, Collection<? extends String> tags,
            Collection<? extends String> modules, Element element); @Override void registerState(String id, String description, Collection<? extends String> tags,
            Collection<? extends String> modules, StateType state); @Override void saveState(String id, String description, Collection<? extends String> tags, Collection<? extends String> modules,
            Node parentNode); @Override void saveState(String id, String description, Collection<? extends String> tags, Collection<? extends String> modules,
            StateType state); @Override void toggleState(String id); @Override void unregisterModuleStateController(String moduleName, ModuleStateController controller); @Override void unregisterState(String id);  }### Answer:
@Test public void testGetModulesThatCanSaveState() { ModuleStateManager manager = new ModuleStateManagerImpl(null); ModuleStateController one = EasyMock.createNiceMock(ModuleStateController.class); ModuleStateController two = EasyMock.createNiceMock(ModuleStateController.class); EasyMock.expect(Boolean.valueOf(one.canSaveState())).andReturn(Boolean.TRUE); EasyMock.expect(Boolean.valueOf(two.canSaveState())).andReturn(Boolean.FALSE); EasyMock.replay(one, two); manager.registerModuleStateController(ONE, one); manager.registerModuleStateController(TWO, two); Collection<? extends String> names; names = manager.getModulesThatCanSaveState(); Assert.assertTrue(names.size() == 1 && names.contains(ONE)); EasyMock.verify(one, two); EasyMock.reset(one, two); EasyMock.expect(Boolean.valueOf(one.canSaveState())).andReturn(Boolean.FALSE); EasyMock.expect(Boolean.valueOf(two.canSaveState())).andReturn(Boolean.TRUE); EasyMock.replay(one, two); names = manager.getModulesThatCanSaveState(); Assert.assertTrue(names.size() == 1 && names.contains(TWO)); EasyMock.verify(one, two); EasyMock.reset(one, two); EasyMock.expect(Boolean.valueOf(one.canSaveState())).andReturn(Boolean.TRUE); EasyMock.expect(Boolean.valueOf(two.canSaveState())).andReturn(Boolean.TRUE); EasyMock.replay(one, two); names = manager.getModulesThatCanSaveState(); Assert.assertTrue(names.size() == 2 && names.containsAll(Arrays.asList(ONE, TWO))); EasyMock.verify(one, two); }