-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
63 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/test/java/org/blondin/mpg/out/InjuredSuspendedWrapperClientTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.blondin.mpg.out; | ||
|
||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.get; | ||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; | ||
|
||
import org.blondin.mpg.AbstractMockTestClient; | ||
import org.blondin.mpg.out.model.Position; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import com.github.tomakehurst.wiremock.http.Fault; | ||
|
||
public class InjuredSuspendedWrapperClientTest extends AbstractMockTestClient { | ||
|
||
@Test | ||
public void testType() throws Exception { | ||
stubFor(get("/injuries/football/france-ligue-1/").willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("sportsgambler.ligue-1.20230807.html"))); | ||
stubFor(get("/2020/08/20/joueurs-blesses-et-suspendus/") | ||
.willReturn(aResponse().withHeader("Content-Type", "application/json").withBodyFile("maligue2.joueurs-blesses-et-suspendus.20230802.html"))); | ||
|
||
InjuredSuspendedWrapperClient client = InjuredSuspendedWrapperClient.build(getConfig(), "http://localhost:" + getServer().port() + "/injuries/football/", | ||
"http://localhost:" + getServer().port() + "/2020/08/20/joueurs-blesses-et-suspendus/"); | ||
|
||
Assert.assertNotNull("L1", client.getPlayer(ChampionshipOutType.LIGUE_1, "Sergio Rico", Position.G, "Paris SG")); | ||
Assert.assertNotNull("L2", client.getPlayer(ChampionshipOutType.LIGUE_2, "Guidi", Position.D, "Bastia")); | ||
} | ||
|
||
@Test | ||
public void testFailSportsgambler() throws Exception { | ||
stubFor(get("/injuries/football/france-ligue-1/").willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE))); | ||
InjuredSuspendedWrapperClient client = InjuredSuspendedWrapperClient.build(getConfig(), "http://localhost:" + getServer().port() + "/injuries/football/", null); | ||
Assert.assertNull(client.getPlayer(ChampionshipOutType.LIGUE_1, "Sergio Rico", Position.G, "Paris SG")); | ||
Assert.assertTrue(getLogOut(), getLogOut().contains("WARN: SportsGambler is unavailable, injured/suspended players not taken into account")); | ||
} | ||
|
||
@Test | ||
public void testFailMaligue2() throws Exception { | ||
stubFor(get("/2020/08/20/joueurs-blesses-et-suspendus/").willReturn(aResponse().withFault(Fault.RANDOM_DATA_THEN_CLOSE))); | ||
InjuredSuspendedWrapperClient client = InjuredSuspendedWrapperClient.build(getConfig(), null, "http://localhost:" + getServer().port() + "/2020/08/20/joueurs-blesses-et-suspendus/"); | ||
Assert.assertNull(client.getPlayer(ChampionshipOutType.LIGUE_2, "Guidi", Position.D, "Bastia")); | ||
Assert.assertTrue(getLogOut(), getLogOut().contains("WARN: Maligue2.fr is unavailable, L2 injured/suspended players not taken into account")); | ||
} | ||
} |