DocumentRedactorImpl implements DocumentRedactor { @Override public String cleanUpGeneratedEntryIds(String document) { final String xPathExprGeneratedEntryId = " return cleanUpElements(document, xPathExprGeneratedEntryId); } DocumentRedactorImpl(
			SimpleMarshaller marshaller,
			DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor,
			Set<AbstractDocumentLevelRedactionHandler> documentLevelRedactionHandlers,
			Set<AbstractObligationLevelRedactionHandler> obligationLevelRedactionHandlers,
			Set<AbstractClinicalFactLevelRedactionHandler> clinicalFactLevelRedactionHandlers,
			Set<AbstractPostRedactionLevelRedactionHandler> postRedactionLevelRedactionHandlers); @Override String cleanUpEmbeddedClinicalDocumentFromFactModel(
			String factModelXml); @Override String cleanUpGeneratedEntryIds(String document); @Override String cleanUpGeneratedServiceEventIds(String document); @Override RedactedDocument redactDocument(String document,
			RuleExecutionContainer ruleExecutionContainer, FactModel factModel);  }
@Test public void testCleanUpGeneratedEntryIds() throws Exception { initDocumentRedactorWithActualServices(); final String c32WithGeneratedEntryIds = fileReader .readFile("testC32WithGeneratedEntryIds.xml"); final String cleanC32 = documentRedactor .cleanUpGeneratedEntryIds(c32WithGeneratedEntryIds); final Document docWithGeneratedEntryIds = documentXmlConverter .loadDocument(c32WithGeneratedEntryIds); final Document docCleanedUp = documentXmlConverter .loadDocument(cleanC32); final String xPathExpr = " NodeList foundGeneratedEntryIds = documentAccessor.getNodeList( docWithGeneratedEntryIds, xPathExpr); assertTrue(foundGeneratedEntryIds.getLength() > 0); foundGeneratedEntryIds = documentAccessor.getNodeList(docCleanedUp, xPathExpr); assertTrue(foundGeneratedEntryIds.getLength() == 0); }
@SuppressWarnings("unchecked") @Test(expected = DS4PException.class) public void testCleanUpGeneratedEntryIds_Throws_Exception() throws Exception { final String c32WithGeneratedEntryIds = "someDocument"; when(documentXmlConverterSpy.loadDocument(c32WithGeneratedEntryIds)) .thenThrow(Exception.class); documentRedactor.cleanUpGeneratedEntryIds(c32WithGeneratedEntryIds); }
@Test(expected = DS4PException.class) public void testCleanUpGeneratedEntryIds_Throws_Exception2() throws Exception { final String c32WithGeneratedEntryIds = "someDocument"; final Document documentMock = mock(Document.class); final NodeList nodeListMock = mock(NodeList.class); when(documentXmlConverterSpy.loadDocument(c32WithGeneratedEntryIds)) .thenReturn(documentMock); when( documentAccessorMock.getNodeList(documentMock, " when(nodeListMock.getLength()).thenReturn(0); doThrow(Exception.class).when(documentXmlConverterSpy) .convertXmlDocToString(documentMock); documentRedactor.cleanUpGeneratedEntryIds(c32WithGeneratedEntryIds); }
@SuppressWarnings("unchecked") @Test(expected = DS4PException.class) public void testCleanUpGeneratedEntryIds_Throws_XPathExpressionException() throws Exception { when( documentAccessorMock.getNodeList(isA(Document.class), eq(" XPathExpressionException.class); documentRedactor.cleanUpGeneratedEntryIds("someString"); }