DirectAdapterUtils { protected static NHINDAddressCollection getNhindRecipients(Message message) throws MessagingException { NHINDAddressCollection recipients = new NHINDAddressCollection(); addRecipients(recipients, message, RecipientType.TO, AddressSource.To); addRecipients(recipients, message, RecipientType.CC, AddressSource.CC); addRecipients(recipients, message, RecipientType.BCC, AddressSource.BCC); if (recipients.isEmpty()) { throw new DirectException("No recipients found in message."); } return recipients; } private  DirectAdapterUtils(); static boolean isMdn(MessageEnvelope envelope);  }
@Test public void canGetNhindRecipients() throws MessagingException { when(mockMessage.getRecipients(RecipientType.TO)).thenReturn( new Address[] {new InternetAddress("test@test1.com")}); when(mockMessage.getRecipients(RecipientType.CC)).thenReturn(EMPTY_ADDRESS_ARRAY); when(mockMessage.getRecipients(RecipientType.BCC)).thenReturn(EMPTY_ADDRESS_ARRAY); assertNotNull(DirectAdapterUtils.getNhindRecipients(mockMessage)); }
@Test(expected = DirectException.class) public void willThrowDirectExceptionWhenNoRecipientsPresent() throws MessagingException { when(mockMessage.getRecipients(RecipientType.TO)).thenReturn(EMPTY_ADDRESS_ARRAY); when(mockMessage.getRecipients(RecipientType.CC)).thenReturn(EMPTY_ADDRESS_ARRAY); when(mockMessage.getRecipients(RecipientType.BCC)).thenReturn(EMPTY_ADDRESS_ARRAY); DirectAdapterUtils.getNhindRecipients(mockMessage); }