Improve error output and add team id matcher template creator
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
package de.jeyp91;
|
||||
import de.jeyp91.apifootball.APIFootballMatch;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -18,14 +22,39 @@ public class TeamIDMatcherTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getTippligaIdFromOpenLigaDbIdTest() {
|
||||
public void getTippligaIdFromOpenLigaDbIdTest() throws ParseException {
|
||||
int tlwId;
|
||||
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(80);
|
||||
String jsonMatch = "{" +
|
||||
"\"fixture_id\":1," +
|
||||
"\"league_id\":1240," +
|
||||
"\"league\":{" +
|
||||
"\"name\":\"Testliga\"" +
|
||||
"}," +
|
||||
"\"event_date\":\"2020-01-01T00:00:00+02:00\"" +
|
||||
"\"round\":\"Bayern - 1\"," +
|
||||
"\"statusShort\":\"FT\"" +
|
||||
"\"homeTeam\":{" +
|
||||
"\"team_id\":9330," +
|
||||
"\"team_name\":\"TestHome\"" +
|
||||
"}," +
|
||||
"\"awayTeam\":{" +
|
||||
"\"team_id\":9331," +
|
||||
"\"team_name\":\"TestGuest\"" +
|
||||
"}" +
|
||||
"}";
|
||||
JSONObject matchObject;
|
||||
JSONParser jsonParser = new JSONParser();
|
||||
matchObject = (JSONObject) jsonParser.parse(jsonMatch);
|
||||
APIFootballMatch match = new APIFootballMatch(matchObject, 2021);
|
||||
;
|
||||
match.teamIdHome = 80;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(505, tlwId);
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(91);
|
||||
match.teamIdHome = 91;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(160, tlwId);
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(12754);
|
||||
match.teamIdHome = 12754;
|
||||
tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME);
|
||||
assertEquals(182, tlwId);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user