### Question:
NodeReader { public boolean canActivateState(Node node, boolean activateDataLayer) { boolean canActivate = false; try { String path = activateDataLayer ? StateConstants.WMS_DATA_LAYER_PATH : StateConstants.WMS_MAP_LAYERS_PATH; NodeList wmsNodes = StateXML.getChildNodes(node, path); canActivate = wmsNodes.getLength() > 0; } catch (XPathExpressionException e) { LOGGER.error(e.getMessage(), e); } return canActivate; }  boolean canActivateState(Node node, boolean activateDataLayer); List<WMSLayerState> readNode(Node node, boolean activateDataLayer);  }### Answer:
@Test public void testCanActivate() throws XPathExpressionException, ParserConfigurationException, JAXBException { Node node = createStateNodeWithGroups(); NodeReader reader = new NodeReader(); boolean actual = reader.canActivateState(node, false); assertTrue(actual); node = createStateNodeWithoutMapGroup(); actual = reader.canActivateState(node, false); assertFalse(actual); actual = reader.canActivateState(node, true); assertTrue(actual); }
@Test public void testCanActivateJustGroups() throws ParserConfigurationException { Node node = createStateNodeWithDataGroup(); NodeReader reader = new NodeReader(); boolean actual = reader.canActivateState(node, true); assertFalse(actual); }
@Test public void testCanActivateJustLayers() throws ParserConfigurationException { Node node = createStateNode(); Document doc = node.getOwnerDocument(); Element layers = StateXML.createElement(doc, "layers"); node.appendChild(layers); NodeReader reader = new NodeReader(); boolean actual = reader.canActivateState(node, true); assertFalse(actual); actual = reader.canActivateState(node, false); assertFalse(actual); }
@Test public void testCanActivateNothing() throws ParserConfigurationException { Node node = createStateNode(); NodeReader reader = new NodeReader(); boolean actual = reader.canActivateState(node, true); assertFalse(actual); actual = reader.canActivateState(node, false); assertFalse(actual); }