### Question:
NewAPI { public boolean registerPlayer(String playerName, String password) { String name = playerName.toLowerCase(); if (isRegistered(name)) { return false; } HashedPassword result = passwordSecurity.computeHash(password, name); PlayerAuth auth = PlayerAuth.builder() .name(name) .password(result) .realName(playerName) .registrationDate(System.currentTimeMillis()) .build(); return dataSource.saveAuth(auth); } @Inject  NewAPI(AuthMe plugin, DataSource dataSource, PasswordSecurity passwordSecurity,
           Management management, ValidationService validationService, PlayerCache playerCache); static NewAPI getInstance(); AuthMe getPlugin(); String getPluginVersion(); boolean isAuthenticated(Player player); boolean isNPC(Player player); boolean isUnrestricted(Player player); Location getLastLocation(Player player); boolean isRegistered(String playerName); boolean checkPassword(String playerName, String passwordToCheck); boolean registerPlayer(String playerName, String password); void forceLogin(Player player); void forceLogout(Player player); void forceRegister(Player player, String password, boolean autoLogin); void forceRegister(Player player, String password); void forceUnregister(Player player); void forceUnregister(String name); List<String> getRegisteredNames(); List<String> getRegisteredRealNames();  }### Answer:
@Test public void shouldRegisterPlayer() { String name = "Marco"; String password = "myP4ss"; HashedPassword hashedPassword = new HashedPassword("0395872SLKDFJOWEIUTEJSD"); given(passwordSecurity.computeHash(password, name.toLowerCase())).willReturn(hashedPassword); given(dataSource.saveAuth(any(PlayerAuth.class))).willReturn(true); boolean result = api.registerPlayer(name, password); assertThat(result, equalTo(true)); verify(passwordSecurity).computeHash(password, name.toLowerCase()); ArgumentCaptor<PlayerAuth> authCaptor = ArgumentCaptor.forClass(PlayerAuth.class); verify(dataSource).saveAuth(authCaptor.capture()); assertThat(authCaptor.getValue().getNickname(), equalTo(name.toLowerCase())); assertThat(authCaptor.getValue().getRealName(), equalTo(name)); assertThat(authCaptor.getValue().getPassword(), equalTo(hashedPassword)); }
@Test public void shouldNotRegisterAlreadyRegisteredPlayer() { String name = "jonah"; given(dataSource.isAuthAvailable(name)).willReturn(true); boolean result = api.registerPlayer(name, "pass"); assertThat(result, equalTo(false)); verify(dataSource, only()).isAuthAvailable(name); verifyZeroInteractions(management, passwordSecurity); }