@SuppressWarnings("unchecked")
@Test(expected = Throwable.class)
public void testHandleMessage_Throws_Exception_Given_XDS_Returns_Fail_Response()
		throws Throwable {

	// Arrange
	ReflectionTestUtils.setField(sut, "domainId", domainIdMock);
	SignedConsentDto simpleConsentDtoMock = mock(SignedConsentDto.class);
	when(simpleConsentDtoMock.getPatientMrn()).thenReturn(
			patientLocalIdMock);
	when(simpleConsentDtoMock.getXacmlCcdId()).thenReturn("xacmlPolicyId");
	when(simpleConsentDtoMock.getXacmlCcd()).thenReturn(consentMock);
	when(consentGetterMock.getSignedConsentDto(1)).thenReturn(
			simpleConsentDtoMock);
	when(spiritAdapter.login()).thenReturn("stateid123");
	SourceSubmissionClientDto sourceSubmissionClientDto = mock(SourceSubmissionClientDto.class);
	when(spiritAdapter.generatePolicyMetadata(anyString())).thenReturn(
			sourceSubmissionClientDto);
	List<DocumentClientDto> documentClientDtolistmock = new ArrayList<DocumentClientDto>();
	DocumentClientDto documentClientDtomock = mock(DocumentClientDto.class);
	documentClientDtolistmock.add(documentClientDtomock);
	when(sourceSubmissionClientDto.getDocuments()).thenReturn(
			documentClientDtolistmock);
	List<EhrPatientClientDto> patientClientDtoList = new ArrayList<EhrPatientClientDto>();
	EhrPatientClientDto patientClientDtomock = mock(EhrPatientClientDto.class);
	patientClientDtoList.add(patientClientDtomock);
	EhrPatientClientListDto ehrPatientClientListDto = mock(EhrPatientClientListDto.class);
	when(ehrPatientClientListDto.getEhrPatientClientListDto()).thenReturn(
			patientClientDtoList);
	when(ehrPatientClientListDto.getStateId()).thenReturn("stateid123");
	when(spiritAdapter.queryPatientsWithPids(anyString(), anyString()))
			.thenReturn(ehrPatientClientListDto);
	when(
			spiritAdapter.submitDocument(patientClientDtomock,
					sourceSubmissionClientDto, false, "stateid123"))
			.thenThrow(Throwable.class);
	sut.handleMessage(dataMock);
}