@Test
public void shouldNotUpdatePasswordForMailHostIfNotChangedOrNull() throws IOException {
File cipherFile = new SystemEnvironment().getDESCipherFile();
FileUtils.deleteQuietly(cipherFile);
FileUtils.writeStringToFile(cipherFile, "269298bc31c44620", UTF_8);
GoCipher goCipher = new GoCipher();
MailHost mailHost = new MailHost("abc", 12, "admin", "p", null, true, true, "anc@mail.com", "anc@mail.com", goCipher);
ServerConfig serverConfig = new ServerConfig(null, mailHost, null, null);
assertThat(serverConfig.mailHost().getPassword(), is("p"));
String encryptedPassword = serverConfig.mailHost().getEncryptedPassword();
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", "p", encryptedPassword, false , true, "anc@mail.com", "anc@mail.com", goCipher));
assertThat(serverConfig.mailHost().getPassword(), is("p"));
assertThat(serverConfig.mailHost().getEncryptedPassword(), is(encryptedPassword));
serverConfig.updateMailHost(new MailHost("abc", 12, "admin", null, "", true, true, "anc@mail.com", "anc@mail.com"));
assertThat(serverConfig.mailHost().getPassword(), is(nullValue()));
assertThat(serverConfig.mailHost().getEncryptedPassword(), is(nullValue()));
}