### Question:
EMailLogic { public boolean connectToMailServer(EMailCredentials credentials) { if (credentials == null) { String amyUsername = this.properties.getProperty(AMY_MAIL_ADDRESS_KEY); String amyPassword = this.properties.getProperty(AMY_MAIL_PW_KEY); String amyHost = AMY_MAIL_HOST; credentials = new EMailCredentials(amyUsername, amyPassword, amyHost); } this.storage.put(USERNAME_CRED_KEY, credentials.getUsername()); this.storage.put(PASSOWRD_CRED_KEY, credentials.getPassword()); this.storage.put(IMAPSERVER_CRED_KEY, credentials.getImapServer()); return this.mailSession.startNewMailSession(credentials); }  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 protected void testConnectToMailServerStandardCredentials() { EMailCredentials credentials = new EMailCredentials("testUsername", "testPassword", "testHostAddress"); when(this.mailSession.startNewMailSession(credentials)).thenReturn(true); assertTrue(this.emailLogic.connectToMailServer(credentials)); }
@Test protected void testConnectToMailServerEmptyCredentials() { when(this.mailSession.startNewMailSession(ArgumentMatchers.any(EMailCredentials.class))).thenReturn(true); assertTrue(this.emailLogic.connectToMailServer(null)); Mockito.verify(this.properties).getProperty(EMailLogic.AMY_MAIL_ADDRESS_KEY); Mockito.verify(this.properties).getProperty(EMailLogic.AMY_MAIL_PW_KEY); }