@Test public void testGetNewImportantMessagesNoMessages() throws MessagingException, IOException { Message[] messages = createMockMessages(15, 0); when(this.inboxMock.search(ArgumentMatchers.any(FlagTerm.class))).thenReturn(messages); List<Message> returnedMessages = this.emailLogic.getNewImportantMessages(); assertThat(returnedMessages.size(), is(0)); assertThat(returnedMessages, is(Collections.emptyList())); }
List<Message> getNewImportantMessages() { List<Message> unseenMessages = getNewMessages(); List<Message> importantMessages = new ArrayList<>(); try { for (Message m : unseenMessages) { if (isImportantMessage(m)) { importantMessages.add(m); } } return importantMessages; } catch (MessagingException e) { this.logger.error("Couldn't determine whether the message is important", e); return Collections.emptyList(); } }
EMailLogic { List<Message> getNewImportantMessages() { List<Message> unseenMessages = getNewMessages(); List<Message> importantMessages = new ArrayList<>(); try { for (Message m : unseenMessages) { if (isImportantMessage(m)) { importantMessages.add(m); } } return importantMessages; } catch (MessagingException e) { this.logger.error("Couldn't determine whether the message is important", e); return Collections.emptyList(); } } }
EMailLogic { List<Message> getNewImportantMessages() { List<Message> unseenMessages = getNewMessages(); List<Message> importantMessages = new ArrayList<>(); try { for (Message m : unseenMessages) { if (isImportantMessage(m)) { importantMessages.add(m); } } return importantMessages; } catch (MessagingException e) { this.logger.error("Couldn't determine whether the message is important", e); return Collections.emptyList(); } }  }
EMailLogic { List<Message> getNewImportantMessages() { List<Message> unseenMessages = getNewMessages(); List<Message> importantMessages = new ArrayList<>(); try { for (Message m : unseenMessages) { if (isImportantMessage(m)) { importantMessages.add(m); } } return importantMessages; } catch (MessagingException e) { this.logger.error("Couldn't determine whether the message is important", e); return Collections.emptyList(); } }  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 { List<Message> getNewImportantMessages() { List<Message> unseenMessages = getNewMessages(); List<Message> importantMessages = new ArrayList<>(); try { for (Message m : unseenMessages) { if (isImportantMessage(m)) { importantMessages.add(m); } } return importantMessages; } catch (MessagingException e) { this.logger.error("Couldn't determine whether the message is important", e); return Collections.emptyList(); } }  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();  }