package de.jeyp91; import de.jeyp91.apifootball.APIFootballMatch; import de.jeyp91.teamidmatcher.TeamIDMatcher; 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; public class TeamIDMatcherTest { @Test public void getOpenLigaDbIdFromTippligaIdTest() { int apiFootballId; apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(505); assertEquals(80, apiFootballId); apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(160); assertEquals(91, apiFootballId); apiFootballId = TeamIDMatcher.getApiFootballIdFromTippligaId(182); assertEquals(12754, apiFootballId); } @Test public void getTippligaIdFromOpenLigaDbIdTest() throws ParseException { int tlwId; 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); match.teamIdHome = 91; tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME); assertEquals(160, tlwId); match.teamIdHome = 12754; tlwId = TeamIDMatcher.getTippligaIdFromApiFootballId(match, TeamIDMatcher.HOME); assertEquals(182, tlwId); } }