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

Fix #205 : Crash due to PUT content response update #206

Merged
merged 1 commit into from
Oct 5, 2021
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/main/java/org/blondin/mpg/root/MpgClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Team getTeam(String leagueTeamId) {
if (!StringUtils.startsWith(leagueTeamId, "mpg_team_")) {
throw new UnsupportedOperationException(String.format(ERROR_MESSAGE_LEAGUE, leagueTeamId, "mpg_team_"));
}
return get("/team/" + leagueTeamId, headers, Team.class);
return get("team/" + leagueTeamId, headers, Team.class);
}

public Coach getCoach(String leagueDivisionId) {
Expand Down Expand Up @@ -121,8 +121,8 @@ public void updateCoach(String matchId, CoachRequest coachRequest) {
if (!StringUtils.startsWith(matchId, "mpg_match_team_formation_")) {
throw new UnsupportedOperationException(String.format("Coach match id '%s' should start with 'mpg_match_team_formation_'", matchId));
}
String result = put("/match-team-formation/" + matchId, headers, coachRequest, String.class);
if (!"{\"success\":true}".equals(result)) {
String result = put("match-team-formation/" + matchId, headers, coachRequest, String.class);
if (StringUtils.isBlank(result) || !result.contains(matchId)) {
throw new UnsupportedOperationException(String.format("The team has not been updated, result message: %s", result));
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/org/blondin/mpg/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public void testCaptainNotOnMainPitch() throws Exception {
stubFor(put("/match-team-formation/mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")
.withRequestBody(equalToJson(getTestFileToString("mpg.coach.MLAX7HMK.20210812.withNotOnMainPitchCaptain-Request.json")))
.willReturn(aResponse().withStatus(Response.Status.OK.getStatusCode()).withHeader("Content-Type", "application/json")
.withBody("{\"success\":true}")));
.withBody("Fake: mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")));
Config config = spy(getConfig());
doReturn(true).when(config).isTeampUpdate();
doReturn(false).when(config).isTacticalSubstitutes();
Expand All @@ -98,7 +98,7 @@ public void testCaptainAlreadySelected() throws Exception {
stubFor(put("/match-team-formation/mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")
.withRequestBody(equalToJson(getTestFileToString("mpg.coach.MLAX7HMK.20210812.withCaptain-Request.json")))
.willReturn(aResponse().withStatus(Response.Status.OK.getStatusCode()).withHeader("Content-Type", "application/json")
.withBody("{\"success\":true}")));
.withBody("Fake: mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")));
Config config = spy(getConfig());
doReturn(true).when(config).isTeampUpdate();
doReturn(false).when(config).isTacticalSubstitutes();
Expand All @@ -122,7 +122,7 @@ public void testCaptainAdd() throws Exception {
stubFor(put("/match-team-formation/mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")
.withRequestBody(equalToJson(getTestFileToString("mpg.coach.MLAX7HMK.20210812.withNoCaptain-Request.json")))
.willReturn(aResponse().withStatus(Response.Status.OK.getStatusCode()).withHeader("Content-Type", "application/json")
.withBody("{\"success\":true}")));
.withBody("Fake: mpg_match_team_formation_MLAX7HMK_3_1_1_5_6")));
Config config = spy(getConfig());
doReturn(true).when(config).isTeampUpdate();
doReturn(false).when(config).isTacticalSubstitutes();
Expand Down Expand Up @@ -235,7 +235,7 @@ public void testProcessFromEmptyCoach() throws Exception {
stubFor(put("/match-team-formation/mpg_match_team_formation_MLEFEX6G_3_1_2_2_2")
.withRequestBody(equalToJson(getTestFileToString("mpg.coach.MLEFEX6G.20210804-Request.json")))
.willReturn(aResponse().withStatus(Response.Status.OK.getStatusCode()).withHeader("Content-Type", "application/json")
.withBody("{\"success\":true}")));
.withBody("Fake: mpg_match_team_formation_MLEFEX6G_3_1_2_2_2")));
executeMainProcess(config);
Assert.assertTrue(getLogOut(), getLogOut().contains("Ligue 2 Fous"));
Assert.assertTrue(getLogOut(), getLogOut().contains("Ba"));
Expand Down