### Question:
NodeWriter { public void writeToNode(Node node, List<WMSLayerAndState> layerStates, boolean saveDataLayers) { List<WMSLayerState> dataLayers = New.list(); List<WMSLayerState> mapLayers = New.list(); segregateLayers(layerStates, dataLayers, mapLayers); Document doc = node instanceof Document ? (Document)node : node.getOwnerDocument(); try { if (saveDataLayers) { if (!dataLayers.isEmpty()) { Element dataLayerNode = (Element)StateXML.createChildNode(node, doc, node, StateConstants.DATA_LAYERS_PATH, StateConstants.LAYERS_NAME); dataLayerNode.setAttribute("type", StateConstants.DATA_LAYERS_TYPE); addToNode(dataLayerNode, dataLayers); } } else if (!mapLayers.isEmpty()) { Element mapLayerNode = (Element)StateXML.createChildNode(node, doc, node, StateConstants.MAP_LAYERS_PATH, StateConstants.LAYERS_NAME); mapLayerNode.setAttribute("type", StateConstants.MAP_LAYERS_TYPE); addToNode(mapLayerNode, mapLayers); } } catch (XPathExpressionException e) { LOGGER.error(e.getMessage(), e); } }  void writeToNode(Node node, List<WMSLayerAndState> layerStates, boolean saveDataLayers); static void segregateLayers(List<WMSLayerAndState> layerStates, List<WMSLayerState> dataLayers,
            List<WMSLayerState> mapLayers);  }### Answer:
@Test public void testWriteToNode() throws ParserConfigurationException, JAXBException, SAXException, IOException { Document doc = XMLUtilities.newDocument(); Node stateElement = doc.appendChild(StateXML.createElement(doc, ModuleStateController.STATE_NAME)); performTest(stateElement); }