Skip to content

Commit

Permalink
Fix #218 : Manage league last list day
Browse files Browse the repository at this point in the history
  • Loading branch information
axel3rd committed Dec 12, 2021
1 parent 2698694 commit 710acc4
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main/java/org/blondin/mpg/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ static void processLeague(League league, ApiClients apiClients, Config config) {
processMercatoLeague(league, apiClients, config);
break;
case GAMES:
if (league.isLive() && StringUtils.isBlank(league.getNextRealGameWeekDate())) {
LOG.info("\nThis is the last live day, no next week.\n");
return;
}
processGames(league, apiClients, config);
break;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/blondin/mpg/root/model/League.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public class League {
private LeagueStatus status;
private Mode mode;
private int currentTeamStatus;
@JsonProperty("isLive")
private boolean live;
private String nextRealGameWeekDate;

public String getId() {
return StringUtils.removeStart(leagueId, "mpg_league_");
Expand Down Expand Up @@ -51,4 +54,12 @@ public int getCurrentTeamStatus() {
return currentTeamStatus;
}

public boolean isLive() {
return live;
}

public String getNextRealGameWeekDate() {
return nextRealGameWeekDate;
}

}
12 changes: 12 additions & 0 deletions src/test/java/org/blondin/mpg/MainTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@ public void testRealWithBadCredentials() throws Exception {
}
}

@Test
public void testLastLiveDay() throws Exception {
stubFor(post("/user/sign-in")
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("mpg.user-signIn.fake.json")));
stubFor(get("/dashboard/leagues")
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("mpg.dashboard.NL931FU9-noNextweek.json")));
Config config = spy(getConfig());
executeMainProcess(config);

Assert.assertTrue(getLogOut(), getLogOut().contains("This is the last live day, no next week"));
}

@Test
public void testCaptainAndBoostPlayerBonus3() throws Exception {
prepareMainFrenchLigue1Mocks("MLAX7HMK-20211122", "2021", "20211122", "20211122");
Expand Down
84 changes: 84 additions & 0 deletions src/test/resources/__files/mpg.dashboard.NL931FU9-noNextweek.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
{
"leaguesDivisionsItems": [
{
"leagueId": "mpg_league_NL931FU9",
"name": "¿Donde esta el Messi?",
"adminId": "user_35635",
"status": 4,
"season": 1,
"mode": 2,
"createdAt": "2021-08-22T15:32:30Z",
"mercatoState": {
"divisionsLeft": 0,
"usersLeft": 0
},
"championshipId": 3,
"rating": "mpg",
"imageUrl": "https://s3.eu-west-1.amazonaws.com/image.mpg/0d4b437e-d239-447f-9b93-6fb676fd4db5.jpg",
"totalDivisions": 1,
"totalUsers": 8,
"totalMissedPosts": 0,
"teamId": "mpg_team_NL931FU9_1_1_4",
"divisionNumber": 1,
"isLive": true,
"nextRealGameWeekDateNotExistWhenLeagueFinished": "2021-12-17T17:30:00Z",
"currentTeamRanking": 5,
"currentTeamVariation": 0,
"divisionStatus": 4,
"divisionId": "mpg_division_NL931FU9_1_1",
"divisionTotalUsers": 8,
"liveState": {
"currentGameWeek": 14,
"firstRealGameWeek": 4,
"formationsStatuses": {
"mpg_team_NL931FU9_1_1_0": 2,
"mpg_team_NL931FU9_1_1_1": 2,
"mpg_team_NL931FU9_1_1_2": 2,
"mpg_team_NL931FU9_1_1_3": 2,
"mpg_team_NL931FU9_1_1_4": 2,
"mpg_team_NL931FU9_1_1_5": 2,
"mpg_team_NL931FU9_1_1_6": 1,
"mpg_team_NL931FU9_1_1_7": 1
},
"liveAt": "2021-08-31T13:51:10Z",
"standings": {
"mpg_team_NL931FU9_1_1_3": {
"rank": 1,
"variation": 0
},
"mpg_team_NL931FU9_1_1_5": {
"rank": 2,
"variation": 0
},
"mpg_team_NL931FU9_1_1_0": {
"rank": 3,
"variation": 1
},
"mpg_team_NL931FU9_1_1_2": {
"rank": 4,
"variation": -1
},
"mpg_team_NL931FU9_1_1_4": {
"rank": 5,
"variation": 0
},
"mpg_team_NL931FU9_1_1_1": {
"rank": 6,
"variation": 0
},
"mpg_team_NL931FU9_1_1_6": {
"rank": 7,
"variation": 0
},
"mpg_team_NL931FU9_1_1_7": {
"rank": 8,
"variation": 0
}
},
"totalGameWeeks": 14
},
"currentFormationStatus": 2
}
],
"defaultOrder": false
}

0 comments on commit 710acc4

Please sign in to comment.