### Question:
AuthMeApi { public String getLastIp(String playerName) { PlayerAuth auth = playerCache.getAuth(playerName); if (auth == null) { auth = dataSource.getAuth(playerName); } if (auth != null) { return auth.getLastIp(); } return null; } @Inject  AuthMeApi(AuthMe plugin, DataSource dataSource, PlayerCache playerCache, PasswordSecurity passwordSecurity,
              Management management, ValidationService validationService, GeoIpService geoIpService); static AuthMeApi getInstance(); AuthMe getPlugin(); String getPluginVersion(); boolean isAuthenticated(Player player); boolean isNpc(Player player); boolean isUnrestricted(Player player); Location getLastLocation(Player player); String getLastIp(String playerName); List<String> getNamesByIp(String address); @Deprecated Date getLastLogin(String playerName); Instant getLastLoginTime(String playerName); 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); void changePassword(String name, String newPassword); List<String> getRegisteredNames(); List<String> getRegisteredRealNames(); String getCountryCode(String ip); String getCountryName(String ip);  }### Answer:
@Test public void shouldGetLastIp() { String name = "Gabriel"; Player player = mockPlayerWithName(name); PlayerAuth auth = PlayerAuth.builder().name(name) .lastIp("93.23.44.55") .build(); given(playerCache.getAuth(name)).willReturn(auth); String result = api.getLastIp(player.getName()); assertThat(result, not(nullValue())); assertThat(result, equalTo("93.23.44.55")); }
@Test public void shouldReturnNullAsLastIpForUnknownUser() { String name = "Harrison"; given(playerCache.getAuth(name)).willReturn(null); given(dataSource.getAuth(name)).willReturn(null); String result = api.getLastIp(name); assertThat(result, nullValue()); verify(playerCache).getAuth(name); verify(dataSource).getAuth(name); }