Parse overtime goals

This commit is contained in:
2023-04-10 13:39:45 +02:00
parent d078a182a1
commit 12164c03ae
5 changed files with 67 additions and 1 deletions

View File

@@ -0,0 +1,23 @@
package de.jeyp91.apifootball;
import org.json.simple.JSONObject;
import org.junit.Test;
import static de.jeyp91.apifootball.APIFootballConnector.stringToJSONObject;
public class APIFootballMatchTest {
@Test
public void withExtratime() throws Exception {
String matchString = "{\"fixture_id\":958530,\"league_id\":4303,\"league\":{\"name\":\"DFB Pokal\",\"country\":\"Germany\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/leagues\\/81.png\",\"flag\":\"https:\\/\\/media-1.api-sports.io\\/flags\\/de.svg\"},\"event_date\":\"2022-10-19T18:00:00+02:00\",\"event_timestamp\":1666195200,\"firstHalfStart\":1666195200,\"secondHalfStart\":1666198800,\"round\":\"2nd Round\",\"status\":\"Match Finished\",\"statusShort\":\"PEN\",\"elapsed\":120,\"venue\":\"Home Deluxe Arena\",\"referee\":\"Frank Willenborg, Germany\",\"homeTeam\":{\"team_id\":185,\"team_name\":\"SC Paderborn 07\",\"logo\":\"https:\\/\\/media-2.api-sports.io\\/football\\/teams\\/185.png\"},\"awayTeam\":{\"team_id\":162,\"team_name\":\"Werder Bremen\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/teams\\/162.png\"},\"goalsHomeTeam\":2,\"goalsAwayTeam\":2,\"score\":{\"halftime\":\"2-0\",\"fulltime\":\"2-2\",\"extratime\":\"0-0\",\"penalty\":\"5-4\"}}";
JSONObject matchJson = stringToJSONObject(matchString);
APIFootballMatch match = new APIFootballMatch(matchJson, 2023);
}
@Test
public void withoutExtratime() throws Exception {
String matchString = "{\"fixture_id\":958530,\"league_id\":4303,\"league\":{\"name\":\"DFB Pokal\",\"country\":\"Germany\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/leagues\\/81.png\",\"flag\":\"https:\\/\\/media-1.api-sports.io\\/flags\\/de.svg\"},\"event_date\":\"2022-10-19T18:00:00+02:00\",\"event_timestamp\":1666195200,\"firstHalfStart\":1666195200,\"secondHalfStart\":1666198800,\"round\":\"2nd Round\",\"status\":\"Match Finished\",\"statusShort\":\"PEN\",\"elapsed\":120,\"venue\":\"Home Deluxe Arena\",\"referee\":\"Frank Willenborg, Germany\",\"homeTeam\":{\"team_id\":185,\"team_name\":\"SC Paderborn 07\",\"logo\":\"https:\\/\\/media-2.api-sports.io\\/football\\/teams\\/185.png\"},\"awayTeam\":{\"team_id\":162,\"team_name\":\"Werder Bremen\",\"logo\":\"https:\\/\\/media-3.api-sports.io\\/football\\/teams\\/162.png\"},\"goalsHomeTeam\":2,\"goalsAwayTeam\":2,\"score\":{\"halftime\":\"2-0\",\"fulltime\":\"2-2\",\"extratime\":null,\"penalty\":null}}";
JSONObject matchJson = stringToJSONObject(matchString);
APIFootballMatch match = new APIFootballMatch(matchJson, 2023);
}
}