Improve error output and add team id matcher template creator

This commit is contained in:
2020-11-04 21:22:27 +01:00
parent 2f411aae67
commit d42edcf01c
15 changed files with 158 additions and 154 deletions

View File

@@ -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);
}
}

View File

@@ -9,20 +9,18 @@ public class APIFootballUpdaterTest {
@Test
public void updateFixturesTest() throws IOException {
APIFootballUpdater updater = new APIFootballUpdater(2021);
// updater.updateFixtures(2743);
// updater.updateFixtures(2692);
}
@Test
public void updateAllFixturesTest() throws IOException {
APIFootballUpdater updater = new APIFootballUpdater(2021);
// updater.updateAllFixtures("Tippliga.json");
// updater.updateAllFixtures("WTL_Pokal.json");
// updater.updateAllFixtures();
}
@Test
public void updateAllRoundsTest() throws IOException {
APIFootballUpdater updater = new APIFootballUpdater(2021);
// updater.updateAllRounds("Tippliga.json");
// updater.updateAllRounds("WTL_Pokal.json");
// updater.updateAllRounds();
}
}

View File

@@ -8,7 +8,7 @@ public class MatchesListGistUpdaterTest {
@Test
public void updateAllLeaguesTest() throws UnsupportedEncodingException {
MatchesListGistUpdater updater = new MatchesListGistUpdater("Tippliga.json");
// updater.updateAllLeagues();
MatchesListGistUpdater updater = new MatchesListGistUpdater();
updater.updateAllLeagues();
}
}

View File

@@ -0,0 +1,13 @@
package de.jeyp91.gists;
import org.junit.Test;
public class TeamIDMatcherTemplateCreatorTest {
@Test
public void getTeamsTemplate() {
TeamIDMatcherTemplateCreator creator = new TeamIDMatcherTemplateCreator(0, 2790);
String template = creator.getTeamsTemplate();
System.out.println(template);
}
}