NodeIdRepresentation { public StreamingOutput getResourceByAT(final String resourceName, final long nodeId, final Map<QueryParameter, String> queryParams, final IDAccessType accessType) throws JaxRxException { final StreamingOutput sOutput = new StreamingOutput() { @Override public void write(final OutputStream output) throws IOException, JaxRxException { final String revision = queryParams.get(QueryParameter.REVISION); final String wrap = queryParams.get(QueryParameter.WRAP); final String doNodeId = queryParams.get(QueryParameter.OUTPUT); final boolean wrapResult = (wrap == null) ? false : wrap .equalsIgnoreCase(YESSTRING); final boolean nodeid = (doNodeId == null) ? false : doNodeId .equalsIgnoreCase(YESSTRING); final Integer rev = revision == null ? null : Integer.valueOf(revision); serializeAT(resourceName, nodeId, rev, nodeid, output, wrapResult, accessType); } }; return sOutput; } NodeIdRepresentation(final File storagePath); StreamingOutput getResource(final String resourceName,
			final long nodeId, final Map<QueryParameter, String> queryParams); StreamingOutput getResourceByAT(final String resourceName,
			final long nodeId, final Map<QueryParameter, String> queryParams,
			final IDAccessType accessType); StreamingOutput performQueryOnResource(final String resourceName,
			final long nodeId, final String query,
			final Map<QueryParameter, String> queryParams); void deleteResource(final String resourceName, final long nodeId); void modifyResource(final String resourceName, final long nodeId,
			final InputStream newValue); void addSubResource(final String resourceName, final long nodeId,
			final InputStream input, final IDAccessType type);  }
@Test public final void testGetResourceByAT() throws WebApplicationException, IOException, ParserConfigurationException, SAXException { final Map<QueryParameter, String> queryParams = new HashMap<QueryParameter, String>(); queryParams.put(QueryParameter.OUTPUT, LITERALSTRUE); queryParams.put(QueryParameter.WRAP, LITERALSTRUE); queryParams.put(QueryParameter.REVISION, "1"); ByteArrayOutputStream outputStream; Document doc; NodeList list; String textContent = null; Node node; Attr attribute; final StreamingOutput fChildOutput = ridWorker.getResourceByAT( RESOURCENAME, NODEIDGETRESOURCE, queryParams, IDAccessType.FIRSTCHILD); outputStream = new ByteArrayOutputStream(); fChildOutput.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName(NAME); node = list.item(0); textContent = node.getTextContent(); outputStream.close(); assertEquals("Test expected name ", "Albania", textContent); final StreamingOutput lChildOutput = ridWorker.getResourceByAT( RESOURCENAME, NODEIDGETRESOURCE, queryParams, IDAccessType.LASTCHILD); outputStream = new ByteArrayOutputStream(); lChildOutput.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName("border"); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem("length"); outputStream.close(); assertEquals("Test expected border value ", "287", attribute.getValue()); final StreamingOutput rSiblingOutput = ridWorker .getResourceByAT(RESOURCENAME, NODEIDGETRESOURCE, queryParams, IDAccessType.RIGHTSIBLING); outputStream = new ByteArrayOutputStream(); rSiblingOutput.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName("country"); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(NAME); outputStream.close(); assertEquals("Test expected right sibling name ", "Andorra", attribute.getValue()); final StreamingOutput lSiblingOutput = ridWorker.getResourceByAT( RESOURCENAME, NODEIDGETRESOURCE, queryParams, IDAccessType.LEFTSIBLING); outputStream = new ByteArrayOutputStream(); lSiblingOutput.write(outputStream); doc = DOMHelper.buildDocument(outputStream); list = doc.getElementsByTagName("continent"); node = list.item(0); attribute = (Attr) node.getAttributes().getNamedItem(NAME); outputStream.close(); assertEquals("Test expected right sibling name ", "Africa", attribute.getValue()); }