@Test
public void testDirectEmailSend() throws Throwable {

	// Arrange
	when(xdsbRegistry.getPatientUniqueId(anyString(), anyString()))
	.thenReturn(patientUniqueId);
	when(contextHandler.enforcePolicy(isA(XacmlRequest.class))).thenReturn(
			xacmlResponse).thenReturn(xacmlResponse);
	when(
			xdsbRepository.retrieveDocumentSet(
					any(RetrieveDocumentSetRequest.class), anyString(),
					anyString())).thenReturn(retrieveDocumentSetResponse);
	when(marshaller.marshal(isA(Object.class))).thenReturn(
			enforcementPolicies).thenReturn(enforcementPolicies);
	dSSResponseForDirect1 = mock(DSSResponseForDirect.class);
	when(
			documentSegmentation
			.segmentDocumentForDirect(isA(DSSRequestForDirect.class)))
			.thenReturn(dSSResponseForDirect1);
	when(context.getUserPrincipal()).thenReturn(samlTokenPrincipal);
	when(
			samlTokenParser.parse(samlTokenPrincipal.getToken(),
					"urn:oasis:names:tc:xacml:1.0:resource:resource-id"))
					.thenReturn(
							"d3bb3930-7241-11e3-b4f7-00155d3a2124^^^&2.16.840.1.113883.4.357&ISO");
	when(
			samlTokenParser.parse(samlTokenPrincipal.getToken(),
					"urn:oasis:names:tc:xacml:1.0:subject-category:intermediary-subject"))
					.thenReturn("1114252178");
	when(
			samlTokenParser.parse(samlTokenPrincipal.getToken(),
					"urn:oasis:names:tc:xspa:1.0:subject:purposeofuse"))
					.thenReturn("TREATMENT");
	when(
			samlTokenParser.parse(samlTokenPrincipal.getToken(),
					"urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject"))
					.thenReturn("1760717789");
	when(dSSResponseForDirect1.getDocumentPayloadRawData()).thenReturn(
			dataHandler);
	when(dataHandlerToBytesConverter.toByteArray(any(DataHandler.class)))
			.thenReturn(byteValue);
	// Act
	final DirectEmailSendResponse response = pep
			.directEmailSend(directEmailSendRequest);
	// TODO: Add validation
}