AdhocQueryResponseFilter { public AdhocQueryResponse filterByAuthor(AdhocQueryResponse response, String authorNPI) throws XdsbRegistryAdapterException { try { String xPathExpr = " xPathExpr = xPathExpr.replace("%", authorNPI); xPathExpr = xPathExpr.replace("$", UUID_CLASSIFICATIONSCHEME_XDSDOCUMENTENTRY_AUTHOR); String docString = marshaller.marshal(response); Document xmlDocument = converter.loadDocument(docString); NodeList nodeSet = documentAccessor.getNodeList(xmlDocument, xPathExpr); for (int i = 0; i < nodeSet.getLength(); i++) { Node node = nodeSet.item(i); Element elementToBeRedacted = (Element) node; elementToBeRedacted.getParentNode().removeChild( elementToBeRedacted); } xmlDocument.normalize(); return marshaller.unmarshalFromXml(AdhocQueryResponse.class, converter.convertXmlDocToString(xmlDocument)); } catch (SimpleMarshallerException | DocumentAccessorException e) { throw new XdsbRegistryAdapterException(e); } } AdhocQueryResponseFilter(SimpleMarshaller marshaller,
			DocumentXmlConverter converter, DocumentAccessor documentAccessor); AdhocQueryResponse filterByAuthor(AdhocQueryResponse response,
			String authorNPI); static final String UUID_CLASSIFICATIONSCHEME_XDSDOCUMENTENTRY_AUTHOR; }
@Test public void testFilterByAuthor() throws Exception, Throwable { String expectedResponse = fileReader .readFile("unitTestAdhocQueryResponseFiltered.xml"); AdhocQueryResponse responseMock = marshaller.unmarshalFromXml( AdhocQueryResponse.class, fileReader.readFile("unitTestAdhocQueryResponse.xml")); AdhocQueryResponse actualResponse = sut.filterByAuthor(responseMock, "1114252178"); String actualResponseXmlString = marshaller.marshal(actualResponse); assertXMLEqual("", expectedResponse, actualResponseXmlString); }