예제 #1
0
 @Override
 public void runCommand(Player player, List<String> arguments) {
   PlayerAuth auth = playerCache.getAuth(player.getName());
   if (auth.getEmail() != null && !"*****@*****.**".equalsIgnoreCase(auth.getEmail())) {
     commonService.send(player, MessageKey.EMAIL_SHOW, auth.getEmail());
   } else {
     commonService.send(player, MessageKey.SHOW_NO_EMAIL);
   }
 }
  @Test
  public void shouldReturnEmail() {
    // given
    String user = "******";
    String email = "*****@*****.**";
    PlayerAuth auth = mock(PlayerAuth.class);
    given(auth.getEmail()).willReturn(email);
    given(dataSource.getAuth(user)).willReturn(auth);
    CommandSender sender = mock(CommandSender.class);

    // when
    command.executeCommand(sender, Collections.singletonList(user));

    // then
    verify(sender).sendMessage(argThat(containsString(email)));
  }