Add more tests for async change email process

This commit is contained in:
ljacqu
2016-01-16 07:57:43 +01:00
parent 8c05c8df98
commit ace95f750a
2 changed files with 87 additions and 10 deletions
@@ -40,12 +40,10 @@ public class AsyncChangeEmail {
if (currentEmail == null) {
m.send(player, MessageKey.USAGE_ADD_EMAIL);
} else if (StringUtils.isEmpty(newEmail) || "your@email.com".equals(newEmail)) {
m.send(player, MessageKey.INVALID_EMAIL);
} else if (isEmailInvalid(newEmail)) {
m.send(player, MessageKey.INVALID_NEW_EMAIL);
} else if (!oldEmail.equals(currentEmail)) {
m.send(player, MessageKey.INVALID_OLD_EMAIL);
} else if (!Settings.isEmailCorrect(newEmail)) {
m.send(player, MessageKey.INVALID_NEW_EMAIL);
} else {
saveNewEmail(auth);
}
@@ -54,6 +52,11 @@ public class AsyncChangeEmail {
}
}
private static boolean isEmailInvalid(String email) {
return StringUtils.isEmpty(email) || "your@email.com".equals(email)
|| !Settings.isEmailCorrect(email);
}
private void saveNewEmail(PlayerAuth auth) {
auth.setEmail(newEmail);
if (dataSource.updateEmail(auth)) {