### Question:
NodeReader { public List<WMSLayerState> readNode(Node node, boolean activateDataLayer) { List<WMSLayerState> layerStates = New.list(); try { NodeList children = null; String path = activateDataLayer ? StateConstants.WMS_DATA_LAYER_PATH : StateConstants.WMS_MAP_LAYERS_PATH; children = StateXML.getChildNodes(node, path); if (children != null) { for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); try { WMSLayerState layerState = XMLUtilities.readXMLObject(child, WMSLayerState.class); layerStates.add(layerState); } catch (JAXBException e) { StringBuilder sb = new StringBuilder(); sb.append("Failed to read WMS layer state for index "); sb.append(i); sb.append(", isDataLayer = "); sb.append(activateDataLayer); sb.append(e.getMessage()); LOGGER.error(sb.toString(), e); } } } } catch (XPathExpressionException e) { LOGGER.error(e.getMessage(), e); } return layerStates; }  boolean canActivateState(Node node, boolean activateDataLayer); List<WMSLayerState> readNode(Node node, boolean activateDataLayer);  }### Answer:
@Test public void testReadNodeData() throws ParserConfigurationException, JAXBException, XPathExpressionException { Node node = createStateNodeWithGroups(); NodeReader reader = new NodeReader(); List<WMSLayerState> layerStates = reader.readNode(node, true); assertEquals(ourDataLayerName1, layerStates.get(0).getId()); assertEquals(ourDataLayerName2, layerStates.get(1).getId()); }
@Test public void testReadNodeMap() throws ParserConfigurationException, JAXBException, XPathExpressionException { Node node = createStateNodeWithGroups(); NodeReader reader = new NodeReader(); List<WMSLayerState> layerStates = reader.readNode(node, false); assertEquals(ourMapLayerName1, layerStates.get(0).getId()); assertEquals(ourMapLayerName2, layerStates.get(1).getId()); }
@Test public void testReadNodeNoLayerGroup() throws ParserConfigurationException, JAXBException, XPathExpressionException { Node node = createStateNodeWithoutMapGroup(); NodeReader reader = new NodeReader(); List<WMSLayerState> layerStates = reader.readNode(node, false); assertTrue(layerStates.isEmpty()); }
@Test public void testReadNodeNoLayers() throws ParserConfigurationException { Node node = createStateNode(); NodeReader reader = new NodeReader(); List<WMSLayerState> layerStates = reader.readNode(node, false); assertTrue(layerStates.isEmpty()); }