Try to fetch steam game count if requested and cache it

This commit is contained in:
Andreas Dahm committed 2026-04-28 15:43:02 +02:00
1 parent be9b70c541
commit 1b08e7902c
9 files changed
+125 -10

No files matched your search

@@ -32,6 +32,27 @@ class SteamApiServiceTest {
ReflectionTestUtils.setField(steamApiService, "apiKey", "test-api-key");
}
@Test
void getOwnedGamesCount_shouldReturnCount() {
String steamId = "76561197960435530";
String jsonResponse = """
{
"response": {
"game_count": 42
}
}
""";
server.expect(requestTo(containsString("/IPlayerService/GetOwnedGames/v0001/")))
.andExpect(queryParam("steamid", steamId))
.andExpect(queryParam("key", "test-api-key"))
.andRespond(withSuccess(jsonResponse, MediaType.APPLICATION_JSON));
int result = steamApiService.getOwnedGamesCount(steamId);
assertThat(result).isEqualTo(42);
}
@Test
void getPlayerSummary_shouldReturnPlayer() {
String steamId = "76561197960435530";
@@ -89,7 +110,7 @@ class SteamApiServiceTest {
List<SteamOwnedGamesResponse.Game> result = steamApiService.getOwnedGames(steamId);
assertThat(result).hasSize(1);
assertThat(result.get(0).name()).isEqualTo("Counter-Strike");
assertThat(result.getFirst().name()).isEqualTo("Counter-Strike");
}
@Test
@@ -115,9 +136,9 @@ class SteamApiServiceTest {
List<SteamOwnedGamesResponse.Game> result = steamApiService.getOwnedGames(steamId);
assertThat(result).hasSize(1);
assertThat(result.get(0).name()).isEqualTo("Counter-Strike");
assertThat(result.get(0).playtimeForever()).isNull();
assertThat(result.get(0).hasCommunityVisibleStats()).isNull();
assertThat(result.getFirst().name()).isEqualTo("Counter-Strike");
assertThat(result.getFirst().playtimeForever()).isNull();
assertThat(result.getFirst().hasCommunityVisibleStats()).isNull();
}
@Test
@@ -165,6 +186,6 @@ class SteamApiServiceTest {
assertThat(result).isPresent();
assertThat(result.get().player().personaname()).isEqualTo("TestUser");
assertThat(result.get().games()).hasSize(1);
assertThat(result.get().games().get(0).name()).isEqualTo("Counter-Strike");
assertThat(result.get().games().getFirst().name()).isEqualTo("Counter-Strike");
}
}