### Question:
EmailRegisterExecutor implements RegistrationExecutor<EmailRegisterParams> { @Override public void executePostPersistAction(EmailRegisterParams params) { Player player = params.getPlayer(); boolean couldSendMail = emailService.sendPasswordMail( player.getName(), params.getEmail(), params.getPassword()); if (couldSendMail) { syncProcessManager.processSyncEmailRegister(player); } else { commonService.send(player, MessageKey.EMAIL_SEND_FAILURE); } }  @Override boolean isRegistrationAdmitted(EmailRegisterParams params); @Override PlayerAuth buildPlayerAuth(EmailRegisterParams params); @Override void executePostPersistAction(EmailRegisterParams params);  }### Answer:
@Test public void shouldPerformActionAfterDataSourceSave() { given(emailService.sendPasswordMail(anyString(), anyString(), anyString())).willReturn(true); Player player = mock(Player.class); given(player.getName()).willReturn("Laleh"); EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com"); String password = "A892C#@"; params.setPassword(password); executor.executePostPersistAction(params); verify(emailService).sendPasswordMail("Laleh", "test@example.com", password); verify(syncProcessManager).processSyncEmailRegister(player); }
@Test public void shouldHandleEmailSendingFailure() { given(emailService.sendPasswordMail(anyString(), anyString(), anyString())).willReturn(false); Player player = mock(Player.class); given(player.getName()).willReturn("Laleh"); EmailRegisterParams params = EmailRegisterParams.of(player, "test@example.com"); String password = "A892C#@"; params.setPassword(password); executor.executePostPersistAction(params); verify(emailService).sendPasswordMail("Laleh", "test@example.com", password); verify(commonService).send(player, MessageKey.EMAIL_SEND_FAILURE); verifyZeroInteractions(syncProcessManager); }