### Question:
ModuleStateManagerImpl implements ModuleStateManager { @Override public void deactivateAllStates() { Collection<? extends String> activeStateIds; synchronized (myActiveStates) { activeStateIds = getActiveStateIds(); myActiveStates.clear(); } for (String stateId : activeStateIds) { StateDataExtended data; synchronized (myStateMap) { data = myStateMap.get(stateId); } if (data != null) { deactivateStates(data); } } saveToPreferences(); } 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 testDeactivateAllStates() throws InterruptedException { ModuleStateManager manager = new ModuleStateManagerImpl(null); ModuleStateController one = EasyMock.createNiceMock(ModuleStateController.class); ModuleStateController two = EasyMock.createNiceMock(ModuleStateController.class); ModuleStateController three1 = EasyMock.createNiceMock(ModuleStateController.class); ModuleStateController three2 = EasyMock.createNiceMock(ModuleStateController.class); Element node = EasyMock.createMock(Element.class); one.activateState(EasyMock.eq(STATEID), EasyMock.eq(DESCRIPTION), EasyMockHelper.eq(TAGS), EasyMock.eq(node)); three1.activateState(EasyMock.eq(STATEID), EasyMock.eq(DESCRIPTION), EasyMockHelper.eq(TAGS), EasyMock.eq(node)); three2.activateState(EasyMock.eq(STATEID), EasyMock.eq(DESCRIPTION), EasyMockHelper.eq(TAGS), EasyMock.eq(node)); EasyMock.replay(one, two, three1, three2, node); manager.registerModuleStateController(ONE, one); manager.registerModuleStateController(TWO, two); manager.registerModuleStateController(THREE, three1); manager.registerModuleStateController(THREE, three2); manager.registerState(STATEID, DESCRIPTION, TAGS, Arrays.asList(ONE, THREE), node); manager.toggleState(STATEID); EasyMock.verify(one, two, three1, three2, node); Assert.assertTrue(manager.isStateActive(STATEID)); Assert.assertTrue(manager.getActiveStateIds().size() == 1 && manager.getActiveStateIds().contains(STATEID)); EasyMock.reset(one, two, three1, three2); one.deactivateState(STATEID, node); three1.deactivateState(STATEID, node); three2.deactivateState(STATEID, node); EasyMock.replay(one, two, three1, three2); manager.deactivateAllStates(); EasyMock.verify(one, two, three1, three2, node); Assert.assertFalse(manager.isStateActive(STATEID)); Assert.assertTrue(manager.getActiveStateIds().isEmpty()); }