Skip to content

Commit

Permalink
Fix #212 : Previous bonus selected not reused
Browse files Browse the repository at this point in the history
  • Loading branch information
axel3rd committed Oct 19, 2021
1 parent 508bd28 commit 8af1690
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 57 deletions.
5 changes: 1 addition & 4 deletions src/main/java/org/blondin/mpg/root/model/Coach.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ public class Coach {
@JsonProperty("matchTeamFormation")
private MatchTeamFormation matchTeamFormation;

@JsonProperty("selectedBonus")
private SelectedBonus bonusSelected;

public String getIdMatch() {
return matchTeamFormation.getId();
}
Expand All @@ -25,7 +22,7 @@ public String getCaptain() {
}

public SelectedBonus getBonusSelected() {
return bonusSelected;
return matchTeamFormation.getSelectedBonus();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ public class MatchTeamFormation {
private String id;
private int composition;
private String captain;
private SelectedBonus selectedBonus;

public String getId() {
return id;
Expand All @@ -20,4 +21,8 @@ public int getComposition() {
public String getCaptain() {
return captain;
}

public SelectedBonus getSelectedBonus() {
return selectedBonus;
}
}
17 changes: 17 additions & 0 deletions src/test/java/org/blondin/mpg/root/MpgClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ public void testMockCoachNotEmpty() throws Exception {
Assert.assertEquals("mpg_championship_player_220237", coach.getCaptain());
}

@Test
public void testMockCoachBonus() throws Exception {
stubFor(post("/user/sign-in")
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("mpg.user-signIn.fake.json")));
stubFor(get("/division/mpg_division_MLEFEX6G_3_1/coach")
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("mpg.coach.MLEFEX6G.20211019.json")));
MpgClient mpgClient = MpgClient.build(getConfig(), "http://localhost:" + server.port());
Coach coach = mpgClient.getCoach("mpg_division_MLEFEX6G_3_1");
Assert.assertNotNull(coach);
Assert.assertTrue(coach.getComposition() > 0);
Assert.assertEquals("mpg_match_team_formation_MLEFEX6G_3_1_12_5_2", coach.getIdMatch());
Assert.assertEquals("mpg_championship_player_177449", coach.getCaptain());
Assert.assertNotNull(coach.getBonusSelected());
Assert.assertEquals("boostOnePlayer", coach.getBonusSelected().getName());
Assert.assertEquals("mpg_championship_player_437503", coach.getBonusSelected().getPlayerId());
}

@Test
public void testMockClubs() throws Exception {
stubFor(post("/user/sign-in")
Expand Down
127 changes: 74 additions & 53 deletions src/test/resources/__files/mpg.coach.MLEFEX6G.20211019.json
Original file line number Diff line number Diff line change
@@ -1,57 +1,78 @@
{
"divisionMatch": {
"id": "mpg_division_match_MLEFEX6G_3_1_12_5_5_2",
"type": "mpg_division_match",
"divisionId": "mpg_division_MLEFEX6G_3_1",
"home": {
"teamId": "mpg_team_MLEFEX6G_3_1_5"
"divisionMatch": {
"id": "mpg_division_match_MLEFEX6G_3_1_12_5_5_2",
"type": "mpg_division_match",
"divisionId": "mpg_division_MLEFEX6G_3_1",
"home": {
"teamId": "mpg_team_MLEFEX6G_3_1_5"
},
"away": {
"teamId": "mpg_team_MLEFEX6G_3_1_2"
}
},
"away": {
"teamId": "mpg_team_MLEFEX6G_3_1_2"
}
},
"matchTeamFormation": {
"id": "mpg_match_team_formation_MLEFEX6G_3_1_12_5_2",
"type": "mpg_match_team_formation",
"composition": "343",
"playersOnPitch": {
"1": null,
"2": null,
"3": null,
"4": null,
"5": null,
"6": null,
"7": null,
"8": null,
"9": null,
"10": null,
"11": null,
"12": null,
"13": null,
"14": null,
"15": null,
"16": null,
"17": null,
"18": null
"matchTeamFormation": {
"id": "mpg_match_team_formation_MLEFEX6G_3_1_12_5_2",
"type": "mpg_match_team_formation",
"composition": "343",
"playersOnPitch": {
"1": "mpg_championship_player_220359",
"2": "mpg_championship_player_454964",
"3": "mpg_championship_player_245726",
"4": "mpg_championship_player_245485",
"5": "mpg_championship_player_437503",
"6": "mpg_championship_player_177449",
"7": "mpg_championship_player_204405",
"8": null,
"9": "mpg_championship_player_244135",
"10": "mpg_championship_player_423064",
"11": "mpg_championship_player_511596",
"12": "mpg_championship_player_523643",
"13": "mpg_championship_player_512711",
"14": "mpg_championship_player_209171",
"15": null,
"16": "mpg_championship_player_225904",
"17": "mpg_championship_player_228313",
"18": "mpg_championship_player_102724"
},
"tacticalSubs": [
{
"rating": 5,
"subId": "mpg_championship_player_523643",
"starterId": "mpg_championship_player_245485"
},
{
"rating": 6,
"subId": "mpg_championship_player_225904",
"starterId": "mpg_championship_player_511596"
},
{
"rating": 6,
"subId": "mpg_championship_player_228313",
"starterId": "mpg_championship_player_423064"
}
],
"selectedBonus": {
"name": "boostOnePlayer",
"playerId": "mpg_championship_player_437503"
},
"captain": "mpg_championship_player_177449"
},
"tacticalSubs": []
},
"nextGameWeek": {
"gameWeekNumber": 13,
"startDate": "2021-10-23T13:00:00Z",
"endDate": "2021-10-25T18:45:00Z",
"startIn": 328590,
"matchesIds": [
"mpg_championship_match_2216856",
"mpg_championship_match_2216848",
"mpg_championship_match_2216849",
"mpg_championship_match_2216851",
"mpg_championship_match_2216852",
"mpg_championship_match_2216853",
"mpg_championship_match_2216854",
"mpg_championship_match_2216855",
"mpg_championship_match_2216857",
"mpg_championship_match_2216850"
]
}
"nextGameWeek": {
"gameWeekNumber": 13,
"startDate": "2021-10-23T13:00:00Z",
"endDate": "2021-10-25T18:45:00Z",
"startIn": 317812,
"matchesIds": [
"mpg_championship_match_2216856",
"mpg_championship_match_2216848",
"mpg_championship_match_2216849",
"mpg_championship_match_2216851",
"mpg_championship_match_2216852",
"mpg_championship_match_2216853",
"mpg_championship_match_2216854",
"mpg_championship_match_2216855",
"mpg_championship_match_2216857",
"mpg_championship_match_2216850"
]
}
}

0 comments on commit 8af1690

Please sign in to comment.