XdsbRegistryAdapter { public String extractDeprecatedDocumentUniqueId( AdhocQueryResponse response, String messageId) throws XdsbRegistryAdapterException { try { String responseXml = this.marshaller.marshal(response); Document responseDoc = this.documentXmlConverter .loadDocument(responseXml); StringBuilder builder = new StringBuilder(); builder.append(" builder.append(SUBMISSION_SET_STATUS_DEPRECATED); builder.append("']]/preceding-sibling::rim:ExtrinsicObject[@objectType='"); builder.append(UUID_XDS_DOCUMENTENTRY); builder.append("']/descendant::rim:ExternalIdentifier[@identificationScheme='"); builder.append(UUID_XDS_DOCUMENTENTRY_UNIQUEID); builder.append("']/@value"); String xPathExpr = builder.toString(); Node node = this.documentAccessor.getNode(responseDoc, xPathExpr); if (node == null) { return null; } else { return node.getNodeValue(); } } catch (SimpleMarshallerException | DocumentAccessorException e) { logger.error(messageId, e.getMessage()); throw new XdsbRegistryAdapterException(e.getMessage(), e); } } XdsbRegistryAdapter(XdsbRegistryWebServiceClient xdsbRegistry,
			AdhocQueryResponseFilter responseFilter,
			SimpleMarshaller marshaller,
			DocumentXmlConverter documentXmlConverter,
			DocumentAccessor documentAccessor); AdhocQueryResponse registryStoredQuery(
			AdhocQueryRequest adhocQueryRequest); AdhocQueryResponse registryStoredQuery(String patientId,
			String domainId, String authorId,
			XdsbDocumentType xdsbDocumentType, boolean serviceTimeAware,
			String messageId); AdhocQueryResponse registryStoredQuery(String patientUniqueId,
			String authorNPI, XdsbDocumentType xdsbDocumentType,
			boolean serviceTimeAware, String messageId); AdhocQueryResponse registryStoredQuery(AdhocQueryRequest req,
			String authorNPI, String messageId); List<String> findDeprecatedDocumentUniqueIds(
			String submissionSetPatientId, String submissionSetAuthorPerson,
			String messageId); AdhocQueryResponse findSubmissionSets(String submissionSetPatientId,
			String submissionSetAuthorPerson); AdhocQueryResponse getSubmissionSetAndContents(
			String submissionSetUniqueId, String messageId); List<String> extractSubmissionSetUniqueIds(
			AdhocQueryResponse response); String extractDeprecatedDocumentUniqueId(
			AdhocQueryResponse response, String messageId); List<XdsbDocumentReference> extractXdsbDocumentReferenceList(
			AdhocQueryResponse adhocQueryResponse); RetrieveDocumentSetRequest extractXdsbDocumentReferenceListAsRetrieveDocumentSetRequest(
			AdhocQueryResponse adhocQueryResponse); String extractPatientId(AdhocQueryRequest req); String extractFormatCode(AdhocQueryRequest req); String extractResponseOptionReturnType(AdhocQueryRequest req); String extractDocumentEntryStatus(AdhocQueryRequest req); String getPatientUniqueId(String patientId, String domainId); static final String FORMAT_CODE_CLINICAL_DOCUMENT; static final String FORMAT_CODE_PRIVACY_CONSENT; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_FORMAT_CODE; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_PATIENT_ID; static final String SLOT_NAME_XDS_DOCUMENT_ENTRY_STATUS; static final String UUID_XDS_DOCUMENTENTRY; static final String UUID_XDS_DOCUMENTENTRY_UNIQUEID; static final String UUID_XDS_DOCUMENTENTRY_AUTHOR; static final String UUID_XDS_SUBMISSION_SET_UNIQUEID; }
@Test public void testExtractDeprecatedDocumentUniqueId() throws Throwable { AdhocQueryResponse responseMock = mock(AdhocQueryResponse.class); String responseXmlMock = "responseXmlMock"; Document documentMock = mock(Document.class); Node nodeMock = mock(Node.class); String nodeValueMock = "nodeValueMock"; when(marshallerMock.marshal(responseMock)).thenReturn(responseXmlMock); when(documentXmlConverterMock.loadDocument(responseXmlMock)) .thenReturn(documentMock); when(documentAccessorMock.getNode(eq(documentMock), anyString())) .thenReturn(nodeMock); when(nodeMock.getNodeValue()).thenReturn(nodeValueMock); String deprecatedDocumentUniqueId = xdsbRegistryAdapterSpy .extractDeprecatedDocumentUniqueId(responseMock, ""); assertEquals(nodeValueMock, deprecatedDocumentUniqueId); }