### Question:
EMailLogic { public boolean hasNewMessages(boolean checkForImportant) { if (checkForImportant) { return !getNewImportantMessages().isEmpty(); } return !getNewMessages().isEmpty(); }  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();  }### Answer:
@Test public void testHasNewMessagesNormalCase() throws MessagingException, IOException { Message[] messages1 = createMockMessages(15, 7); when(this.inboxMock.search(ArgumentMatchers.any(FlagTerm.class))).thenReturn(messages1); assertEquals(true, this.emailLogic.hasNewMessages(false)); assertEquals(true, this.emailLogic.hasNewMessages(true)); Message[] messages2 = createMockMessages(10, 0); when(this.inboxMock.search(ArgumentMatchers.any(FlagTerm.class))).thenReturn(messages2); assertEquals(true, this.emailLogic.hasNewMessages(false)); assertEquals(false, this.emailLogic.hasNewMessages(true)); Message[] messages3 = createMockMessages(10, 10); when(this.inboxMock.search(ArgumentMatchers.any(FlagTerm.class))).thenReturn(messages3); assertEquals(true, this.emailLogic.hasNewMessages(false)); assertEquals(true, this.emailLogic.hasNewMessages(true)); }
@Test public void testHasNewMessagesNoMails() throws MessagingException { when(this.inboxMock.search(ArgumentMatchers.any(FlagTerm.class))).thenReturn(new Message[0]); assertEquals(false, this.emailLogic.hasNewMessages(false)); assertEquals(false, this.emailLogic.hasNewMessages(true)); }