Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gameId column to LeagueScoreJournal #772

Merged
merged 4 commits into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.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)));
}

@Test
Expand All @@ -57,6 +66,7 @@ void noOneCanCreateLeagueScoreJournal() throws Exception {
"data": {
"type": "leagueScoreJournal",
"attributes": {
"gameId": 10,
"gameCount": 10,
"loginId": 10,
"scoreBefore": 10,
Expand Down
10 changes: 5 additions & 5 deletions src/inttest/resources/sql/league/prepLeagueData.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down