@Test
  public void shouldRejectNonPlayerSender() {
    // given
    CommandSender sender = mock(BlockCommandSender.class);
    ChangePasswordCommand command = new ChangePasswordCommand();

    // when
    command.executeCommand(sender, new ArrayList<String>(), commandService);

    // then
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }
  @Test
  public void shouldRejectPasswordEqualToNick() {
    // given
    CommandSender sender = initPlayerWithName("tester", true);
    ChangePasswordCommand command = new ChangePasswordCommand();

    // when
    command.executeCommand(sender, Arrays.asList("old_", "Tester"), commandService);

    // then
    verify(commandService).send(sender, MessageKey.PASSWORD_IS_USERNAME_ERROR);
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }
  @Test
  public void shouldDenyInvalidPassword() {
    // given
    CommandSender sender = initPlayerWithName("name", true);
    ChangePasswordCommand command = new ChangePasswordCommand();

    // when
    command.executeCommand(sender, Arrays.asList("old123", "!pass"), commandService);

    // then
    verify(commandService).send(sender, MessageKey.PASSWORD_MATCH_ERROR);
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }
  @Test
  public void shouldRejectNotLoggedInPlayer() {
    // given
    CommandSender sender = initPlayerWithName("name", false);
    ChangePasswordCommand command = new ChangePasswordCommand();

    // when
    command.executeCommand(sender, Arrays.asList("pass", "pass"), commandService);

    // then
    verify(commandService).send(sender, MessageKey.NOT_LOGGED_IN);
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }
  @Test
  public void shouldRejectTooShortPassword() {
    // given
    CommandSender sender = initPlayerWithName("abc12", true);
    ChangePasswordCommand command = new ChangePasswordCommand();
    given(commandService.getProperty(SecuritySettings.MIN_PASSWORD_LENGTH)).willReturn(7);

    // when
    command.executeCommand(sender, Arrays.asList("oldverylongpassword", "tester"), commandService);

    // then
    verify(commandService).send(sender, MessageKey.INVALID_PASSWORD_LENGTH);
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }
  @Test
  public void shouldRejectUnsafeCustomPassword() {
    // given
    CommandSender sender = initPlayerWithName("player", true);
    ChangePasswordCommand command = new ChangePasswordCommand();
    given(commandService.getProperty(SecuritySettings.UNSAFE_PASSWORDS))
        .willReturn(Arrays.asList("test", "abc123"));

    // when
    command.executeCommand(sender, Arrays.asList("oldpw", "abc123"), commandService);

    // then
    verify(commandService).send(sender, MessageKey.PASSWORD_UNSAFE_ERROR);
    assertThat(wrapperMock.wasMockCalled(Server.class), equalTo(false));
  }