@Test
public void testDeprecatePolicy() throws SpiritAdapterException,
		EhrException_Exception {

	// Arrange
	String documentUniqueIdMock = "documentUniqueIdMock";
	String patientIdMock = "patientIdMock";
	byte[] revokedPdfConsentMock = new byte[1];
	EhrPatientRsp ehrPatientRspMock = mock(EhrPatientRsp.class);
	List<EhrPatientClientDto> ehrPatientClientDtoList = new LinkedList<EhrPatientClientDto>();
	EhrPatientClientDto ehrPatientClientDtoMock = mock(EhrPatientClientDto.class);
	ehrPatientClientDtoList.add(ehrPatientClientDtoMock);
	when(ehrPatientRspMock.getResponseData()).thenReturn(
			ehrPatientClientDtoList);
	when(webService.queryPatients(isA(EhrPatientRq.class))).thenReturn(
			ehrPatientRspMock);
	EhrXdsQRsp ehrXdsQRspMock = mock(EhrXdsQRsp.class);
	when(webService.queryPatientContent(isA(EhrXdsQGetAllRq.class)))
			.thenReturn(ehrXdsQRspMock);
	PatientContentClientDto patientContentClientDtoMock = mock(PatientContentClientDto.class);
	when(ehrXdsQRspMock.getResponseData()).thenReturn(
			patientContentClientDtoMock);
	List<DocumentClientDto> documentClientDtoList = new LinkedList<DocumentClientDto>();
	DocumentClientDto documentClientDtoMockXacml = mock(DocumentClientDto.class);
	DocumentClientDto documentClientDtoMockSignedPdf = mock(DocumentClientDto.class);
	documentClientDtoList.add(documentClientDtoMockXacml);
	documentClientDtoList.add(documentClientDtoMockSignedPdf);
	when(patientContentClientDtoMock.getDocuments()).thenReturn(
			documentClientDtoList);
	when(documentClientDtoMockXacml.getUniqueId()).thenReturn(
			SpiritConstants.URN_PREFIX_XACML + documentUniqueIdMock);
	when(documentClientDtoMockSignedPdf.getUniqueId()).thenReturn(
			SpiritConstants.URN_PREFIX_PDF_SIGNED + documentUniqueIdMock);
	XdsSrcSubmitRsp xdsSrcSubmitRspMock = mock(XdsSrcSubmitRsp.class);
	when(webService.appendDocument(isA(XdsSrcApRpReq.class))).thenReturn(
			xdsSrcSubmitRspMock);
	XdsSrcSubmitRsp xdsSrcSubmitRspMockDeprecate = mock(XdsSrcSubmitRsp.class);
	when(webService.deprecateDocument(isA(XdsSrcDeprecateReq.class)))
			.thenReturn(xdsSrcSubmitRspMockDeprecate);
	EhrPolicyDiscardRsp ehrPolicyDiscardRspMock = mock(EhrPolicyDiscardRsp.class);
	when(webService.discardPolicies(isA(EhrPolicyDiscardRq.class)))
			.thenReturn(ehrPolicyDiscardRspMock);
	SubmissionSetClientDto submissionSetClientDto = mock(SubmissionSetClientDto.class);
	when(documentClientDtoMockSignedPdf.getSubmissionSet()).thenReturn(
			submissionSetClientDto);
	AuthorMetadataClientDto authorMetadataClientDto = new AuthorMetadataClientDto();
	authorMetadataClientDto.setPerson("authorPerson");
	IheClassificationClientDto classCode = new IheClassificationClientDto();
	classCode.setNodeRepresentation("classCode");
	classCode.setValue("classCode");
	IheClassificationClientDto formatCode = new IheClassificationClientDto();
	formatCode.setNodeRepresentation("formatCode");
	formatCode.setValue("formatCode");
	IheClassificationClientDto typeCode = new IheClassificationClientDto();
	typeCode.setNodeRepresentation("typeCode");
	typeCode.setValue("typeCode");
	IheClassificationClientDto confidentialityCode = new IheClassificationClientDto();
	confidentialityCode.setNodeRepresentation("confidentialityCode");
	confidentialityCode.setValue("confidentialityCode");
	IheClassificationClientDto healthcareFacilityCode = new IheClassificationClientDto();
	healthcareFacilityCode.setNodeRepresentation("healthcareFacilityCode");
	healthcareFacilityCode.setValue("healthcareFacilityCode");
	IheClassificationClientDto practiceSettingCode = new IheClassificationClientDto();
	practiceSettingCode.setNodeRepresentation("practiceSettingCode");
	practiceSettingCode.setValue("practiceSettingCode");
	IheClassificationClientDto contentTypeCode = new IheClassificationClientDto();
	contentTypeCode.setNodeRepresentation("contentTypeCode");
	contentTypeCode.setValue("contentTypeCode");
	when(submissionSetClientDto.getAuthor()).thenReturn(
			Arrays.asList(authorMetadataClientDto));
	when(documentClientDtoMockSignedPdf.getClassCode()).thenReturn(
			classCode);
	when(documentClientDtoMockSignedPdf.getFormatCode()).thenReturn(
			formatCode);
	when(documentClientDtoMockSignedPdf.getTypeCode()).thenReturn(typeCode);
	when(documentClientDtoMockSignedPdf.getConfidentialityCode())
			.thenReturn(confidentialityCode);
	when(documentClientDtoMockSignedPdf.getHealthcareFacilityCode())
			.thenReturn(healthcareFacilityCode);
	when(documentClientDtoMockSignedPdf.getPracticeSettingCode())
			.thenReturn(practiceSettingCode);
	when(submissionSetClientDto.getContentTypeCode()).thenReturn(
			contentTypeCode);
	// Act
	XdsSrcSubmitRsp actualResponse = sat.deprecatePolicy(
			documentUniqueIdMock, patientIdMock, revokedPdfConsentMock);
	// Assert
	verify(webService, times(1)).deprecateDocument(
			isA(XdsSrcDeprecateReq.class));
	verify(webService, times(1)).discardPolicies(
			isA(EhrPolicyDiscardRq.class));
	verify(webService, times(1)).appendDocument(
			argThat(new AppendDocumentArgumentMatcher(
					authorMetadataClientDto, classCode, formatCode,
					typeCode, confidentialityCode, healthcareFacilityCode,
					practiceSettingCode, contentTypeCode)));
	assertEquals(xdsSrcSubmitRspMockDeprecate, actualResponse);
}