mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-09-06 20:28:06 +02:00
Update add email tests (#527)
This commit is contained in:
parent
5795b9d8fd
commit
964abdc0c5
@ -56,16 +56,38 @@ public class AsyncAddEmailTest {
|
||||
given(auth.getEmail()).willReturn(null);
|
||||
given(playerCache.getAuth("tester")).willReturn(auth);
|
||||
given(dataSource.isEmailStored("my.mail@example.org")).willReturn(false);
|
||||
given(dataSource.updateEmail(any(PlayerAuth.class))).willReturn(true);
|
||||
|
||||
// when
|
||||
process.process();
|
||||
|
||||
// then
|
||||
verify(dataSource).updateEmail(auth);
|
||||
verify(messages).send(player, MessageKey.EMAIL_ADDED_SUCCESS);
|
||||
verify(auth).setEmail("my.mail@example.org");
|
||||
verify(playerCache).updatePlayer(auth);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldReturnErrorWhenMailCannotBeSaved() {
|
||||
// given
|
||||
AsyncAddEmail process = createProcess("my.mail@example.org");
|
||||
given(player.getName()).willReturn("testEr");
|
||||
given(playerCache.isAuthenticated("tester")).willReturn(true);
|
||||
PlayerAuth auth = mock(PlayerAuth.class);
|
||||
given(auth.getEmail()).willReturn(null);
|
||||
given(playerCache.getAuth("tester")).willReturn(auth);
|
||||
given(dataSource.isEmailStored("my.mail@example.org")).willReturn(false);
|
||||
given(dataSource.updateEmail(any(PlayerAuth.class))).willReturn(false);
|
||||
|
||||
// when
|
||||
process.process();
|
||||
|
||||
// then
|
||||
verify(dataSource).updateEmail(auth);
|
||||
verify(messages).send(player, MessageKey.ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldNotAddMailIfPlayerAlreadyHasEmail() {
|
||||
// given
|
||||
|
Loading…
Reference in New Issue
Block a user