From a9c063006431fefeba1b7f8bc43da63aac48a2f0 Mon Sep 17 00:00:00 2001 From: BlackYps Date: Fri, 18 Aug 2023 18:13:45 +0200 Subject: [PATCH 1/4] Add gameId column to LeagueScoreJournal --- .../faforever/api/config/LeagueDbTestContainers.java | 2 +- .../api/league/LeagueScoreJournalElideTest.java | 12 +++++++++++- src/inttest/resources/sql/league/prepLeagueData.sql | 10 +++++----- .../api/league/domain/LeagueScoreJournal.java | 6 ++++++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/inttest/java/com/faforever/api/config/LeagueDbTestContainers.java b/src/inttest/java/com/faforever/api/config/LeagueDbTestContainers.java index 2ffc640c6..544aaeb48 100644 --- a/src/inttest/java/com/faforever/api/config/LeagueDbTestContainers.java +++ b/src/inttest/java/com/faforever/api/config/LeagueDbTestContainers.java @@ -20,7 +20,7 @@ @Configuration public class LeagueDbTestContainers { private static final MariaDBContainer leagueServiceDBContainer = new MariaDBContainer<>("mariadb:10.6"); - private static final GenericContainer leagueServiceContainer = new GenericContainer<>("faforever/faf-league-service:1.3.0"); + private static final GenericContainer leagueServiceContainer = new GenericContainer<>("faforever/faf-league-service:1.5.0"); private static final Network sharedNetwork = Network.newNetwork(); @Bean diff --git a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java index c895e2fea..3d772368a 100644 --- a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java +++ b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java @@ -9,6 +9,7 @@ import static com.faforever.api.data.JsonApiMediaType.JSON_API_MEDIA_TYPE; import static org.hamcrest.Matchers.hasSize; +import static org.hamcrest.Matchers.is; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch; @@ -43,7 +44,15 @@ void anyOneCanReadSpecificLeagueScoreJournal() throws Exception { mockMvc.perform( get("/data/leagueScoreJournal/1") ) - .andExpect(status().isOk()); + .andExpect(status().isOk()) + .andExpect(jsonPath("$.data.attributes.gameId", is(2))) + .andExpect(jsonPath("$.data.attributes.loginId", is(1))) + .andExpect(jsonPath("$.data.attributes.leagueSeasonId", is(1))) + .andExpect(jsonPath("$.data.attributes.subdivisionIdBefore", is(1))) + .andExpect(jsonPath("$.data.attributes.subdivisionIdAfter", is(2))) + .andExpect(jsonPath("$.data.attributes.scoreBefore", is(10))) + .andExpect(jsonPath("$.data.attributes.scoreAfter", is(2))) + .andExpect(jsonPath("$.data.attributes.gameCount", is(22))); } @Test @@ -57,6 +66,7 @@ void noOneCanCreateLeagueScoreJournal() throws Exception { "data": { "type": "leagueScoreJournal", "attributes": { + "gameId": 10, "gameCount": 10, "loginId": 10, "scoreBefore": 10, diff --git a/src/inttest/resources/sql/league/prepLeagueData.sql b/src/inttest/resources/sql/league/prepLeagueData.sql index fd6a69c6d..dbd7bf1ca 100644 --- a/src/inttest/resources/sql/league/prepLeagueData.sql +++ b/src/inttest/resources/sql/league/prepLeagueData.sql @@ -34,9 +34,9 @@ VALUES (1, 1, 1, 1, 10, 10, FALSE), (7, 1, 2, 7, 22, 20, FALSE), (8, 1, 2, 8, 23, 20, FALSE); -INSERT INTO league_score_journal (id, login_id, league_season_id, subdivision_id_before, subdivision_id_after, +INSERT INTO league_score_journal (id, game_id, login_id, league_season_id, subdivision_id_before, subdivision_id_after, score_before, score_after, game_count) -VALUES (1, 1, 1, 1, 2, 10, 2, 22), - (2, 1, 1, 2, 2, 2, 3, 23), - (3, 5, 1, 3, 3, 7, 6, 11), - (4, 5, 1, 3, 3, 6, 5, 12); +VALUES (1, 2, 1, 1, 1, 2, 10, 2, 22), + (2, 2, 1, 1, 2, 2, 2, 3, 23), + (3, 2, 5, 1, 3, 3, 7, 6, 11), + (4, 2, 5, 1, 3, 3, 6, 5, 12); diff --git a/src/main/java/com/faforever/api/league/domain/LeagueScoreJournal.java b/src/main/java/com/faforever/api/league/domain/LeagueScoreJournal.java index 7b8952247..3200869ca 100644 --- a/src/main/java/com/faforever/api/league/domain/LeagueScoreJournal.java +++ b/src/main/java/com/faforever/api/league/domain/LeagueScoreJournal.java @@ -20,6 +20,7 @@ public class LeagueScoreJournal { public static final String TYPE_NAME = "leagueScoreJournal"; private Integer id; + private Integer gameId; private Integer loginId; private LeagueSeason leagueSeason; private LeagueSeasonDivisionSubdivision leagueSeasonDivisionSubdivisionBefore; @@ -35,6 +36,11 @@ public Integer getId() { return id; } + @Column(name = "game_id") + public Integer getGameId() { + return gameId; + } + @Column(name = "login_id") public Integer getLoginId() { return loginId; From 776ce7c21b0c1ff69f05f5ded0576afe4e7dba1e Mon Sep 17 00:00:00 2001 From: BlackYps Date: Sun, 3 Sep 2023 00:24:48 +0200 Subject: [PATCH 2/4] Fix test because 3v3 leaderboard has been added --- .../java/com/faforever/api/league/LeaderboardElideTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/inttest/java/com/faforever/api/league/LeaderboardElideTest.java b/src/inttest/java/com/faforever/api/league/LeaderboardElideTest.java index 15a1999c9..756e8fb9d 100644 --- a/src/inttest/java/com/faforever/api/league/LeaderboardElideTest.java +++ b/src/inttest/java/com/faforever/api/league/LeaderboardElideTest.java @@ -28,7 +28,7 @@ void anyOneCanReadAllLeaderboard() throws Exception { get("/data/leagueLeaderboard") ) .andExpect(status().isOk()) - .andExpect(jsonPath("$.data[*]", hasSize(5))); + .andExpect(jsonPath("$.data[*]", hasSize(6))); } @Test From 3176d1d70ff5dcbbe6dc918159b085418bdf020c Mon Sep 17 00:00:00 2001 From: BlackYps Date: Sun, 3 Sep 2023 00:37:28 +0200 Subject: [PATCH 3/4] Fix leagueScoreJournal test --- .../faforever/api/league/LeagueScoreJournalElideTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java index 3d772368a..c9b44b275 100644 --- a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java +++ b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java @@ -47,9 +47,9 @@ void anyOneCanReadSpecificLeagueScoreJournal() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.data.attributes.gameId", is(2))) .andExpect(jsonPath("$.data.attributes.loginId", is(1))) - .andExpect(jsonPath("$.data.attributes.leagueSeasonId", is(1))) - .andExpect(jsonPath("$.data.attributes.subdivisionIdBefore", is(1))) - .andExpect(jsonPath("$.data.attributes.subdivisionIdAfter", is(2))) + .andExpect(jsonPath("$.data.relationships.leagueSeason.data.id", is(1))) + .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionBefore.data.id", is(1))) + .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionAfter.data.id", is(2))) .andExpect(jsonPath("$.data.attributes.scoreBefore", is(10))) .andExpect(jsonPath("$.data.attributes.scoreAfter", is(2))) .andExpect(jsonPath("$.data.attributes.gameCount", is(22))); From ec4653f3a7a29a3e04d10bd33d963dfcb4a9d427 Mon Sep 17 00:00:00 2001 From: BlackYps Date: Sun, 3 Sep 2023 00:47:51 +0200 Subject: [PATCH 4/4] Fix test attempt #2 --- .../faforever/api/league/LeagueScoreJournalElideTest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java index c9b44b275..0db4c9480 100644 --- a/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java +++ b/src/inttest/java/com/faforever/api/league/LeagueScoreJournalElideTest.java @@ -47,9 +47,9 @@ void anyOneCanReadSpecificLeagueScoreJournal() throws Exception { .andExpect(status().isOk()) .andExpect(jsonPath("$.data.attributes.gameId", is(2))) .andExpect(jsonPath("$.data.attributes.loginId", is(1))) - .andExpect(jsonPath("$.data.relationships.leagueSeason.data.id", is(1))) - .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionBefore.data.id", is(1))) - .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionAfter.data.id", is(2))) + .andExpect(jsonPath("$.data.relationships.leagueSeason.data.id", is("1"))) + .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionBefore.data.id", is("1"))) + .andExpect(jsonPath("$.data.relationships.leagueSeasonDivisionSubdivisionAfter.data.id", is("2"))) .andExpect(jsonPath("$.data.attributes.scoreBefore", is(10))) .andExpect(jsonPath("$.data.attributes.scoreAfter", is(2))) .andExpect(jsonPath("$.data.attributes.gameCount", is(22)));