### Question:
TimeManagerStateController extends AbstractModuleStateController { @Override public boolean canActivateState(Node node) { XPath xpath = StateXML.newXPath(); try { String current = xpath.evaluate("/" + ModuleStateController.STATE_QNAME + "/:time/:current", node); String held = xpath.evaluate("/" + ModuleStateController.STATE_QNAME + "/:time/:held/:key", node); String fadeIn = xpath.evaluate("/" + ModuleStateController.STATE_QNAME + "/:time/:fade/:in", node); String fadeOut = xpath.evaluate("/" + ModuleStateController.STATE_QNAME + "/:time/:fade/:out", node); return StringUtils.isNotEmpty(current) || StringUtils.isNotEmpty(held) || StringUtils.isNotEmpty(fadeIn) || StringUtils.isNotEmpty(fadeOut); } catch (XPathExpressionException e) { LOGGER.error(e, e); return false; } } TimeManagerStateController(TimeManager timeManager, AnimationManager animationManager); @Override void activateState(String id, String description, Collection<? extends String> tags, Node element); @Override void activateState(String id, String description, Collection<? extends String> tags, StateType state); @Override boolean canActivateState(Node node); @Override boolean canActivateState(StateType state); @Override boolean canSaveState(); @Override void deactivateState(String id, Node node); @Override void deactivateState(String id, StateType state); @Override boolean isSaveStateByDefault(); @Override void saveState(Node node); @Override void saveState(StateType state);  }### Answer:
@Test public void testCanActivateState() throws ParserConfigurationException, XPathExpressionException { TimeManager timeManager = EasyMock.createNiceMock(TimeManager.class); AnimationManager animationManager = EasyMock.createNiceMock(AnimationManager.class); EasyMock.replay(timeManager, animationManager); Document doc = XMLUtilities.newDocument(); Node timeNode = doc.appendChild(StateXML.createElement(doc, ModuleStateController.STATE_NAME)) .appendChild(StateXML.createElement(doc, "time")); TimeManagerStateController controller = new TimeManagerStateController(timeManager, animationManager); Assert.assertFalse(controller.canActivateState(doc)); Node currentNode = timeNode.appendChild(StateXML.createElement(doc, "current")); currentNode.setTextContent("2003-03-18T00:00:00"); Assert.assertTrue(controller.canActivateState(doc)); timeNode.removeChild(currentNode); Assert.assertFalse(controller.canActivateState(doc)); Node heldNode = timeNode.appendChild(StateXML.createElement(doc, "held")); heldNode.appendChild(StateXML.createElement(doc, "key")).setTextContent("heldkey"); Assert.assertTrue(controller.canActivateState(doc)); timeNode.removeChild(heldNode); Node fadeNode = timeNode.appendChild(StateXML.createElement(doc, "fade")); Node inNode = fadeNode.appendChild(StateXML.createElement(doc, "in")); inNode.setTextContent("P0.100S"); Assert.assertTrue(controller.canActivateState(doc)); fadeNode.removeChild(inNode); Node outNode = fadeNode.appendChild(StateXML.createElement(doc, "out")); outNode.setTextContent("P0.150S"); Assert.assertTrue(controller.canActivateState(doc)); fadeNode.removeChild(outNode); Assert.assertFalse(controller.canActivateState(doc)); }