fix tests

This commit is contained in:
Lee 2024-04-13 17:21:33 +01:00
parent b5e8664ad3
commit e5e3503abc
3 changed files with 12 additions and 7 deletions

@ -9,19 +9,23 @@ import java.util.UUID;
/** /**
* @author Braydon * @author Braydon
*/ */
@AllArgsConstructor
@Getter @Getter
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@ToString @ToString
@RedisHash(value = "playerName", timeToLive = 60L * 60L * 6) // 6 hours (in seconds) @RedisHash(value = "playerName", timeToLive = 60L * 60L * 6) // 6 hours (in seconds)
public final class CachedPlayerName { public final class CachedPlayerName extends CachedResponse {
/** /**
* The username of the player. * The username of the player.
*/ */
@Id @NonNull private String username; @Id private final String username;
/** /**
* The unique id of the player. * The unique id of the player.
*/ */
@NonNull private UUID uniqueId; private final UUID uniqueId;
public CachedPlayerName(String username, UUID uniqueId) {
super(CacheInformation.defaultCache());
this.username = username;
this.uniqueId = uniqueId;
}
} }

@ -115,6 +115,7 @@ public class PlayerService {
CachedPlayerName player = new CachedPlayerName(username, uuid); CachedPlayerName player = new CachedPlayerName(username, uuid);
playerNameCacheRepository.save(player); playerNameCacheRepository.save(player);
log.info("Got UUID from username: {} -> {}", username, uuid); log.info("Got UUID from username: {} -> {}", username, uuid);
player.getCache().setCached(false);
return player; return player;
} catch (RateLimitException exception) { } catch (RateLimitException exception) {
throw new MojangAPIRateLimitException(); throw new MojangAPIRateLimitException();

@ -48,8 +48,8 @@ class PlayerControllerTests {
.accept(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON)
.contentType(MediaType.APPLICATION_JSON)) .contentType(MediaType.APPLICATION_JSON))
.andExpect(status().isOk()) .andExpect(status().isOk())
.andExpect(jsonPath("$.player.username").value(testPlayer)) .andExpect(jsonPath("$.username").value(testPlayer))
.andExpect(jsonPath("$.player.uniqueId").value(testPlayerUuid)); .andExpect(jsonPath("$.uniqueId").value(testPlayerUuid));
} }
@Test @Test