SpiritAdapterImpl implements SpiritAdapter { @Override public EhrPatientClientDto updateDocument( XdsSrcUpdateReq xdsSrcUpdateRequest) throws SpiritAdapterException { try { String stateId = login(); logger.info("updateDocument: START"); xdsSrcUpdateRequest.setStateID(stateId); XdsSrcSubmitRsp xdsSrcSubmitResponse = getWebService() .updateDocument(xdsSrcUpdateRequest); logger.info("updateDocument: SUCCESS"); logout(stateId); return xdsSrcSubmitResponse.getResponseData(); } catch (EhrException_Exception e) { logger.warn("UpdateDocument: FAILED\n", e); throw new SpiritAdapterException(e); } } SpiritAdapterImpl(String endpointUrl, String org, String pwd,
			String rol, String user, String domainId, String c2sDomainId,
			String c2sDomainType, String c2sEnvType);  SpiritAdapterImpl(String endpointUrl, String org, String pwd,
			String rol, String user, String domainId, String c2sDomainId,
			String c2sDomainType, String c2sEnvType,
			SpiritEhrWsClientRqRspInterface webService); @Override SpiritUserResponse usrOrgRoleLogin(); @Override String login(); @Override void logout(String stateId); @Override PatientDto createPatientByPDQ(PatientDto patientDto); @Override PatientDto updatePatientByLocId(PatientDto patientDto); @Override XdsSrcSubmitRsp submitSignedConsent(byte[] xacmlPolicy,
			byte[] signedConsentPdf, byte[] pdfConsentFromXacml,
			byte[] pdfConsentToXacml, String xacmlPolicyId, String patientId,
			String country); @Override EhrPatientClientListDto queryPatientsWithPids(String patientId,
			String stateId); EhrPatientRsp insertPatient(EhrPatientRq arg0); @Override XdsSrcSubmitRsp submitDocument(EhrPatientClientDto submitForPatient,
			SourceSubmissionClientDto sourceSubmission, Boolean withFolder,
			String stateId); @Override XdsSrcSubmitRsp submitDocument(EhrPatientClientDto submitForPatient,
			SourceSubmissionClientDto sourceSubmission, Boolean withFolder); @Override EhrXdsQRsp queryPatientContent(EhrPatientClientDto patient,
			String stateId); @Override EhrXdsRetrRsp retrieveDocument(DocumentClientDto wantedDocument); @Override EhrPatientClientDto updateDocument(
			XdsSrcUpdateReq xdsSrcUpdateRequest); @Override SourceSubmissionClientDto generatePolicyMetadata(String document); @Override DocumentClientDto queryDocumentsByUid(String patientId,
			String documentUniqueId, String stateId); @Override XdsSrcSubmitRsp deprecateDocument(String documentUniqueId,
			String patientId, String stateId); @Override XdsSrcSubmitRsp deprecateDocuments(
			List<String> documentUniqueIdList, String patientId, String stateId); @Override XdsSrcSubmitRsp deprecateDocuments(
			List<String> documentUniqueIdList, EhrPatientClientDto patient,
			PatientContentClientDto patientContentClientDto, String stateId); @Override String deleteDocuments(FolderClientDto folder,
			List<DocumentClientDto> documentList, EhrPatientClientDto patient,
			String stateId); @Override XdsSrcSubmitRsp deleteDocument(FolderClientDto folder,
			DocumentClientDto document, EhrPatientClientDto patient,
			String stateId); @Override XdsSrcSubmitRsp deprecatePolicy(String documentUniqueId,
			String patientId, byte[] revokedPdfConsent); XdsSrcSubmitRsp appendDocument(EhrPatientClientDto patient,
			DocumentClientDto oldDocument, DocumentClientDto documentToAppend,
			String stateId); @Override EhrPolicySubmitRsp submitPolicy(byte[] policy); @Override EhrPolicySubmitRsp submitPolicies(List<byte[]> policyList); @Override EhrPolicySubmitOrUpdateRsp submitOrUpdatePolicy(byte[] policy,
			String stateId); @Override EhrPolicySubmitOrUpdateRsp submitOrUpdatePolicies(
			List<byte[]> policyList, String stateId); @Override EhrPolicyUpdateRsp updatePolicy(byte[] policy); @Override EhrPolicyUpdateRsp updatePolicies(List<byte[]> policyList); @Override byte[] retrievePolicy(String policyId); @Override List<byte[]> retrievePolicies(List<String> listPolicySetIds,
			List<String> listPolicyIds); @Override EhrPolicyDiscardRsp discardPolicy(String policyId, String stateId); @Override EhrPolicyDiscardRsp discardPolicies(List<String> listPolicySetIds,
			List<String> listPolicyIds, String stateId); EhrPapCfgRsp loadPapConfiguration(); @Override XdsSrcSubmitRsp submitC32(byte[] c32file); @Override SourceSubmissionClientDto generateC32Metadata(String document);  }
@Test public void testUpdateDocument() throws Exception { XdsSrcUpdateReq xdsSrcUpdateRequest = mock(XdsSrcUpdateReq.class); SpiritAdapterImpl satSpy = spy(sat); String stateId = "MockedStateId"; doReturn(stateId).when(satSpy).login(); XdsSrcSubmitRsp response = mock(XdsSrcSubmitRsp.class); EhrPatientClientDto ehrPatientClientDto = mock(EhrPatientClientDto.class); doReturn(ehrPatientClientDto).when(response).getResponseData(); doReturn(response).when(webService).updateDocument(xdsSrcUpdateRequest); satSpy.updateDocument(xdsSrcUpdateRequest); verify(webService).updateDocument(xdsSrcUpdateRequest); verify(satSpy).logout("MockedStateId"); }