DocumentCleanupForDocumentationOfNoServiceEvent extends
		AbstractPostRedactionLevelRedactionHandler { @Override public void execute(Document xmlDocument, XacmlResult xacmlResult, FactModel factModel, Document factModelDocument, RuleExecutionContainer ruleExecutionContainer, List<Node> listOfNodes, Set<String> redactSectionCodesAndGeneratedEntryIds) throws XPathExpressionException { NodeList documentationOfElements = documentAccessor.getNodeList( xmlDocument, XPATH_DOCUMENTATIONOF_WITH_NO_SERVICE_EVENT); if (documentationOfElements != null) { for (int i = 0; i < documentationOfElements.getLength(); i++) { Node documentationOfElement = documentationOfElements.item(i); documentationOfElement.getParentNode().removeChild( documentationOfElement); } } } DocumentCleanupForDocumentationOfNoServiceEvent(
			DocumentAccessor documentAccessor); @Override void execute(Document xmlDocument, XacmlResult xacmlResult,
			FactModel factModel, Document factModelDocument,
			RuleExecutionContainer ruleExecutionContainer,
			List<Node> listOfNodes,
			Set<String> redactSectionCodesAndGeneratedEntryIds); static final String XPATH_DOCUMENTATIONOF_WITH_NO_SERVICE_EVENT; }
@Test public void testExecute_DocumentationOf_Has_ServiceEvent() throws IOException, SimpleMarshallerException, XPathExpressionException { String c32FileName = "c32.xml"; String factmodelXml = fileReader.readFile(TEST_PATH + FACTMODEL_PATH + c32FileName); String c32 = embeddedClinicalDocumentExtractor.extractClinicalDocumentFromFactModel(factmodelXml); String ruleExecutionContainerXml = fileReader.readFile(TEST_PATH + RULEEXECUTIONCONTAINER_PATH + c32FileName); RuleExecutionContainer ruleExecutionContainer = marshaller.unmarshalFromXml(RuleExecutionContainer.class, ruleExecutionContainerXml); Document c32Document = documentXmlConverter.loadDocument(c32); Document factModelDocument = documentXmlConverter.loadDocument(factmodelXml); FactModel factModel = marshaller.unmarshalFromXml(FactModel.class, factmodelXml); List<Node> listOfNodes = new LinkedList<Node>(); Set<String> redactSectionCodesAndGeneratedEntryIds = new HashSet<String>(); sut.execute(c32Document, factModel.getXacmlResult(), factModel, factModelDocument, ruleExecutionContainer, listOfNodes, redactSectionCodesAndGeneratedEntryIds); assertEquals(1, documentAccessor.getNodeList(c32Document, " assertEquals(3, documentAccessor.getNodeList(c32Document, " assertEquals("serviceEvent", documentAccessor.getNodeList(c32Document, " }
@Test public void testExecute_DocumentationOf_Does_Not_Have_ServiceEvent() throws IOException, SimpleMarshallerException, XPathExpressionException { String c32FileName = "c32-emptyDocumentationOf.xml"; String factmodelXml = fileReader.readFile(TEST_PATH + FACTMODEL_PATH + c32FileName); String c32 = embeddedClinicalDocumentExtractor.extractClinicalDocumentFromFactModel(factmodelXml); String ruleExecutionContainerXml = fileReader.readFile(TEST_PATH + RULEEXECUTIONCONTAINER_PATH + c32FileName); RuleExecutionContainer ruleExecutionContainer = marshaller.unmarshalFromXml(RuleExecutionContainer.class, ruleExecutionContainerXml); Document c32Document = documentXmlConverter.loadDocument(c32); Document factModelDocument = documentXmlConverter.loadDocument(factmodelXml); FactModel factModel = marshaller.unmarshalFromXml(FactModel.class, factmodelXml); List<Node> listOfNodes = new LinkedList<Node>(); Set<String> redactSectionCodesAndGeneratedEntryIds = new HashSet<String>(); sut.execute(c32Document, factModel.getXacmlResult(), factModel, factModelDocument, ruleExecutionContainer, listOfNodes, redactSectionCodesAndGeneratedEntryIds); assertEquals(0, documentAccessor.getNodeList(c32Document, " }