@Test protected void testGetFrom() throws MessagingException, IOException { final String personalName = "personalName"; Message[] messages = createMockMessages(2, 0); InternetAddress addressWithPersonal = (InternetAddress) messages[0].getFrom()[0]; when(addressWithPersonal.getPersonal()).thenReturn(personalName); assertThat(EMailLogic.getFrom(messages[0]), is(personalName)); assertThat(EMailLogic.getFrom(messages[1]), containsString("address")); }
static String getFrom(Message message) throws MessagingException { InternetAddress address = (InternetAddress) message.getFrom()[0]; String personal = address.getPersonal(); return (personal == null) ? address.getAddress() : personal; }
EMailLogic { static String getFrom(Message message) throws MessagingException { InternetAddress address = (InternetAddress) message.getFrom()[0]; String personal = address.getPersonal(); return (personal == null) ? address.getAddress() : personal; } }
EMailLogic { static String getFrom(Message message) throws MessagingException { InternetAddress address = (InternetAddress) message.getFrom()[0]; String personal = address.getPersonal(); return (personal == null) ? address.getAddress() : personal; }  }
EMailLogic { static String getFrom(Message message) throws MessagingException { InternetAddress address = (InternetAddress) message.getFrom()[0]; String personal = address.getPersonal(); return (personal == null) ? address.getAddress() : personal; }  boolean hasNewMessages(boolean checkForImportant); int getNewMessageCount(boolean checkForImportant); String printMessages(int amount, boolean important); MessageDTO[] getMailsForREST(int amount); boolean connectToMailServer(EMailCredentials credentials); boolean isConnectedToMailServer(); void disconnectFromMailServer(); EMailCredentials getCredentials(); @PostConstruct void connectToMailServer(); }
EMailLogic { static String getFrom(Message message) throws MessagingException { InternetAddress address = (InternetAddress) message.getFrom()[0]; String personal = address.getPersonal(); return (personal == null) ? address.getAddress() : personal; }  boolean hasNewMessages(boolean checkForImportant); int getNewMessageCount(boolean checkForImportant); String printMessages(int amount, boolean important); MessageDTO[] getMailsForREST(int amount); boolean connectToMailServer(EMailCredentials credentials); boolean isConnectedToMailServer(); void disconnectFromMailServer(); EMailCredentials getCredentials(); @PostConstruct void connectToMailServer();  }