Skip to content

Commit

Permalink
Fix #205 : Crash due to PUT content response update
Browse files Browse the repository at this point in the history
  • Loading branch information
axel3rd committed Oct 5, 2021
1 parent 950c72e commit 6cf5199
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
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

0 comments on commit 6cf5199

Please sign in to comment.