### Question:
EMailLogic { public EMailCredentials getCredentials() { if (!this.storage.has(USERNAME_CRED_KEY) || !this.storage.has(PASSOWRD_CRED_KEY) || !this.storage.has(IMAPSERVER_CRED_KEY)) { return null; } final String username = this.storage.get(USERNAME_CRED_KEY); final String password = this.storage.get(PASSOWRD_CRED_KEY); final String imapServer = this.storage.get(IMAPSERVER_CRED_KEY); return new EMailCredentials(username, password, imapServer); }  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 testGetCredentialsNotNull() { final String credentialString = "credential"; when(this.framework.storage().has(ArgumentMatchers.anyString())).thenReturn(true); when(this.framework.storage().get(ArgumentMatchers.anyString())).thenReturn(credentialString); EMailCredentials creds = new EMailCredentials(credentialString, credentialString, credentialString); assertThat(this.emailLogic.getCredentials().getUsername(), is(creds.getUsername())); assertThat(this.emailLogic.getCredentials().getPassword(), is(creds.getPassword())); assertThat(this.emailLogic.getCredentials().getImapServer(), is(creds.getImapServer())); }
@Test protected void testGetCredentialsNull() { when(this.framework.storage().has(ArgumentMatchers.anyString())).thenReturn(false); Assertions.assertNull(this.emailLogic.getCredentials()); }