From 8cfb2a325a12fd03b3d401119d5c99a485ff9c4c Mon Sep 17 00:00:00 2001 From: Julian Arndt Date: Sun, 8 Nov 2020 23:04:32 +0100 Subject: [PATCH] Remove Gist --- build.gradle | 3 + src/main/java/de/jeyp91/App.java | 11 +- src/main/java/de/jeyp91/ResourceProvider.java | 45 + src/main/java/de/jeyp91/S3Provider.java | 95 ++ .../apifootball/APIFootballConnector.java | 70 +- .../jeyp91/apifootball/APIFootballMatch.java | 18 +- .../apifootball/APIFootballUpdater.java | 56 +- .../java/de/jeyp91/gists/GistProvider.java | 278 ---- .../jeyp91/gists/MatchesListGistUpdater.java | 30 - .../{ => teamidmatcher}/TeamIDMatcher.java | 12 +- .../TeamIDMatcherTemplateCreator.java | 2 +- .../java/de/jeyp91/tippliga/TLWMatch.java | 4 +- .../jeyp91/tippliga/TLWMatchdaysCreator.java | 16 +- .../jeyp91/tippliga/TLWMatchdaysUpdater.java | 7 +- .../tippliga/TLWMatchesCreatorFootball.java | 28 +- .../TLWMatchesCreatorTipperLeague.java | 23 +- .../TLWMatchesCreatorTipperPokal.java | 22 +- .../tippliga/TLWMatchesManagerBase.java | 25 +- .../tippliga/TLWMatchesUpdaterFootball.java | 5 +- .../de/jeyp91/tippliga/TLWTeamsCreator.java | 4 +- .../de/jeyp91/tippliga/TLWTeamsUpdater.java | 6 +- .../MatchesListCreator.java | 44 +- .../MatchesListForumUpdater.java | 43 + .../tippligaforum/TippligaConfigProvider.java | 32 + .../TippligaSQLConnector.java | 108 +- src/main/resources/Tippliga/Ligen.json | 72 + .../Tippliga/Team_ID_Matcher_Config.json | 582 ++++++++ .../Tippliga/Tipper_Match_Pair_Config.json | 1289 +++++++++++++++++ .../Tippliga/Tipper_Team_Config.json | 267 ++++ src/test/java/de/jeyp91/S3ProviderTest.java | 13 + .../java/de/jeyp91/TeamIDMatcherTest.java | 3 +- .../apifootball/APIFootballUpdaterTest.java | 20 +- .../de/jeyp91/gists/GistProviderTest.java | 55 - .../gists/MatchesListGistUpdaterTest.java | 14 - .../TeamIDMatcherTemplateCreatorTest.java | 3 +- .../tippliga/TLWMatchdayUpdaterTest.java | 4 +- .../tippliga/TLWMatchdaysCreatorTest.java | 16 +- .../TLWMatchesCreatorFootballTest.java | 6 +- .../TLWMatchesCreatorTipperPokalTest.java | 4 +- .../tippliga/TLWMatchesCreatorTipperTest.java | 4 +- .../TLWMatchesUpdaterFootballTest.java | 6 +- .../jeyp91/tippliga/TLWTeamsCreatorTest.java | 14 +- .../jeyp91/tippliga/TLWTeamsUpdaterTest.java | 6 +- .../tippliga/TippligaConfigProviderTest.java | 14 + .../tippliga/TippligaSQLConnectorTest.java | 45 +- .../MatchesListCreatorTest.java | 15 +- .../MatchesListForumUpdaterTest.java | 21 + tokens/StoredCredential | Bin 1089 -> 1089 bytes 48 files changed, 2792 insertions(+), 668 deletions(-) create mode 100644 src/main/java/de/jeyp91/ResourceProvider.java create mode 100644 src/main/java/de/jeyp91/S3Provider.java delete mode 100644 src/main/java/de/jeyp91/gists/GistProvider.java delete mode 100644 src/main/java/de/jeyp91/gists/MatchesListGistUpdater.java rename src/main/java/de/jeyp91/{ => teamidmatcher}/TeamIDMatcher.java (92%) rename src/main/java/de/jeyp91/{gists => teamidmatcher}/TeamIDMatcherTemplateCreator.java (97%) rename src/main/java/de/jeyp91/{gists => tippligaforum}/MatchesListCreator.java (69%) create mode 100644 src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java create mode 100644 src/main/java/de/jeyp91/tippligaforum/TippligaConfigProvider.java rename src/main/java/de/jeyp91/{tippliga => tippligaforum}/TippligaSQLConnector.java (56%) create mode 100644 src/main/resources/Tippliga/Ligen.json create mode 100644 src/main/resources/Tippliga/Team_ID_Matcher_Config.json create mode 100644 src/main/resources/Tippliga/Tipper_Match_Pair_Config.json create mode 100644 src/main/resources/Tippliga/Tipper_Team_Config.json create mode 100644 src/test/java/de/jeyp91/S3ProviderTest.java delete mode 100644 src/test/java/de/jeyp91/gists/GistProviderTest.java delete mode 100644 src/test/java/de/jeyp91/gists/MatchesListGistUpdaterTest.java rename src/test/java/de/jeyp91/{gists => teamidmatcher}/TeamIDMatcherTemplateCreatorTest.java (76%) create mode 100644 src/test/java/de/jeyp91/tippliga/TippligaConfigProviderTest.java rename src/test/java/de/jeyp91/{gists => tippligaforum}/MatchesListCreatorTest.java (67%) create mode 100644 src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java diff --git a/build.gradle b/build.gradle index 50bc9c2..690a936 100644 --- a/build.gradle +++ b/build.gradle @@ -22,6 +22,8 @@ dependencies { implementation 'org.apache.httpcomponents:httpclient:4.5.9' implementation 'com.googlecode.json-simple:json-simple:1.1.1' implementation 'com.google.code.gson:gson:2.8.6' + implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.896') + implementation 'com.amazonaws:aws-java-sdk-s3' testImplementation 'junit:junit:4.11' compile 'com.google.api-client:google-api-client:1.23.0' compile 'com.google.oauth-client:google-oauth-client-jetty:1.23.0' @@ -31,6 +33,7 @@ dependencies { compile group: 'net.sourceforge.argparse4j', name: 'argparse4j', version: '0.8.1' compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.3' compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.3' + compile group: 'javax.xml.bind', name: 'jaxb-api', version: '2.2.4' } jar { diff --git a/src/main/java/de/jeyp91/App.java b/src/main/java/de/jeyp91/App.java index 2a14c34..56a5b6e 100644 --- a/src/main/java/de/jeyp91/App.java +++ b/src/main/java/de/jeyp91/App.java @@ -1,7 +1,8 @@ package de.jeyp91; import de.jeyp91.apifootball.APIFootballUpdater; -import de.jeyp91.gists.MatchesListGistUpdater; +import de.jeyp91.tippligaforum.MatchesListForumUpdater; import de.jeyp91.tippliga.*; +import de.jeyp91.tippligaforum.TippligaSQLConnector; import net.sourceforge.argparse4j.ArgumentParsers; import net.sourceforge.argparse4j.inf.ArgumentParser; import net.sourceforge.argparse4j.inf.ArgumentParserException; @@ -48,18 +49,18 @@ public class App { sql = teamsUpdater.getInsertSQL(); break; case "APIFootballUpdater": - APIFootballUpdater apiFootballUpdater = new APIFootballUpdater(season); + APIFootballUpdater apiFootballUpdater = new APIFootballUpdater(); apiFootballUpdater.updateAllFixtures(); break; case "MatchesListGistUpdater": - MatchesListGistUpdater matchesListGistUpdater = new MatchesListGistUpdater(); - matchesListGistUpdater.updateAllLeagues(); + MatchesListForumUpdater matchesListForumUpdater = new MatchesListForumUpdater(); + matchesListForumUpdater.updateAllLeagues(); break; default: break; } if(!StatusHolder.getError() && !sql.equals("")) { - TippligaSQLConnector con = new TippligaSQLConnector(); + TippligaSQLConnector con = TippligaSQLConnector.getInstance(); con.executeUpdate(sql); logger.info(beautifulInfo); } diff --git a/src/main/java/de/jeyp91/ResourceProvider.java b/src/main/java/de/jeyp91/ResourceProvider.java new file mode 100644 index 0000000..309eb9b --- /dev/null +++ b/src/main/java/de/jeyp91/ResourceProvider.java @@ -0,0 +1,45 @@ +package de.jeyp91; + +import com.google.common.io.Resources; +import org.json.simple.JSONArray; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.io.IOException; +import java.net.URL; +import java.nio.charset.StandardCharsets; + +public class ResourceProvider { + + private static JSONArray getJSONArrayFromResource(String path) { + URL url = Resources.getResource(path); + String jsonConfig; + JSONArray array = null; + + try { + JSONParser jsonParser = new JSONParser(); + jsonConfig = Resources.toString(url, StandardCharsets.UTF_8); + array = (JSONArray) jsonParser.parse(jsonConfig); + + } catch (IOException | ParseException e) { + e.printStackTrace(); + } + return array; + } + + public static JSONArray getLigenConfig() { + return getJSONArrayFromResource("Tippliga/Ligen.json"); + } + + public static JSONArray getTeamIDMatcherConfig() { + return getJSONArrayFromResource("Tippliga/Team_ID_Matcher_Config.json"); + } + + public static JSONArray getTipperMatchPairConfig() { + return getJSONArrayFromResource("Tippliga/Tipper_Match_Pair_Config.json"); + } + + public static JSONArray getTipperTeamConfig() { + return getJSONArrayFromResource("Tippliga/Tipper_Team_Config.json"); + } +} diff --git a/src/main/java/de/jeyp91/S3Provider.java b/src/main/java/de/jeyp91/S3Provider.java new file mode 100644 index 0000000..3492a84 --- /dev/null +++ b/src/main/java/de/jeyp91/S3Provider.java @@ -0,0 +1,95 @@ +package de.jeyp91; + +import com.amazonaws.AmazonServiceException; +import com.amazonaws.SdkClientException; +import com.amazonaws.regions.Regions; +import com.amazonaws.services.s3.AmazonS3; +import com.amazonaws.services.s3.AmazonS3ClientBuilder; +import com.amazonaws.services.s3.model.S3Object; +import com.amazonaws.services.s3.model.S3ObjectInputStream; +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; + +public class S3Provider { + private static final Regions AWS_DEFAULT_REGION = Regions.EU_CENTRAL_1; + private static final String BUCKET_NAME = "tlw-database-tool-api-football-data"; + + private void writeToS3(String filename, String content) { + final AmazonS3 s3 = AmazonS3ClientBuilder + .standard() + .withRegion(AWS_DEFAULT_REGION) + .build(); + try { + s3.putObject(BUCKET_NAME, filename, content); + } catch (AmazonServiceException e) { + System.err.println(e.getErrorMessage()); + } + } + + public void writeFixturesToS3(int league, String content) { + writeToS3("fixtures/" + league + ".json", content); + } + + public void writeRoundsToS3(int league, String content) { + writeToS3("rounds/" + league + ".json", content); + } + + private String getFileFromS3(String filename) { + final AmazonS3 s3 = AmazonS3ClientBuilder + .standard() + .withRegion(AWS_DEFAULT_REGION) + .build(); + StringBuilder builder = new StringBuilder(); + try { + S3Object o = s3.getObject(BUCKET_NAME, filename); + S3ObjectInputStream s3is = o.getObjectContent(); + BufferedReader reader = new BufferedReader(new InputStreamReader(s3is)); + String line; + while ((line = reader.readLine()) != null) { + builder.append(line); + } + } catch (SdkClientException | IOException e) { + e.printStackTrace(); + } + return builder.toString(); + } + + String getFixturesStringFromS3(int league) { + return getFileFromS3("fixtures/" + league + ".json"); + } + + public JSONObject getFixturesJSONFromS3(int league) { + String fixturesString = getFixturesStringFromS3(league); + JSONParser parser = new JSONParser(); + JSONObject jsonObject = null; + try { + jsonObject = (JSONObject) parser.parse(fixturesString); + } catch (ParseException e) { + /* TODO */ + e.printStackTrace(); + } + return jsonObject; + } + + private String getRoundsStringFromS3(int league) { + return getFileFromS3("rounds/" + league + ".json"); + } + + public JSONObject getRoundsJSONFromS3(int league) { + String fixturesString = getRoundsStringFromS3(league); + JSONParser parser = new JSONParser(); + JSONObject jsonObject = null; + try { + jsonObject = (JSONObject) parser.parse(fixturesString); + } catch (ParseException e) { + /* TODO */ + e.printStackTrace(); + } + return jsonObject; + } +} diff --git a/src/main/java/de/jeyp91/apifootball/APIFootballConnector.java b/src/main/java/de/jeyp91/apifootball/APIFootballConnector.java index 7226e10..69e2346 100644 --- a/src/main/java/de/jeyp91/apifootball/APIFootballConnector.java +++ b/src/main/java/de/jeyp91/apifootball/APIFootballConnector.java @@ -1,29 +1,22 @@ package de.jeyp91.apifootball; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.S3Provider; import org.json.simple.JSONArray; import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import java.util.ArrayList; import java.util.HashMap; -/** - * - */ public class APIFootballConnector { private static APIFootballConnector conn = null; private final int season; - private final String gistId; - private final HashMap rounds = new HashMap<>(); - private final HashMap matches = new HashMap<>(); + private final HashMap rounds = new HashMap<>(); + private final HashMap matches = new HashMap<>(); private APIFootballConnector(int season) { this.season = season; - GistProvider prov = GistProvider.getInstance(); - this.gistId = prov.getGistID("APIFootball_" + (season + 1)); } public static APIFootballConnector getAPIFootballConnectorInstance(int season) { @@ -62,14 +55,14 @@ public class APIFootballConnector { return matchesOfMatchday; } - public ArrayList getMatchesFromLeagueFromFile(int id) { + public ArrayList getMatchesFromLeagueFromFile(int leagueId) { ArrayList matchesList = new ArrayList<>(); + S3Provider prov = new S3Provider(); - String filename = "matches_league_" + id + ".json"; - if(!this.matches.containsKey(filename)) { - this.matches.put(filename, readObjectFromFile(filename)); + if(!this.matches.containsKey(leagueId)) { + this.matches.put(leagueId, prov.getFixturesJSONFromS3(leagueId)); } - JSONObject matches = this.matches.get(filename); + JSONObject matches = this.matches.get(leagueId); JSONArray matchArray = (JSONArray) (((JSONObject)matches.get("api")).get("fixtures")); for(int i = 0; i < matchArray.size(); i++) { @@ -79,52 +72,17 @@ public class APIFootballConnector { return matchesList; } - public JSONObject getMatchdays(int id) { - - String filename = "rounds_" + id + ".json"; - if(!this.rounds.containsKey(filename)) { - this.rounds.put(filename, readObjectFromFile(filename)); + public JSONObject getMatchdays(int leagueId) { + S3Provider prov = new S3Provider(); + if(!this.rounds.containsKey(leagueId)) { + this.rounds.put(leagueId, prov.getRoundsJSONFromS3(leagueId)); } - return this.rounds.get(filename); - } - - public JSONObject readObjectFromFile(String filename) { - - JSONObject object = null; - JSONParser jsonParser = new JSONParser(); - - GistProvider prov = GistProvider.getInstance(); - String jsonConfig = prov.getFileFromGist(filename); - - try { - object = (JSONObject) jsonParser.parse(jsonConfig); - } catch (ParseException e) { - e.printStackTrace(); - } - - return object; - } - - public JSONArray readArrayFromFile(String filename) { - - JSONArray object = null; - JSONParser jsonParser = new JSONParser(); - - GistProvider prov = GistProvider.getInstance(); - String jsonConfig = prov.getFileFromGist(filename); - - try { - object = (JSONArray) jsonParser.parse(jsonConfig); - } catch (ParseException e) { - e.printStackTrace(); - } - - return object; + return this.rounds.get(leagueId); } public JSONObject getTeamsForLeague(int league) { String url = "https://v2.api-football.com/teams/league/" + league; - String content = new APIFootballUpdater(0).getRawData(url); + String content = new APIFootballUpdater().getRawData(url); return stringToJSONObject(content); } diff --git a/src/main/java/de/jeyp91/apifootball/APIFootballMatch.java b/src/main/java/de/jeyp91/apifootball/APIFootballMatch.java index c3c313b..3449fad 100644 --- a/src/main/java/de/jeyp91/apifootball/APIFootballMatch.java +++ b/src/main/java/de/jeyp91/apifootball/APIFootballMatch.java @@ -1,29 +1,18 @@ package de.jeyp91.apifootball; -import com.google.common.io.Resources; import de.jeyp91.BaseMatch; -import de.jeyp91.gists.GistProvider; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import java.io.IOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; public class APIFootballMatch extends BaseMatch { - private final int season; private final int matchId; private final int leagueId; - private String matchStatus; private final String teamNameHome; private final String teamNameGuest; private Boolean showTable = null; public APIFootballMatch(JSONObject json, int season) { - this.season = season; this.matchId = Integer.parseInt(json.get("fixture_id").toString()); // TODO this.leagueId = Integer.parseInt(json.get("league_id").toString()); @@ -33,8 +22,7 @@ public class APIFootballMatch extends BaseMatch { this.teamNameGuest = ((JSONObject) json.get("awayTeam")).get("team_name").toString(); this.goalsHome = getNumberOrNull(json.get("goalsHomeTeam")); this.goalsGuest = getNumberOrNull(json.get("goalsAwayTeam")); - this.matchday = getMatchdayFromRoundString(json.get("round").toString(), this.leagueId); - this.matchStatus = json.get("statusShort").toString(); + this.matchday = getMatchdayFromRoundString(season, json.get("round").toString(), this.leagueId); this.matchDatetime = (String) json.get("event_date"); } @@ -42,10 +30,10 @@ public class APIFootballMatch extends BaseMatch { return this.matchId; } - private int getMatchdayFromRoundString(String round, int leagueId) { + public static int getMatchdayFromRoundString(int season, String round, int leagueId) { round = round.replace(" ", "_"); Integer matchday = null; - APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(this.season); + APIFootballConnector con = APIFootballConnector.getAPIFootballConnectorInstance(season); JSONObject roundsObject = con.getMatchdays(leagueId); JSONArray roundsArray = (JSONArray)(((JSONObject) roundsObject.get("api")).get("fixtures")); for (int i = 0; i < roundsArray.size(); i++) { diff --git a/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java b/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java index a1a4a1d..74405ef 100644 --- a/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java +++ b/src/main/java/de/jeyp91/apifootball/APIFootballUpdater.java @@ -1,10 +1,12 @@ package de.jeyp91.apifootball; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.ResourceProvider; +import de.jeyp91.S3Provider; import org.apache.http.HttpResponse; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.HttpClientBuilder; +import org.json.simple.JSONArray; import org.json.simple.JSONObject; import java.io.*; @@ -12,51 +14,42 @@ import java.util.HashSet; public class APIFootballUpdater { - private final int season; - private final GistProvider provider; - private final String exceededLimitError = "{\"api\":{\"results\":0,\"error\":\"You have reached the request limit for the day\"}}"; - public APIFootballUpdater(int season) { - this.season = season; - this.provider = GistProvider.getInstance(); + public APIFootballUpdater() { + } - public void updateFixtures(int league) throws IOException { + public void updateFixtures(int league) { String apiFootballUrl = "https://v2.api-football.com/fixtures/league/" + league + "?timezone=Europe/Berlin"; - String filename = "matches_league_" + league + ".json"; String content = getRawData(apiFootballUrl); if(!content.equals(this.exceededLimitError)) { - writeStringToGist(filename, content); + S3Provider prov = new S3Provider(); + prov.writeFixturesToS3(league, content); } } - public void updateAllFixtures() throws IOException { - HashSet leagues = provider.getLeagues(); + public void updateAllFixtures() { + HashSet leagues = getLeagues(); for (Integer league : leagues) { updateFixtures(league); } } - public void updateRounds(int league) throws IOException { - String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league; - String filename = "rounds_" + league + ".json"; - String content = getRawData(apiFootballUrl); - if(!content.equals(this.exceededLimitError)) { - writeStringToGist(filename, content); - } - } - - public void updateAllRounds() throws IOException { - HashSet leagues = provider.getLeagues(); + public void updateAllRounds() { + HashSet leagues = getLeagues(); for (Integer league : leagues) { updateRounds(league); } } - private void writeStringToGist(String filename, String content) throws UnsupportedEncodingException { - String id = this.provider.getGistID("APIFootball_" + this.season); - this.provider.updateGist(id, filename, content); + public void updateRounds(int league) { + String apiFootballUrl = "https://v2.api-football.com/fixtures/rounds/" + league; + String content = getRawData(apiFootballUrl); + if(!content.equals(this.exceededLimitError)) { + S3Provider prov = new S3Provider(); + prov.writeRoundsToS3(league, content); + } } public String getRawData(String requestUrl) { @@ -103,4 +96,15 @@ public class APIFootballUpdater { } return result.toString(); } + + public HashSet getLeagues() { + JSONArray leaguesArray = ResourceProvider.getLigenConfig(); + HashSet leagues = new HashSet<>(); + for (Object leagueObject : leaguesArray) { + JSONObject leagueJSONObject = (JSONObject) leagueObject; + Integer leagueId = ((Long) leagueJSONObject.get("league_id")).intValue(); + leagues.add(leagueId); + } + return leagues; + } } diff --git a/src/main/java/de/jeyp91/gists/GistProvider.java b/src/main/java/de/jeyp91/gists/GistProvider.java deleted file mode 100644 index d3bf32a..0000000 --- a/src/main/java/de/jeyp91/gists/GistProvider.java +++ /dev/null @@ -1,278 +0,0 @@ -package de.jeyp91.gists; - -import com.google.api.client.util.DateTime; -import com.google.common.io.Resources; -import org.apache.commons.codec.binary.Base64; -import org.apache.http.HttpHeaders; -import org.apache.http.HttpResponse; -import org.apache.http.client.HttpClient; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPatch; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.HttpClientBuilder; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.util.HashSet; -import java.util.Set; - -public class GistProvider { - - private static GistProvider prov = null; - private final JSONArray gistList; - private String username; - private String password; - - private GistProvider() { - readConfig(); - this.gistList = listAllGists(); - } - - private void readConfig() { - JSONParser jsonParser = new JSONParser(); - URL url = Resources.getResource("Gist_Config.json"); - JSONObject gistConfig = null; - - try { - String jsonConfig = Resources.toString(url, StandardCharsets.UTF_8); - //Read JSON file - gistConfig = (JSONObject) jsonParser.parse(jsonConfig); - - } catch (IOException | ParseException e) { - e.printStackTrace(); - } - this.username = gistConfig.get("username").toString(); - this.password = gistConfig.get("password").toString(); - } - - public static GistProvider getInstance() { - if (prov == null) { - prov = new GistProvider(); - } - return prov; - } - - public JSONArray listAllGists() { - String gistsRaw = getRawData("https://api.github.com/gists"); - return stringToJSONArray(gistsRaw); - } - - public DateTime getGistUpdatedTimestamp(String gistDescription) { - DateTime updated = null; - for (Object o : this.gistList) { - JSONObject gist = (JSONObject) o; - String desc = gist.get("description").toString(); - if (gistDescription.equals(desc)) { - updated = new DateTime(gist.get("updated_at").toString()); - } - } - return updated; - } - - public String getGistID(String gistDescription) { - String id = null; - for (Object o : this.gistList) { - JSONObject gist = (JSONObject) o; - String desc = gist.get("description").toString(); - if (gistDescription.equals(desc)) { - id = gist.get("id").toString(); - } - } - return id; - } - - public String updateGist(String id, String file, String content) throws UnsupportedEncodingException { - String requestUrl = "https://api.github.com/gists/" + id; - String auth = this.username + ":" + this.password; - byte[] encodedAuth = Base64.encodeBase64( - auth.getBytes(StandardCharsets.ISO_8859_1)); - String authHeader = "Basic " + new String(encodedAuth); - - HttpClient client = HttpClientBuilder - .create() - .build(); - HttpPatch request = new HttpPatch(requestUrl); - request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); - request.setHeader(HttpHeaders.ACCEPT, "application/vnd.github.v3+json"); - - JSONObject contentObject = new JSONObject(); - contentObject.put("content", content); - JSONObject fileObject = new JSONObject(); - fileObject.put(file, contentObject); - JSONObject filesObject = new JSONObject(); - filesObject.put("files", fileObject); - - String bodyString = filesObject.toString(); - - StringEntity body = new StringEntity(filesObject.toString()); - body.setContentType("application/json"); - body.setContentEncoding("UTF-8"); - request.setEntity(body); - - HttpResponse response = null; - try { - response = client.execute(request); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - BufferedReader rd = null; - try { - rd = new BufferedReader( - new InputStreamReader(response.getEntity().getContent(), StandardCharsets.UTF_8) - ); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - StringBuilder result = new StringBuilder(); - String line = ""; - while (true) { - try { - line = rd.readLine(); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - // Stop reading if last line was found. - if (line == null) break; - - result.append(line); - } - return result.toString(); - } - - public JSONArray getTeamIdMatcher() { - return stringToJSONArray(getFileFromGist("Team_ID_Matcher.json")); - } - - public HashSet getLeagues() { - JSONObject leaguesObject = stringToJSONObject(getFileFromGist("Ligen.json")); - JSONArray leaguesArray = (JSONArray) leaguesObject.get("Ligen"); - HashSet leagues = new HashSet<>(); - for (Object leagueObject : leaguesArray) { - JSONObject leagueJSONObject = (JSONObject) leagueObject; - Integer leagueId = ((Long) leagueJSONObject.get("league_id")).intValue(); - leagues.add(leagueId); - } - return leagues; - } - - public String getFileFromGist(String filename) { - String fileurl = null; - for (Object o : this.gistList) { - JSONObject gist = (JSONObject) o; - JSONObject files = (JSONObject)gist.get("files"); - Set filenames = files.keySet(); - if(filenames.contains(filename)) { - fileurl = ((JSONObject)files.get(filename)).get("raw_url").toString(); - } - } - - String content = null; - if(fileurl != null) { - content = getRawData(fileurl); - } - return content; - } - - private String getRawData(String requestUrl) { - - String auth = this.username + ":" + this.password; - byte[] encodedAuth = Base64.encodeBase64( - auth.getBytes(StandardCharsets.ISO_8859_1)); - String authHeader = "Basic " + new String(encodedAuth); - - HttpClient client = HttpClientBuilder - .create() - .build(); - HttpGet request = new HttpGet(requestUrl); - request.setHeader(HttpHeaders.AUTHORIZATION, authHeader); - - HttpResponse response = null; - try { - response = client.execute(request); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - BufferedReader rd = null; - try { - rd = new BufferedReader( - new InputStreamReader(response.getEntity().getContent(), "UTF-8") - ); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - StringBuilder result = new StringBuilder(); - String line = ""; - while (true) { - try { - line = rd.readLine(); - } catch (IOException e) { - /* TODO */ - e.printStackTrace(); - } - - // Stop reading if last line was found. - if (line == null) break; - - result.append(line); - } - return result.toString(); - } - - private JSONArray stringToJSONArray(String rawData) { - - JSONParser parser = new JSONParser(); - JSONArray data = null; - try { - data = (JSONArray) parser.parse(rawData); - } catch (Exception e) { - /* TODO */ - e.printStackTrace(); - } - return data; - } - - private JSONObject stringToJSONObject(String rawData) { - - JSONParser parser = new JSONParser(); - JSONObject data = null; - try { - data = (JSONObject) parser.parse(rawData); - } catch (Exception e) { - /* TODO */ - e.printStackTrace(); - } - return data; - } - - public String getTippligaConfig(String filename) { - return getFileFromGist(filename); - } - - public String getTippligaBaseConfig(String filename) { - return getFileFromGist(filename); - } - - public JSONObject getAPIFootballLeagueConfig(int league) { - String filename = "matches_league_" + league + ".json"; - String file = getFileFromGist(filename); - return stringToJSONObject(file); - } -} diff --git a/src/main/java/de/jeyp91/gists/MatchesListGistUpdater.java b/src/main/java/de/jeyp91/gists/MatchesListGistUpdater.java deleted file mode 100644 index dab33ca..0000000 --- a/src/main/java/de/jeyp91/gists/MatchesListGistUpdater.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.jeyp91.gists; - -import java.io.UnsupportedEncodingException; -import java.util.HashSet; - -public class MatchesListGistUpdater { - private HashSet leagues; - private final String gistId; - private final GistProvider prov; - - public MatchesListGistUpdater() { - this.prov = GistProvider.getInstance(); - this.gistId = prov.getGistID("Spiele"); - this.leagues = prov.getLeagues(); - } - - public void updateAllLeagues() throws UnsupportedEncodingException { - for(Integer league : this.leagues) { - updateLeague(league); - } - } - - private void updateLeague(int league) throws UnsupportedEncodingException { - MatchesListCreator creator = new MatchesListCreator(league); - String filename = creator.getFilename(); - String content = creator.getMatchesBeautful(); - GistProvider prov = GistProvider.getInstance(); - prov.updateGist(this.gistId, filename, content); - } -} diff --git a/src/main/java/de/jeyp91/TeamIDMatcher.java b/src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcher.java similarity index 92% rename from src/main/java/de/jeyp91/TeamIDMatcher.java rename to src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcher.java index e4aec4c..fd0c47e 100644 --- a/src/main/java/de/jeyp91/TeamIDMatcher.java +++ b/src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcher.java @@ -1,8 +1,9 @@ -package de.jeyp91; +package de.jeyp91.teamidmatcher; import com.google.common.collect.HashBiMap; +import de.jeyp91.ResourceProvider; +import de.jeyp91.StatusHolder; import de.jeyp91.apifootball.APIFootballMatch; -import de.jeyp91.gists.GistProvider; import org.apache.logging.log4j.*; import org.json.simple.JSONArray; import org.json.simple.JSONObject; @@ -19,14 +20,15 @@ public class TeamIDMatcher { private static void initBiMap() { if(!init) { ids = HashBiMap.create(); - GistProvider prov = GistProvider.getInstance(); - teams = prov.getTeamIdMatcher(); + + teams = ResourceProvider.getTeamIDMatcherConfig(); for (Object team : teams) { int tippligaID = ((Long) ((JSONObject) team).get("tippligaID")).intValue(); int apiFootballID = ((Long) ((JSONObject) team).get("apiFootballID")).intValue(); ids.put(tippligaID, apiFootballID); } + init = true; } } @@ -60,7 +62,7 @@ public class TeamIDMatcher { public static String getTeamNameFromTippligaId(Integer id) { initBiMap(); String name = ""; - for(Object team:teams) { + for(Object team : teams) { int tippligaID = ((Long)((JSONObject) team).get("tippligaID")).intValue(); if(id == tippligaID) { name = (((JSONObject) team).get("teamname")).toString(); diff --git a/src/main/java/de/jeyp91/gists/TeamIDMatcherTemplateCreator.java b/src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreator.java similarity index 97% rename from src/main/java/de/jeyp91/gists/TeamIDMatcherTemplateCreator.java rename to src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreator.java index 23e5d72..4cba5d0 100644 --- a/src/main/java/de/jeyp91/gists/TeamIDMatcherTemplateCreator.java +++ b/src/main/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreator.java @@ -1,4 +1,4 @@ -package de.jeyp91.gists; +package de.jeyp91.teamidmatcher; import de.jeyp91.apifootball.APIFootballConnector; import org.json.simple.JSONArray; diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatch.java b/src/main/java/de/jeyp91/tippliga/TLWMatch.java index 33fe9af..042c5d5 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatch.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatch.java @@ -4,10 +4,8 @@ import java.sql.ResultSet; import java.sql.SQLException; import de.jeyp91.BaseMatch; -import de.jeyp91.StatusHolder; -import de.jeyp91.TeamIDMatcher; +import de.jeyp91.teamidmatcher.TeamIDMatcher; import de.jeyp91.apifootball.APIFootballMatch; -import de.jeyp91.openligadb.OpenLigaDBMatch; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java index 129b02e..b9894b6 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysCreator.java @@ -1,13 +1,9 @@ package de.jeyp91.tippliga; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.tippligaforum.TippligaConfigProvider; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import java.text.DateFormat; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; @@ -27,15 +23,9 @@ public class TLWMatchdaysCreator { TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath); this.matches = matchesCreator.getMatches(); - GistProvider prov = GistProvider.getInstance(); - String jsonConfig = prov.getTippligaConfig(configPath); + TippligaConfigProvider prov = new TippligaConfigProvider(season); + this.configObject = prov.getTippligaConfig(configPath); - JSONParser jsonParser = new JSONParser(); - try { - this.configObject = (JSONObject) jsonParser.parse(jsonConfig); - } catch (ParseException e) { - e.printStackTrace(); - } //Read JSON file this.matchesPerMatchday = ((Long) this.configObject.get("matchesPerMatchday")).intValue(); } diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysUpdater.java b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysUpdater.java index f38107c..01db287 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchdaysUpdater.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchdaysUpdater.java @@ -1,6 +1,7 @@ package de.jeyp91.tippliga; -import java.text.ParseException; +import de.jeyp91.tippligaforum.TippligaSQLConnector; + import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Comparator; @@ -14,11 +15,11 @@ public class TLWMatchdaysUpdater { ArrayList matchdaysUpdated; String beautifulInfo = ""; - public TLWMatchdaysUpdater(int season, int league, String configPath) throws ParseException { + public TLWMatchdaysUpdater(int season, int league, String configPath) { this.season = season; this.league = league; - TippligaSQLConnector conn = new TippligaSQLConnector(); + TippligaSQLConnector conn = TippligaSQLConnector.getInstance(); this.matchdaysOriginal = conn.getMatchdays(String.valueOf(season), String.valueOf(league)); this.matchdaysOriginal.sort(Comparator.comparing(TLWMatchday::getMatchday)); diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java index e79c239..ab36bad 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorFootball.java @@ -1,21 +1,13 @@ package de.jeyp91.tippliga; -import com.google.common.io.Resources; import de.jeyp91.apifootball.APIFootballConnector; import de.jeyp91.apifootball.APIFootballMatch; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.tippligaforum.TippligaConfigProvider; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import java.io.IOException; -import java.net.URL; -import java.nio.charset.StandardCharsets; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.util.ArrayList; -import java.util.Date; public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase { @@ -35,20 +27,12 @@ public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase { this.league = league; this.conn = APIFootballConnector.getAPIFootballConnectorInstance(season - 1); - GistProvider prov = GistProvider.getInstance(); - String jsonConfig = prov.getTippligaConfig(configFileName); + TippligaConfigProvider prov = new TippligaConfigProvider(season); + JSONObject config = prov.getTippligaConfig(configFileName); - try { - JSONParser jsonParser = new JSONParser(); - //Read JSON file - JSONObject config = (JSONObject) jsonParser.parse(jsonConfig); - this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue(); - this.matchdayConfig = (JSONArray) config.get("matchdayConfig"); - this.ko = ((Long) config.get("ko")).intValue(); - - } catch (ParseException e) { - e.printStackTrace(); - } + this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue(); + this.matchdayConfig = (JSONArray) config.get("matchdayConfig"); + this.ko = ((Long) config.get("ko")).intValue(); this.publicateMatchObjects(); } diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperLeague.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperLeague.java index dc52ca9..95a6fb2 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperLeague.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperLeague.java @@ -1,13 +1,12 @@ package de.jeyp91.tippliga; +import de.jeyp91.ResourceProvider; import de.jeyp91.StatusHolder; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.tippligaforum.TippligaConfigProvider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import java.util.ArrayList; @@ -28,22 +27,12 @@ public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase { this.league = league; this.matchdays = matchdays; - try { - JSONParser jsonParser = new JSONParser(); - GistProvider prov = GistProvider.getInstance(); - String matchPairingConfigString = prov.getTippligaBaseConfig("Tipper_Match_Pair_Config.json"); - this.matchPairingConfig = (JSONArray) jsonParser.parse(matchPairingConfigString); + this.matchPairingConfig = ResourceProvider.getTipperMatchPairConfig(); + this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig(); - String tipperListString = prov.getTippligaConfig(configFileName); - this.tipperList = (JSONObject) jsonParser.parse(tipperListString); - - String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json"); - this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString); - - } catch (ParseException e) { - e.printStackTrace(); - } + TippligaConfigProvider prov = new TippligaConfigProvider(season); + this.tipperList = prov.getTippligaConfig(configFileName); this.publicateMatchObjects(); } diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokal.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokal.java index 769b891..2c5fdc3 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokal.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokal.java @@ -1,12 +1,11 @@ package de.jeyp91.tippliga; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.ResourceProvider; +import de.jeyp91.tippligaforum.TippligaConfigProvider; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; import java.util.ArrayList; @@ -27,24 +26,13 @@ public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{ this.league = league; this.matchdays = matchdays; + TippligaConfigProvider prov = new TippligaConfigProvider(season); + this.tipperList = prov.getTippligaConfig(configFileName); - GistProvider prov = GistProvider.getInstance(); + this.tipperTeamConfig = ResourceProvider.getTipperTeamConfig(); this.TLWMatches = new ArrayList<>(); - try { - JSONParser jsonParser = new JSONParser(); - - String tipperListString = prov.getTippligaConfig(configFileName); - this.tipperList = (JSONObject) jsonParser.parse(tipperListString); - - String tipperTeamConfigString = prov.getTippligaBaseConfig("Tipper_Team_Config.json"); - this.tipperTeamConfig = (JSONArray) jsonParser.parse(tipperTeamConfigString); - - } catch (ParseException e) { - e.printStackTrace(); - } - this.publicateMatchObjects(); } diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java index 15ea14a..27977d2 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesManagerBase.java @@ -1,19 +1,14 @@ package de.jeyp91.tippliga; -import com.google.api.client.util.DateTime; import de.jeyp91.apifootball.APIFootballMatch; -import de.jeyp91.gists.GistProvider; +import de.jeyp91.tippligaforum.TippligaConfigProvider; import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import java.text.SimpleDateFormat; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; -import java.util.Date; public class TLWMatchesManagerBase { @@ -27,19 +22,11 @@ public class TLWMatchesManagerBase { protected void initConfigParamsFromFile(String configFileName) { - GistProvider prov = GistProvider.getInstance(); - String jsonConfig = prov.getTippligaConfig(configFileName); - try { - JSONParser jsonParser = new JSONParser(); - //Read JSON file - JSONObject config = (JSONObject) jsonParser.parse(jsonConfig); - this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue(); - this.matchdayConfig = (JSONArray) config.get("matchdayConfig"); - this.ko = ((Long) config.get("ko")).intValue(); - - } catch (ParseException e) { - e.printStackTrace(); - } + TippligaConfigProvider prov = new TippligaConfigProvider(this.season); + JSONObject config = prov.getTippligaConfig(configFileName); + this.numberOfMatchdays = ((Long) config.get("numberOfMatchdays")).intValue(); + this.matchdayConfig = (JSONArray) config.get("matchdayConfig"); + this.ko = ((Long) config.get("ko")).intValue(); } public static ArrayList getMatchesStartingFromSecondDay(ArrayList matches) { diff --git a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java index 6fc06e9..aa5740f 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java +++ b/src/main/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootball.java @@ -2,9 +2,10 @@ package de.jeyp91.tippliga; import de.jeyp91.App; import de.jeyp91.StatusHolder; -import de.jeyp91.TeamIDMatcher; +import de.jeyp91.teamidmatcher.TeamIDMatcher; import de.jeyp91.apifootball.APIFootballMatch; import de.jeyp91.apifootball.APIFootballMatchesProvider; +import de.jeyp91.tippligaforum.TippligaSQLConnector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.json.simple.JSONArray; @@ -35,7 +36,7 @@ public class TLWMatchesUpdaterFootball extends TLWMatchesManagerBase { private void initUpdates() { APIFootballMatchesProvider apiFootballMatchesProvider = new APIFootballMatchesProvider(this.season); - TippligaSQLConnector tippligaSQLConnector = new TippligaSQLConnector(); + TippligaSQLConnector tippligaSQLConnector = TippligaSQLConnector.getInstance(); for (Object singleMatchdayConfig : this.matchdayConfig) { int tlwMatchday = ((Long) ((JSONObject) singleMatchdayConfig).get("TLWMatchday")).intValue(); JSONArray matchesConfig = (JSONArray) ((JSONObject) singleMatchdayConfig).get("matchesConfig"); diff --git a/src/main/java/de/jeyp91/tippliga/TLWTeamsCreator.java b/src/main/java/de/jeyp91/tippliga/TLWTeamsCreator.java index d59fe2c..77a3cf8 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWTeamsCreator.java +++ b/src/main/java/de/jeyp91/tippliga/TLWTeamsCreator.java @@ -1,5 +1,7 @@ package de.jeyp91.tippliga; +import de.jeyp91.tippligaforum.TippligaSQLConnector; + import java.util.ArrayList; import java.util.LinkedHashSet; import java.util.Set; @@ -8,7 +10,7 @@ public class TLWTeamsCreator { int season; int league; ArrayList matches; - TippligaSQLConnector connector = new TippligaSQLConnector(); + TippligaSQLConnector connector = TippligaSQLConnector.getInstance(); public TLWTeamsCreator(int season, int league, ArrayList matches) { this.season = season; diff --git a/src/main/java/de/jeyp91/tippliga/TLWTeamsUpdater.java b/src/main/java/de/jeyp91/tippliga/TLWTeamsUpdater.java index c8a5c75..36791e2 100644 --- a/src/main/java/de/jeyp91/tippliga/TLWTeamsUpdater.java +++ b/src/main/java/de/jeyp91/tippliga/TLWTeamsUpdater.java @@ -1,5 +1,7 @@ package de.jeyp91.tippliga; +import de.jeyp91.tippligaforum.TippligaSQLConnector; + import java.util.ArrayList; import java.util.HashSet; @@ -13,7 +15,7 @@ public class TLWTeamsUpdater { public TLWTeamsUpdater(int season, int league, String configFileName) throws Exception { - TippligaSQLConnector conn = new TippligaSQLConnector(); + TippligaSQLConnector conn = TippligaSQLConnector.getInstance(); this.season = season; this.league = league; @@ -47,7 +49,7 @@ public class TLWTeamsUpdater { } private void initMissingTeams(HashSet missingIds) { - TippligaSQLConnector conn = new TippligaSQLConnector(); + TippligaSQLConnector conn = TippligaSQLConnector.getInstance(); for (Integer id : missingIds) { ArrayList teams = conn.getTeams(String.valueOf(id)); missingTeams.add(new TLWTeam( diff --git a/src/main/java/de/jeyp91/gists/MatchesListCreator.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java similarity index 69% rename from src/main/java/de/jeyp91/gists/MatchesListCreator.java rename to src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java index de1c255..f1ecb86 100644 --- a/src/main/java/de/jeyp91/gists/MatchesListCreator.java +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListCreator.java @@ -1,27 +1,26 @@ -package de.jeyp91.gists; +package de.jeyp91.tippligaforum; import com.google.gson.*; +import de.jeyp91.S3Provider; +import de.jeyp91.apifootball.APIFootballMatch; import org.json.simple.JSONArray; import org.json.simple.JSONObject; public class MatchesListCreator { - private final JSONObject matches = new JSONObject(); + private JSONArray matches; private final String country; private final String leagueName; public MatchesListCreator(int league) { - GistProvider provider = GistProvider.getInstance(); - JSONObject leagueConfig = provider.getAPIFootballLeagueConfig(league); + S3Provider prov = new S3Provider(); + JSONObject leagueConfig = prov.getFixturesJSONFromS3(league); JSONObject api = (JSONObject) leagueConfig.get("api"); JSONArray matchesAPIFootball = (JSONArray) api.get("fixtures"); JSONObject firstMatchAPIFootball = (JSONObject) matchesAPIFootball.get(0); JSONObject leagueObject = (JSONObject) firstMatchAPIFootball.get("league"); this.country = leagueObject.get("country").toString(); this.leagueName = leagueObject.get("name").toString(); - matches.put("country", this.country); - matches.put("leagueName", this.leagueName); - matches.put("leagueId", league); populateMatches(matchesAPIFootball); } @@ -31,37 +30,44 @@ public class MatchesListCreator { JSONObject matchAPIFootball = (JSONObject) matchAPIFootballObject; JSONObject match = new JSONObject(); - String matchday = matchAPIFootball.get("round").toString(); - match.put("matchday", matchday); + Long leagueId = (Long) matchAPIFootball.get("league_id"); + String matchdayString = matchAPIFootball.get("round").toString(); + int matchday = APIFootballMatch.getMatchdayFromRoundString(2021, matchdayString, leagueId.intValue()); + String matchtime = matchAPIFootball.get("event_date").toString().replace("T", " ").substring(0, 16); + Long fixtureId = (Long) matchAPIFootball.get("fixture_id"); JSONObject teamHome = (JSONObject) matchAPIFootball.get("homeTeam"); String teamNameHome = teamHome.get("team_name").toString(); JSONObject teamGuest = (JSONObject) matchAPIFootball.get("awayTeam"); String teamNameGuest = teamGuest.get("team_name").toString(); + match.put("match", teamNameHome + " - " + teamNameGuest); - - String matchtime = matchAPIFootball.get("event_date").toString().replace("T", " ").substring(0, 16); + match.put("matchday", matchday); match.put("matchtime", matchtime); - - Long fixtureId = (Long) matchAPIFootball.get("fixture_id"); + match.put("type", "SingleMatch"); + match.put("matchLeague", leagueId); match.put("matchId", fixtureId); - + match.put("showTable", false); matches.add(match); } - this.matches.put("matches", matches); + this.matches = matches; } - public JSONObject getMatches() { + public JSONArray getMatches() { return this.matches; } - public String getMatchesBeautful() { + public String getMatchesBeautiful() { JsonElement jelement = JsonParser.parseString(this.matches.toString()); Gson gson = new GsonBuilder().setPrettyPrinting().create(); return gson.toJson(jelement); } - public String getFilename() { - return "Spiele " + this.country + " " + this.leagueName + ".json"; + public String getCountry() { + return country; + } + + public String getLeagueName() { + return leagueName; } } diff --git a/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java new file mode 100644 index 0000000..bc58356 --- /dev/null +++ b/src/main/java/de/jeyp91/tippligaforum/MatchesListForumUpdater.java @@ -0,0 +1,43 @@ +package de.jeyp91.tippligaforum; + +import de.jeyp91.apifootball.APIFootballUpdater; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.HashSet; + +public class MatchesListForumUpdater { + private HashSet leagues; + + public MatchesListForumUpdater() { + this.leagues = new APIFootballUpdater().getLeagues(); + } + + public void updateAllLeagues() { + for(Integer league : this.leagues) { + updateLeague(league); + } + } + + public void updateLeague(int league) { + MatchesListCreator creator = new MatchesListCreator(league); + String content = creator.getMatchesBeautiful(); + String contentWithCodeBBCode = "[code]" + content + "[/code]"; + int postId = getPostId(creator.getCountry(), creator.getLeagueName()); + TippligaSQLConnector con = TippligaSQLConnector.getInstance(); + con.updatePost(postId, contentWithCodeBBCode); + } + + private Integer getPostId(String country, String league) { + String query = "SELECT post_id FROM phpbb_posts WHERE post_subject = '" + country + " " + league + "';"; + TippligaSQLConnector con = TippligaSQLConnector.getInstance(); + ResultSet rset = con.executeQuery(query); + Integer postId = null; + try { + rset.next(); + postId = Integer.parseInt(rset.getString(1)); + } catch (SQLException e) { + e.printStackTrace(); + } + return postId; + } +} diff --git a/src/main/java/de/jeyp91/tippligaforum/TippligaConfigProvider.java b/src/main/java/de/jeyp91/tippligaforum/TippligaConfigProvider.java new file mode 100644 index 0000000..f0793fa --- /dev/null +++ b/src/main/java/de/jeyp91/tippligaforum/TippligaConfigProvider.java @@ -0,0 +1,32 @@ +package de.jeyp91.tippligaforum; + +import org.json.simple.JSONObject; +import org.json.simple.parser.JSONParser; +import org.json.simple.parser.ParseException; + +public class TippligaConfigProvider { + TippligaSQLConnector con; + Integer seasonForumId; + + public TippligaConfigProvider(int season) { + this.con = TippligaSQLConnector.getInstance(); + Integer adminForumId = con.getForumId("Admin"); + Integer tippligaConfigForumId = con.getForumId("Tippliga-Config", adminForumId); + this.seasonForumId = con.getForumId(String.valueOf(season), tippligaConfigForumId); + } + + public JSONObject getTippligaConfig(String config) { + String post = this.con.getPost(config, this.seasonForumId); + int postLength = post.length(); + post = post.substring(22, postLength - 25); + + JSONObject tippligaConfig = null; + JSONParser jsonParser = new JSONParser(); + try { + tippligaConfig = (JSONObject) jsonParser.parse(post); + } catch (ParseException e) { + e.printStackTrace(); + } + return tippligaConfig; + } +} diff --git a/src/main/java/de/jeyp91/tippliga/TippligaSQLConnector.java b/src/main/java/de/jeyp91/tippligaforum/TippligaSQLConnector.java similarity index 56% rename from src/main/java/de/jeyp91/tippliga/TippligaSQLConnector.java rename to src/main/java/de/jeyp91/tippligaforum/TippligaSQLConnector.java index 2f18d8d..e2a04ae 100644 --- a/src/main/java/de/jeyp91/tippliga/TippligaSQLConnector.java +++ b/src/main/java/de/jeyp91/tippligaforum/TippligaSQLConnector.java @@ -1,12 +1,16 @@ -package de.jeyp91.tippliga; +package de.jeyp91.tippligaforum; import de.jeyp91.StatusHolder; import de.jeyp91.tippliga.TLWMatch; +import de.jeyp91.tippliga.TLWMatchday; import de.jeyp91.tippliga.TLWTeam; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import javax.xml.transform.Result; +import javax.xml.bind.DatatypeConverter; +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; +import java.time.Instant; import java.util.ArrayList; import java.sql.Connection; import java.sql.DriverManager; @@ -19,6 +23,7 @@ public class TippligaSQLConnector { Connection con; private static final Logger logger = LogManager.getLogger(TippligaSQLConnector.class); + private static TippligaSQLConnector tlwSqlCon = null; static { try { @@ -29,7 +34,7 @@ public class TippligaSQLConnector { } } - public TippligaSQLConnector() { + private TippligaSQLConnector() { String jdbcUrlLocalhost = "jdbc:mysql://localhost/d0144ddb" + "?user=root" + "&password=" + @@ -54,6 +59,13 @@ public class TippligaSQLConnector { } } + public static TippligaSQLConnector getInstance() { + if(tlwSqlCon == null) { + tlwSqlCon = new TippligaSQLConnector(); + } + return tlwSqlCon; + } + public ArrayList getTeams(String season, String league) { String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `season` = " + season + " AND `league` = " + league + ";"; @@ -125,13 +137,46 @@ public class TippligaSQLConnector { return matchdays; } - public void updateMatchDateTime(String season, String league, String matchNo, String datetime) { - String queryString = "UPDATE `phpbb_footb_matches` " - + "SET match_datetime = " + datetime - + " WHERE `season` = " + season - + " AND `league` = " + league - + " AND match_no = " + matchNo + ";"; - executeQuery(queryString); + public Integer getForumId(String forumName, int parentId) { + String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\" AND parent_id = " + parentId + ";"; + ResultSet rset = executeQuery(queryString); + Integer id = null; + try { + while (rset.next()) { + id = Integer.parseInt(rset.getString(1)); + } + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + return id; + } + + public Integer getForumId(String forumName) { + String queryString = "SELECT forum_id FROM phpbb_forums WHERE forum_name = \"" + forumName + "\";"; + ResultSet rset = executeQuery(queryString); + Integer id = null; + try { + while (rset.next()) { + id = Integer.parseInt(rset.getString(1)); + } + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + return id; + } + + public String getPost(String subject, int forum_id) { + String queryString = "SELECT post_text FROM phpbb_posts WHERE post_subject = \"" + subject + "\" AND forum_id = \"" + forum_id + "\";"; + ResultSet rset = executeQuery(queryString); + String post = null; + try { + while (rset.next()) { + post = rset.getString(1); + } + } catch (SQLException throwables) { + throwables.printStackTrace(); + } + return post; } public ResultSet executeQuery (String queryString){ @@ -155,4 +200,47 @@ public class TippligaSQLConnector { logger.error(e.getMessage()); } } + + public void updatePost(int postId, String postText) { + String postChecksum = getChecksum(postText); + final long postEditTime = Instant.now().getEpochSecond();; + final String postEditReason = "Update by tool."; + int postEditUser = 2; + String query = getPostUpdateQuery(postId, postText, postChecksum, postEditTime, postEditReason, postEditUser); + executeUpdate(query); + } + + public String getPostUpdateQuery(int postId, String postText, String postChecksum, long postEditTime, String postEditReason, int postEditUser) { + return "UPDATE phpbb_posts SET " + + "post_text = '" + postText + "', " + + "post_checksum = '" + postChecksum + "', " + + "post_edit_time = " + postEditTime + ", " + + "post_edit_reason = '" + postEditReason + "', " + + "post_edit_user = " + postEditUser + ", " + + "post_edit_count = post_edit_count + 1 " + + "WHERE post_id = " + postId + ";"; + } + + public String getChecksum(String postText) { + String postTextForMd5 = replaceXmlMetacharacters(postText); + MessageDigest md = null; + try { + md = MessageDigest.getInstance("MD5"); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + assert md != null; + md.update(postTextForMd5.getBytes()); + byte[] digest = md.digest(); + return DatatypeConverter.printHexBinary(digest).toLowerCase(); + } + + public String replaceXmlMetacharacters(String post) { + post = post.replace("&", "&"); + post = post.replace("<", "<"); + post = post.replace(">", ">"); + post = post.replace("\"", """); + post = post.replace("'", "'"); + return post; + } } diff --git a/src/main/resources/Tippliga/Ligen.json b/src/main/resources/Tippliga/Ligen.json new file mode 100644 index 0000000..46d3ab5 --- /dev/null +++ b/src/main/resources/Tippliga/Ligen.json @@ -0,0 +1,72 @@ +[ + { + "country": "Germany", + "name": "Bundesliga 1", + "league_id": 2755 + }, + { + "country": "Germany", + "name": "Bundesliga 2", + "league_id": 2743 + }, + { + "country": "Germany", + "name": "Liga 3", + "league_id": 2795 + }, + { + "country": "Germany", + "name": "Regionalliga - SudWest", + "league_id": 2823 + }, + { + "country": "Germany", + "name": "Regionalliga - Bayern", + "league_id": 1240 + }, + { + "country": "Germany", + "name": "DFB Pokal", + "league_id": 2677 + }, + { + "country": "Germany", + "name": "U19 Bundesliga", + "league_id": 2692 + }, + { + "country": "Germany", + "name": "Women Bundesliga", + "league_id": 2681 + }, + { + "country": "England", + "name": "Premier League", + "league_id": 2790 + }, + { + "country": "Spain", + "name": "Primera Division", + "league_id": 2833 + }, + { + "country": "Italy", + "name": "Serie A", + "league_id": 2857 + }, + { + "country": "France", + "name": "Ligue 1", + "league_id": 2664 + }, + { + "country": "World", + "name": "UEFA Champions League", + "league_id": 2771 + }, + { + "country": "World", + "name": "UEFA Europa League", + "league_id": 2777 + } +] \ No newline at end of file diff --git a/src/main/resources/Tippliga/Team_ID_Matcher_Config.json b/src/main/resources/Tippliga/Team_ID_Matcher_Config.json new file mode 100644 index 0000000..aac4589 --- /dev/null +++ b/src/main/resources/Tippliga/Team_ID_Matcher_Config.json @@ -0,0 +1,582 @@ +[ + { + "teamname": "FC Bayern München", + "tippligaID": 1, + "apiFootballID": 157 + }, + { + "teamname": "Hertha BSC Berlin", + "tippligaID": 16, + "apiFootballID": 159 + }, + { + "teamname": "Borussia Dortmund", + "tippligaID": 12, + "apiFootballID": 165 + }, + { + "teamname": "FC Augsburg", + "tippligaID": 23, + "apiFootballID": 170 + }, + { + "teamname": "Bayer Leverkusen", + "tippligaID": 14, + "apiFootballID": 168 + }, + { + "teamname": "FC Paderborn 07", + "tippligaID": 33, + "apiFootballID": 185 + }, + { + "teamname": "1. FC Köln", + "tippligaID": 24, + "apiFootballID": 192 + }, + { + "teamname": "1. FC Union Berlin", + "tippligaID": 66, + "apiFootballID": 182 + }, + { + "teamname": "1. FSV Mainz", + "tippligaID": 6, + "apiFootballID": 164 + }, + { + "teamname": "Borussia Mönchengladbach", + "tippligaID": 2, + "apiFootballID": 163 + }, + { + "teamname": "Eintracht Frankfurt", + "tippligaID": 13, + "apiFootballID": 169 + }, + { + "teamname": "FC Schalke 04", + "tippligaID": 9, + "apiFootballID": 174 + }, + { + "teamname": "Fortuna Düsseldorf", + "tippligaID": 89, + "apiFootballID": 158 + }, + { + "teamname": "RB Leipzig", + "tippligaID": 110, + "apiFootballID": 173 + }, + { + "teamname": "SC Freiburg", + "tippligaID": 28, + "apiFootballID": 160 + }, + { + "teamname": "TSG 1899 Hoffenheim", + "tippligaID": 47, + "apiFootballID": 167 + }, + { + "teamname": "Vfl Wolfsburg", + "tippligaID": 11, + "apiFootballID": 161 + }, + { + "teamname": "Werder Bremen", + "tippligaID": 17, + "apiFootballID": 162 + }, + { + "teamname": "1. FC Nürnberg", + "tippligaID": 4, + "apiFootballID": 171 + }, + { + "teamname": "Hannover 96", + "tippligaID": 15, + "apiFootballID": 166 + }, + { + "teamname": "VfB Stuttgart", + "tippligaID": 8, + "apiFootballID": 172 + }, + { + "teamname": "VfL Osnabrück", + "tippligaID": 42, + "apiFootballID": 1324 + }, + { + "teamname": "Erzgebirge Aue", + "tippligaID": 30, + "apiFootballID": 190 + }, + { + "teamname": "Carl Zeiss Jena", + "tippligaID": 36, + "apiFootballID": 1325 + }, + { + "teamname": "Eintracht Braunschweig", + "tippligaID": 25, + "apiFootballID": 744 + }, + { + "teamname": "1. FC Kaiserslautern", + "tippligaID": 19, + "apiFootballID": 745 + }, + { + "teamname": "1. FC Magdeburg", + "tippligaID": 59, + "apiFootballID": 179 + }, + { + "teamname": "Arminia Bielefeld", + "tippligaID": 18, + "apiFootballID": 188 + }, + { + "teamname": "FC St. Pauli", + "tippligaID": 49, + "apiFootballID": 186 + }, + { + "teamname": "Hamburger SV", + "tippligaID": 3, + "apiFootballID": 175 + }, + { + "teamname": "Hansa Rostock", + "tippligaID": 21, + "apiFootballID": 1321 + }, + { + "teamname": "Holstein Kiel", + "tippligaID": 63, + "apiFootballID": 191 + }, + { + "teamname": "Karlsruher SC", + "tippligaID": 26, + "apiFootballID": 785 + }, + { + "teamname": "MSV Duisburg", + "tippligaID": 31, + "apiFootballID": 187 + }, + { + "teamname": "SpVgg Greuther Fürth", + "tippligaID": 27, + "apiFootballID": 178 + }, + { + "teamname": "SpVgg Unterhaching", + "tippligaID": 29, + "apiFootballID": 1314 + }, + { + "teamname": "Darmstadt 98", + "tippligaID": 70, + "apiFootballID": 181 + }, + { + "teamname": "SV Sandhausen", + "tippligaID": 53, + "apiFootballID": 189 + }, + { + "teamname": "TSV 1860 München", + "tippligaID": 20, + "apiFootballID": 786 + }, + { + "teamname": "VfL Bochum", + "tippligaID": 5, + "apiFootballID": 176 + }, + { + "teamname": "FC Ingolstadt 04", + "tippligaID": 72, + "apiFootballID": 184 + }, + { + "teamname": "SV Wehen Wiesbaden", + "tippligaID": 48, + "apiFootballID": 1319 + }, + { + "teamname": "Dynamo Dresden", + "tippligaID": 38, + "apiFootballID": 183 + }, + { + "teamname": "Bayern München II", + "tippligaID": 168, + "apiFootballID": 4674 + }, + { + "teamname": "Jahn Regensburg", + "tippligaID": 43, + "apiFootballID": 177 + }, + { + "teamname": "Preußen Münster", + "tippligaID": 81, + "apiFootballID": 1313 + }, + { + "teamname": "1. FC Heidenheim 1846", + "tippligaID": 85, + "apiFootballID": 180 + }, + { + "teamname": "Chemnitzer FC", + "tippligaID": 79, + "apiFootballID": 1328 + }, + { + "teamname": "Hallescher FC", + "tippligaID": 78, + "apiFootballID": 1316 + }, + { + "teamname": "Würzburger Kickers", + "tippligaID": 107, + "apiFootballID": 784 + }, + { + "teamname": "SG Sonnenhof Großaspach", + "tippligaID": 97, + "apiFootballID": 1317 + }, + { + "teamname": "Waldhof Mannheim", + "tippligaID": 167, + "apiFootballID": 4268 + }, + { + "teamname": "KFC Uerdingen 05", + "tippligaID": 119, + "apiFootballID": 1322 + }, + { + "teamname": "SV Meppen", + "tippligaID": 139, + "apiFootballID": 1318 + }, + { + "teamname": "FSV Zwickau", + "tippligaID": 146, + "apiFootballID": 1315 + }, + { + "teamname": "Viktoria Köln", + "tippligaID": 609, + "apiFootballID": 1620 + }, + { + "teamname": "Kickers Offenbach", + "tippligaID": 22, + "apiFootballID": 1628 + }, + { + "teamname": "Rot-Weiss Essen", + "tippligaID": 34, + "apiFootballID": 1621 + }, + { + "teamname": "SV Babelsberg 03", + "tippligaID": 67, + "apiFootballID": 1622 + }, + { + "teamname": "FSV Frankfurt", + "tippligaID": 71, + "apiFootballID": 1332 + }, + { + "teamname": "Sportfreunde Lotte", + "tippligaID": 95, + "apiFootballID": 1323 + }, + { + "teamname": "FC 08 Homburg", + "tippligaID": 84, + "apiFootballID": 1634 + }, + { + "teamname": "VfB Lübeck", + "tippligaID": 40, + "apiFootballID": 1625 + }, + { + "teamname": "FC Villingen", + "tippligaID": 69, + "apiFootballID": 1619 + }, + { + "teamname": "FC Astoria Walldorf", + "tippligaID": 603, + "apiFootballID": 1626 + }, + { + "teamname": "SV Drochtersen/Assel", + "tippligaID": 152, + "apiFootballID": 1623 + }, + { + "teamname": "Eintracht Norderstedt", + "tippligaID": 148, + "apiFootballID": 1631 + }, + { + "teamname": "TSV Havelse", + "tippligaID": 65, + "apiFootballID": 9342 + }, + { + "teamname": "FSV Union Fürstenwalde", + "tippligaID": 176, + "apiFootballID": 9357 + }, + { + "teamname": "SV Todesfelde", + "tippligaID": 177, + "apiFootballID": 12880 + }, + { + "teamname": "FV Engers 07", + "tippligaID": 178, + "apiFootballID": 12767 + }, + { + "teamname": "FC Oberneuland", + "tippligaID": 74, + "apiFootballID": 4263 + }, + { + "teamname": "VSG Altglienicke", + "tippligaID": 179, + "apiFootballID": 9349 + }, + { + "teamname": "MTV Eintracht Celle", + "tippligaID": 180, + "apiFootballID": 12758 + }, + { + "teamname": "RSV Meinerzhagen", + "tippligaID": 181, + "apiFootballID": 12814 + }, + { + "teamname": "SSV Ulm 1846", + "tippligaID": 166, + "apiFootballID": 1652 + }, + { + "teamname": "FC Rielasingen-Arlen", + "tippligaID": 162, + "apiFootballID": 1642 + }, + { + "teamname": "Eintracht Norderstedt", + "tippligaID": 148, + "apiFootballID": 1631 + }, + { + "teamname": "TSV Steinbach", + "tippligaID": 164, + "apiFootballID": 1656 + }, + { + "teamname": "SC Wiedenbrück", + "tippligaID": 118, + "apiFootballID": 12897 + }, + { + "teamname": "SV 07 Elversberg", + "tippligaID": 96, + "apiFootballID": 1660 + }, + { + "teamname": "1. FC Düren", + "tippligaID": 182, + "apiFootballID": 12754 + }, + { + "teamname": "Olymp. Lyon", + "tippligaID": 505, + "apiFootballID": 80 + }, + { + "teamname": "AS Monaco", + "tippligaID": 160, + "apiFootballID": 91 + }, + { + "teamname": "Manchester United", + "tippligaID": 501, + "apiFootballID": 33 + }, + { + "teamname": "FC Arsenal London", + "tippligaID": 522, + "apiFootballID": 42 + }, + { + "teamname": "1. FC Schweinfurt 05", + "tippligaID": 595, + "apiFootballID": 1635 + }, + { + "teamname": "Real Betis Sevilla", + "tippligaID": 599, + "apiFootballID": 543 + }, + { + "teamname": "FC Barcelona", + "tippligaID": 504, + "apiFootballID": 529 + }, + { + "teamname": "Celta Vigo", + "tippligaID": 611, + "apiFootballID": 538 + }, + { + "teamname": "CA Osasuna", + "tippligaID": 574, + "apiFootballID": 727 + }, + { + "teamname": "Athletic Bilbao", + "tippligaID": 558, + "apiFootballID": 531 + }, + { + "teamname": "Real Madrid", + "tippligaID": 503, + "apiFootballID": 541 + }, + { + "teamname": "FC Getafe", + "tippligaID": 435, + "apiFootballID": 546 + }, + { + "teamname": "FC Valencia", + "tippligaID": 517, + "apiFootballID": 532 + }, + { + "teamname": "Levante UD", + "tippligaID": 570, + "apiFootballID": 539 + }, + { + "teamname": "Real Sociedad", + "tippligaID": 573, + "apiFootballID": 548 + }, + { + "teamname": "FC Villarreal", + "tippligaID": 407, + "apiFootballID": 533 + }, + { + "teamname": "Atlético Madrid", + "tippligaID": 409, + "apiFootballID": 530 + }, + { + "teamname": "FC Sevilla", + "tippligaID": 529, + "apiFootballID": 536 + }, + { + "teamname": "Manchester United", + "tippligaID": 501, + "apiFootballID": 33 + }, + { + "teamname": "FC Southampton", + "tippligaID": 596, + "apiFootballID": 41 + }, + { + "teamname": "FC Fulham", + "tippligaID": 5555, + "apiFootballID": 36 + }, + { + "teamname": "FC Arsenal London", + "tippligaID": 522, + "apiFootballID": 42 + }, + { + "teamname": "FC Liverpool", + "tippligaID": 519, + "apiFootballID": 40 + }, + { + "teamname": "Manchester City", + "tippligaID": 540, + "apiFootballID": 50 + }, + { + "teamname": "Aston Villa", + "tippligaID": 494, + "apiFootballID": 66 + }, + { + "teamname": "Tottenham", + "tippligaID": 432, + "apiFootballID": 47 + }, + { + "teamname": "Everton", + "tippligaID": 405, + "apiFootballID": 45 + }, + { + "teamname": "West Bromwich Albion", + "tippligaID": 568, + "apiFootballID": 60 + }, + { + "teamname": "Leicester City", + "tippligaID": 612, + "apiFootballID": 46 + }, + { + "teamname": "West Ham United", + "tippligaID": 567, + "apiFootballID": 48 + }, + { + "teamname": "Newcastle United", + "tippligaID": 566, + "apiFootballID": 34 + }, + { + "teamname": "Brighton & Hove Albion", + "tippligaID": 626, + "apiFootballID": 51 + }, + { + "teamname": "FC Chelsea London", + "tippligaID": 502, + "apiFootballID": 49 + }, + { + "teamname": "Wolverhampton Wanderers", + "tippligaID": 562, + "apiFootballID": 39 + } +] diff --git a/src/main/resources/Tippliga/Tipper_Match_Pair_Config.json b/src/main/resources/Tippliga/Tipper_Match_Pair_Config.json new file mode 100644 index 0000000..38fefae --- /dev/null +++ b/src/main/resources/Tippliga/Tipper_Match_Pair_Config.json @@ -0,0 +1,1289 @@ +[ + { + "matchday": 1, + "matches": [ + { + "home": 1, + "guest": 2 + }, + { + "home": 3, + "guest": 4 + }, + { + "home": 5, + "guest": 6 + }, + { + "home": 7, + "guest": 8 + }, + { + "home": 9, + "guest": 10 + }, + { + "home": 11, + "guest": 12 + }, + { + "home": 13, + "guest": 14 + } + ] + }, + { + "matchday": 2, + "matches": [ + { + "home": 12, + "guest": 9 + }, + { + "home": 10, + "guest": 7 + }, + { + "home": 8, + "guest": 5 + }, + { + "home": 6, + "guest": 3 + }, + { + "home": 4, + "guest": 13 + }, + { + "home": 14, + "guest": 1 + }, + { + "home": 2, + "guest": 11 + } + ] + }, + { + "matchday": 3, + "matches": [ + { + "home": 1, + "guest": 11 + }, + { + "home": 3, + "guest": 8 + }, + { + "home": 5, + "guest": 10 + }, + { + "home": 7, + "guest": 12 + }, + { + "home": 9, + "guest": 2 + }, + { + "home": 14, + "guest": 4 + }, + { + "home": 13, + "guest": 6 + } + ] + }, + { + "matchday": 4, + "matches": [ + { + "home": 12, + "guest": 5 + }, + { + "home": 10, + "guest": 3 + }, + { + "home": 8, + "guest": 13 + }, + { + "home": 6, + "guest": 14 + }, + { + "home": 4, + "guest": 1 + }, + { + "home": 11, + "guest": 9 + }, + { + "home": 2, + "guest": 7 + } + ] + }, + { + "matchday": 5, + "matches": [ + { + "home": 1, + "guest": 9 + }, + { + "home": 3, + "guest": 12 + }, + { + "home": 5, + "guest": 2 + }, + { + "home": 7, + "guest": 11 + }, + { + "home": 4, + "guest": 6 + }, + { + "home": 14, + "guest": 8 + }, + { + "home": 13, + "guest": 10 + } + ] + }, + { + "matchday": 6, + "matches": [ + { + "home": 12, + "guest": 13 + }, + { + "home": 10, + "guest": 14 + }, + { + "home": 8, + "guest": 4 + }, + { + "home": 6, + "guest": 1 + }, + { + "home": 9, + "guest": 7 + }, + { + "home": 11, + "guest": 5 + }, + { + "home": 2, + "guest": 3 + } + ] + }, + { + "matchday": 7, + "matches": [ + { + "home": 1, + "guest": 7 + }, + { + "home": 3, + "guest": 11 + }, + { + "home": 5, + "guest": 9 + }, + { + "home": 6, + "guest": 8 + }, + { + "home": 4, + "guest": 10 + }, + { + "home": 14, + "guest": 12 + }, + { + "home": 13, + "guest": 2 + } + ] + }, + { + "matchday": 8, + "matches": [ + { + "home": 12, + "guest": 4 + }, + { + "home": 10, + "guest": 6 + }, + { + "home": 8, + "guest": 1 + }, + { + "home": 7, + "guest": 5 + }, + { + "home": 9, + "guest": 3 + }, + { + "home": 11, + "guest": 13 + }, + { + "home": 2, + "guest": 14 + } + ] + }, + { + "matchday": 9, + "matches": [ + { + "home": 1, + "guest": 5 + }, + { + "home": 3, + "guest": 7 + }, + { + "home": 8, + "guest": 10 + }, + { + "home": 6, + "guest": 12 + }, + { + "home": 4, + "guest": 2 + }, + { + "home": 14, + "guest": 11 + }, + { + "home": 13, + "guest": 9 + } + ] + }, + { + "matchday": 10, + "matches": [ + { + "home": 12, + "guest": 8 + }, + { + "home": 10, + "guest": 1 + }, + { + "home": 5, + "guest": 3 + }, + { + "home": 7, + "guest": 13 + }, + { + "home": 9, + "guest": 14 + }, + { + "home": 11, + "guest": 4 + }, + { + "home": 2, + "guest": 6 + } + ] + }, + { + "matchday": 11, + "matches": [ + { + "home": 1, + "guest": 3 + }, + { + "home": 10, + "guest": 12 + }, + { + "home": 8, + "guest": 2 + }, + { + "home": 6, + "guest": 11 + }, + { + "home": 4, + "guest": 9 + }, + { + "home": 14, + "guest": 7 + }, + { + "home": 13, + "guest": 5 + } + ] + }, + { + "matchday": 12, + "matches": [ + { + "home": 1, + "guest": 12 + }, + { + "home": 3, + "guest": 13 + }, + { + "home": 5, + "guest": 14 + }, + { + "home": 7, + "guest": 4 + }, + { + "home": 9, + "guest": 6 + }, + { + "home": 11, + "guest": 8 + }, + { + "home": 2, + "guest": 10 + } + ] + }, + { + "matchday": 13, + "matches": [ + { + "home": 12, + "guest": 2 + }, + { + "home": 10, + "guest": 11 + }, + { + "home": 8, + "guest": 9 + }, + { + "home": 6, + "guest": 7 + }, + { + "home": 4, + "guest": 5 + }, + { + "home": 14, + "guest": 3 + }, + { + "home": 13, + "guest": 1 + } + ] + }, + { + "matchday": 14, + "matches": [ + { + "home": 2, + "guest": 1 + }, + { + "home": 3, + "guest": 4 + }, + { + "home": 6, + "guest": 5 + }, + { + "home": 8, + "guest": 7 + }, + { + "home": 10, + "guest": 9 + }, + { + "home": 12, + "guest": 11 + }, + { + "home": 14, + "guest": 13 + } + ] + }, + { + "matchday": 15, + "matches": [ + { + "home": 9, + "guest": 12 + }, + { + "home": 7, + "guest": 10 + }, + { + "home": 5, + "guest": 8 + }, + { + "home": 3, + "guest": 6 + }, + { + "home": 13, + "guest": 4 + }, + { + "home": 1, + "guest": 14 + }, + { + "home": 11, + "guest": 2 + } + ] + }, + { + "matchday": 16, + "matches": [ + { + "home": 11, + "guest": 1 + }, + { + "home": 8, + "guest": 3 + }, + { + "home": 10, + "guest": 5 + }, + { + "home": 12, + "guest": 7 + }, + { + "home": 2, + "guest": 9 + }, + { + "home": 4, + "guest": 14 + }, + { + "home": 6, + "guest": 13 + } + ] + }, + { + "matchday": 17, + "matches": [ + { + "home": 5, + "guest": 12 + }, + { + "home": 3, + "guest": 10 + }, + { + "home": 13, + "guest": 8 + }, + { + "home": 14, + "guest": 6 + }, + { + "home": 1, + "guest": 4 + }, + { + "home": 9, + "guest": 11 + }, + { + "home": 7, + "guest": 2 + } + ] + }, + { + "matchday": 18, + "matches": [ + { + "home": 9, + "guest": 1 + }, + { + "home": 12, + "guest": 3 + }, + { + "home": 2, + "guest": 5 + }, + { + "home": 11, + "guest": 7 + }, + { + "home": 6, + "guest": 4 + }, + { + "home": 8, + "guest": 14 + }, + { + "home": 10, + "guest": 13 + } + ] + }, + { + "matchday": 19, + "matches": [ + { + "home": 13, + "guest": 12 + }, + { + "home": 14, + "guest": 10 + }, + { + "home": 4, + "guest": 8 + }, + { + "home": 1, + "guest": 6 + }, + { + "home": 7, + "guest": 9 + }, + { + "home": 5, + "guest": 11 + }, + { + "home": 3, + "guest": 2 + } + ] + }, + { + "matchday": 20, + "matches": [ + { + "home": 7, + "guest": 1 + }, + { + "home": 11, + "guest": 3 + }, + { + "home": 9, + "guest": 5 + }, + { + "home": 8, + "guest": 6 + }, + { + "home": 10, + "guest": 4 + }, + { + "home": 12, + "guest": 14 + }, + { + "home": 2, + "guest": 13 + } + ] + }, + { + "matchday": 21, + "matches": [ + { + "home": 4, + "guest": 12 + }, + { + "home": 6, + "guest": 10 + }, + { + "home": 1, + "guest": 8 + }, + { + "home": 5, + "guest": 7 + }, + { + "home": 3, + "guest": 9 + }, + { + "home": 13, + "guest": 11 + }, + { + "home": 14, + "guest": 12 + } + ] + }, + { + "matchday": 22, + "matches": [ + { + "home": 5, + "guest": 1 + }, + { + "home": 7, + "guest": 3 + }, + { + "home": 10, + "guest": 8 + }, + { + "home": 12, + "guest": 6 + }, + { + "home": 2, + "guest": 4 + }, + { + "home": 11, + "guest": 14 + }, + { + "home": 9, + "guest": 13 + } + ] + }, + { + "matchday": 23, + "matches": [ + { + "home": 8, + "guest": 12 + }, + { + "home": 1, + "guest": 10 + }, + { + "home": 3, + "guest": 5 + }, + { + "home": 13, + "guest": 7 + }, + { + "home": 14, + "guest": 9 + }, + { + "home": 4, + "guest": 11 + }, + { + "home": 6, + "guest": 2 + } + ] + }, + { + "matchday": 24, + "matches": [ + { + "home": 3, + "guest": 1 + }, + { + "home": 12, + "guest": 10 + }, + { + "home": 2, + "guest": 8 + }, + { + "home": 11, + "guest": 6 + }, + { + "home": 9, + "guest": 4 + }, + { + "home": 7, + "guest": 14 + }, + { + "home": 5, + "guest": 13 + } + ] + }, + { + "matchday": 25, + "matches": [ + { + "home": 12, + "guest": 1 + }, + { + "home": 13, + "guest": 3 + }, + { + "home": 14, + "guest": 5 + }, + { + "home": 4, + "guest": 7 + }, + { + "home": 6, + "guest": 9 + }, + { + "home": 8, + "guest": 11 + }, + { + "home": 10, + "guest": 2 + } + ] + }, + { + "matchday": 26, + "matches": [ + { + "home": 2, + "guest": 12 + }, + { + "home": 11, + "guest": 10 + }, + { + "home": 9, + "guest": 8 + }, + { + "home": 7, + "guest": 6 + }, + { + "home": 5, + "guest": 4 + }, + { + "home": 3, + "guest": 14 + }, + { + "home": 1, + "guest": 13 + } + ] + }, + { + "matchday": 27, + "matches": [ + { + "home": 2, + "guest": 1 + }, + { + "home": 3, + "guest": 4 + }, + { + "home": 6, + "guest": 5 + }, + { + "home": 8, + "guest": 7 + }, + { + "home": 10, + "guest": 9 + }, + { + "home": 12, + "guest": 11 + }, + { + "home": 14, + "guest": 13 + } + ] + }, + { + "matchday": 28, + "matches": [ + { + "home": 9, + "guest": 12 + }, + { + "home": 7, + "guest": 10 + }, + { + "home": 5, + "guest": 8 + }, + { + "home": 3, + "guest": 6 + }, + { + "home": 13, + "guest": 4 + }, + { + "home": 1, + "guest": 14 + }, + { + "home": 11, + "guest": 2 + } + ] + }, + { + "matchday": 29, + "matches": [ + { + "home": 11, + "guest": 1 + }, + { + "home": 8, + "guest": 3 + }, + { + "home": 10, + "guest": 5 + }, + { + "home": 12, + "guest": 7 + }, + { + "home": 2, + "guest": 9 + }, + { + "home": 4, + "guest": 14 + }, + { + "home": 6, + "guest": 13 + } + ] + }, + { + "matchday": 30, + "matches": [ + { + "home": 5, + "guest": 12 + }, + { + "home": 3, + "guest": 10 + }, + { + "home": 13, + "guest": 8 + }, + { + "home": 14, + "guest": 6 + }, + { + "home": 1, + "guest": 4 + }, + { + "home": 9, + "guest": 11 + }, + { + "home": 7, + "guest": 2 + } + ] + }, + { + "matchday": 31, + "matches": [ + { + "home": 9, + "guest": 1 + }, + { + "home": 12, + "guest": 3 + }, + { + "home": 2, + "guest": 5 + }, + { + "home": 11, + "guest": 7 + }, + { + "home": 6, + "guest": 4 + }, + { + "home": 8, + "guest": 14 + }, + { + "home": 10, + "guest": 13 + } + ] + }, + { + "matchday": 32, + "matches": [ + { + "home": 13, + "guest": 12 + }, + { + "home": 14, + "guest": 10 + }, + { + "home": 4, + "guest": 8 + }, + { + "home": 1, + "guest": 6 + }, + { + "home": 7, + "guest": 9 + }, + { + "home": 5, + "guest": 11 + }, + { + "home": 3, + "guest": 2 + } + ] + }, + { + "matchday": 33, + "matches": [ + { + "home": 7, + "guest": 1 + }, + { + "home": 11, + "guest": 3 + }, + { + "home": 9, + "guest": 5 + }, + { + "home": 8, + "guest": 6 + }, + { + "home": 10, + "guest": 4 + }, + { + "home": 12, + "guest": 14 + }, + { + "home": 2, + "guest": 13 + } + ] + }, + { + "matchday": 34, + "matches": [ + { + "home": 4, + "guest": 12 + }, + { + "home": 6, + "guest": 10 + }, + { + "home": 1, + "guest": 8 + }, + { + "home": 5, + "guest": 7 + }, + { + "home": 3, + "guest": 9 + }, + { + "home": 13, + "guest": 11 + }, + { + "home": 14, + "guest": 12 + } + ] + }, + { + "matchday": 35, + "matches": [ + { + "home": 5, + "guest": 1 + }, + { + "home": 7, + "guest": 3 + }, + { + "home": 10, + "guest": 8 + }, + { + "home": 12, + "guest": 6 + }, + { + "home": 2, + "guest": 4 + }, + { + "home": 11, + "guest": 14 + }, + { + "home": 9, + "guest": 13 + } + ] + }, + { + "matchday": 36, + "matches": [ + { + "home": 8, + "guest": 12 + }, + { + "home": 1, + "guest": 10 + }, + { + "home": 3, + "guest": 5 + }, + { + "home": 13, + "guest": 7 + }, + { + "home": 14, + "guest": 9 + }, + { + "home": 4, + "guest": 11 + }, + { + "home": 6, + "guest": 2 + } + ] + }, + { + "matchday": 37, + "matches": [ + { + "home": 3, + "guest": 1 + }, + { + "home": 12, + "guest": 10 + }, + { + "home": 2, + "guest": 8 + }, + { + "home": 11, + "guest": 6 + }, + { + "home": 9, + "guest": 4 + }, + { + "home": 7, + "guest": 14 + }, + { + "home": 5, + "guest": 13 + } + ] + }, + { + "matchday": 38, + "matches": [ + { + "home": 12, + "guest": 1 + }, + { + "home": 13, + "guest": 3 + }, + { + "home": 14, + "guest": 5 + }, + { + "home": 4, + "guest": 7 + }, + { + "home": 6, + "guest": 9 + }, + { + "home": 8, + "guest": 11 + }, + { + "home": 10, + "guest": 2 + } + ] + }, + { + "matchday": 39, + "matches": [ + { + "home": 2, + "guest": 12 + }, + { + "home": 11, + "guest": 10 + }, + { + "home": 9, + "guest": 8 + }, + { + "home": 7, + "guest": 6 + }, + { + "home": 5, + "guest": 4 + }, + { + "home": 3, + "guest": 14 + }, + { + "home": 1, + "guest": 13 + } + ] + } +] diff --git a/src/main/resources/Tippliga/Tipper_Team_Config.json b/src/main/resources/Tippliga/Tipper_Team_Config.json new file mode 100644 index 0000000..8946fad --- /dev/null +++ b/src/main/resources/Tippliga/Tipper_Team_Config.json @@ -0,0 +1,267 @@ +[ + { + "team_id": 2002, + "team_name": "Julian", + "team_name_short": "Julian" + }, + { + "team_id": 2053, + "team_name": "Demian", + "team_name_short": "Demian" + }, + { + "team_id": 2054, + "team_name": "Hilde", + "team_name_short": "Hilde" + }, + { + "team_id": 2055, + "team_name": "Oliver", + "team_name_short": "Oliver" + }, + { + "team_id": 2056, + "team_name": "Martin", + "team_name_short": "Martin" + }, + { + "team_id": 2057, + "team_name": "Matthias", + "team_name_short": "Matthias" + }, + { + "team_id": 2058, + "team_name": "Nicole (TG Rhön)", + "team_name_short": "Nicole" + }, + { + "team_id": 2059, + "team_name": "Sascha", + "team_name_short": "Sascha" + }, + { + "team_id": 2060, + "team_name": "TG Nürnberg", + "team_name_short": "TG Nürnb." + }, + { + "team_id": 2061, + "team_name": "Friedrich", + "team_name_short": "Friedrich" + }, + { + "team_id": 2062, + "team_name": "Jimmy", + "team_name_short": "Jimmy" + }, + { + "team_id": 2063, + "team_name": "Flo", + "team_name_short": "Flo" + }, + { + "team_id": 2064, + "team_name": "Max", + "team_name_short": "Max" + }, + { + "team_id": 2065, + "team_name": "Fabian", + "team_name_short": "Fabian" + }, + { + "team_id": 2066, + "team_name": "Bastian", + "team_name_short": "Bastian" + }, + { + "team_id": 2067, + "team_name": "Kevin", + "team_name_short": "Kevin" + }, + { + "team_id": 2068, + "team_name": "Tristan", + "team_name_short": "Tristan" + }, + { + "team_id": 2069, + "team_name": "Werner", + "team_name_short": "Werner" + }, + { + "team_id": 2070, + "team_name": "Johnny", + "team_name_short": "Werner" + }, + { + "team_id": 2071, + "team_name": "Marcel", + "team_name_short": "Marcel" + }, + { + "team_id": 2072, + "team_name": "TG Sportbild/Fifa", + "team_name_short": "TG Sportb." + }, + { + "team_id": 2073, + "team_name": "Marcel U.", + "team_name_short": "Marcel U." + }, + { + "team_id": 2074, + "team_name": "Kay", + "team_name_short": "Kay" + }, + { + "team_id": 2075, + "team_name": "Maxi H.", + "team_name_short": "Maxi H." + }, + { + "team_id": 2076, + "team_name": "Frank", + "team_name_short": "Frank" + }, + { + "team_id": 2077, + "team_name": "Stefanie", + "team_name_short": "Stefanie" + }, + { + "team_id": 2078, + "team_name": "Jaron", + "team_name_short": "Jaron" + }, + { + "team_id": 2079, + "team_name": "Jonas", + "team_name_short": "Jonas" + }, + { + "team_id": 2082, + "team_name": "Klaus", + "team_name_short": "Klaus" + }, + { + "team_id": 2083, + "team_name": "Eduard", + "team_name_short": "Eduard" + }, + { + "team_id": 2084, + "team_name": "Kristina", + "team_name_short": "Kristina" + }, + { + "team_id": 2085, + "team_name": "Andreas", + "team_name_short": "Andreas" + }, + { + "team_id": 2086, + "team_name": "Maxi U.", + "team_name_short": "Maxi U." + }, + { + "team_id": 2087, + "team_name": "Franz", + "team_name_short": "Franz" + }, + { + "team_id": 2088, + "team_name": "Vincent", + "team_name_short": "Vincent" + }, + { + "team_id": 2089, + "team_name": "Martin H.", + "team_name_short": "Martin H." + }, + { + "team_id": 2090, + "team_name": "Dome", + "team_name_short": "Dome" + }, + { + "team_id": 2091, + "team_name": "Dom", + "team_name_short": "Dom" + }, + { + "team_id": 2096, + "team_name": "Jan", + "team_name_short": "Jan" + }, + { + "team_id": 2102, + "team_name": "Maxi Z.", + "team_name_short": "Maxi Z." + }, + { + "team_id": 2103, + "team_name": "Patrick", + "team_name_short": "Patrick" + }, + { + "team_id": 2104, + "team_name": "Jan K.", + "team_name_short": "Jan K." + }, + { + "team_id": 2105, + "team_name": "Muck", + "team_name_short": "Muck" + }, + { + "team_id": 2106, + "team_name": "Philipp", + "team_name_short": "Philipp" + }, + { + "team_id": 2108, + "team_name": "Lukas", + "team_name_short": "Lukas" + }, + { + "team_id": 2109, + "team_name": "Sandro", + "team_name_short": "Sandro" + }, + { + "team_id": 2110, + "team_name": "Bernd", + "team_name_short": "Bernd" + }, + { + "team_id": 2112, + "team_name": "Arno", + "team_name_short": "Arno" + }, + { + "team_id": 2113, + "team_name": "Stefan", + "team_name_short": "Stefan" + }, + { + "team_id": 2114, + "team_name": "Armin", + "team_name_short": "Armin" + }, + { + "team_id": 2119, + "team_name": "Dominik", + "team_name_short": "Dominik" + }, + { + "team_id": 2123, + "team_name": "Michael", + "team_name_short": "Michael" + }, + { + "team_id": 2124, + "team_name": "Olli L.", + "team_name_short": "Olli L." + } +] diff --git a/src/test/java/de/jeyp91/S3ProviderTest.java b/src/test/java/de/jeyp91/S3ProviderTest.java new file mode 100644 index 0000000..1f4cadf --- /dev/null +++ b/src/test/java/de/jeyp91/S3ProviderTest.java @@ -0,0 +1,13 @@ +package de.jeyp91; + +import org.junit.Test; + +public class S3ProviderTest { + + @Test + public void getFixturesFromS3Test() { + S3Provider prov = new S3Provider(); + String rounds = prov.getFixturesStringFromS3(1240); + System.out.println(rounds); + } +} diff --git a/src/test/java/de/jeyp91/TeamIDMatcherTest.java b/src/test/java/de/jeyp91/TeamIDMatcherTest.java index d00d8c9..e25a81c 100644 --- a/src/test/java/de/jeyp91/TeamIDMatcherTest.java +++ b/src/test/java/de/jeyp91/TeamIDMatcherTest.java @@ -1,5 +1,6 @@ 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; @@ -46,7 +47,7 @@ public class TeamIDMatcherTest { 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); diff --git a/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java b/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java index 90d6ce4..337fb79 100644 --- a/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java +++ b/src/test/java/de/jeyp91/apifootball/APIFootballUpdaterTest.java @@ -2,25 +2,23 @@ package de.jeyp91.apifootball; import org.junit.Test; -import java.io.IOException; - public class APIFootballUpdaterTest { @Test - public void updateFixturesTest() throws IOException { - APIFootballUpdater updater = new APIFootballUpdater(2021); -// updater.updateFixtures(2692); + public void updateFixturesTest() { + APIFootballUpdater updater = new APIFootballUpdater(); + updater.updateFixtures(1240); } @Test - public void updateAllFixturesTest() throws IOException { - APIFootballUpdater updater = new APIFootballUpdater(2021); -// updater.updateAllFixtures(); + public void updateAllFixturesTest() { + APIFootballUpdater updater = new APIFootballUpdater(); + updater.updateAllFixtures(); } @Test - public void updateAllRoundsTest() throws IOException { - APIFootballUpdater updater = new APIFootballUpdater(2021); -// updater.updateAllRounds(); + public void updateAllRoundsTest() { + APIFootballUpdater updater = new APIFootballUpdater(); + updater.updateAllRounds(); } } diff --git a/src/test/java/de/jeyp91/gists/GistProviderTest.java b/src/test/java/de/jeyp91/gists/GistProviderTest.java deleted file mode 100644 index 6d52406..0000000 --- a/src/test/java/de/jeyp91/gists/GistProviderTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package de.jeyp91.gists; - -import com.google.api.client.util.DateTime; -import de.jeyp91.apifootball.APIFootballUpdater; -import org.json.simple.JSONArray; -import org.junit.Test; - -import java.io.UnsupportedEncodingException; - -public class GistProviderTest { - - @Test - public void listAllGistsTest() { - GistProvider prov = GistProvider.getInstance(); - JSONArray gists = prov.listAllGists(); -// System.out.println(gists); - } - - @Test - public void getFileTest() { - GistProvider prov = GistProvider.getInstance(); - String file = prov.getFileFromGist("Team_ID_Matcher.json"); -// System.out.println(file); - } - - @Test - public void getTeamIdMatcherTest() { - GistProvider prov = GistProvider.getInstance(); - JSONArray matcher = prov.getTeamIdMatcher(); -// System.out.println(matcher); - } - - @Test - public void getGistUpdatedTimestampTest() { - GistProvider prov = GistProvider.getInstance(); - DateTime date = prov.getGistUpdatedTimestamp("Matches"); -// System.out.println(date); - } - - @Test - public void getGistIDTest() { - GistProvider prov = GistProvider.getInstance(); - String id = prov.getGistID("Matches"); -// System.out.println(id); - } - - @Test - public void updateGistTest() throws UnsupportedEncodingException { - GistProvider prov = GistProvider.getInstance(); - APIFootballUpdater updater = new APIFootballUpdater(2021); -// String body = updater.getRawData("https://v2.api-football.com/fixtures/league/2738?timezone=Europe/Berlin"); -// String content = prov.updateGist("6ec51d59cac70c9f4c040eeea1c0cdd9", "matches_league_2738.json", body); -// System.out.println(content); - } -} diff --git a/src/test/java/de/jeyp91/gists/MatchesListGistUpdaterTest.java b/src/test/java/de/jeyp91/gists/MatchesListGistUpdaterTest.java deleted file mode 100644 index eef5cae..0000000 --- a/src/test/java/de/jeyp91/gists/MatchesListGistUpdaterTest.java +++ /dev/null @@ -1,14 +0,0 @@ -package de.jeyp91.gists; - -import org.junit.Test; - -import java.io.UnsupportedEncodingException; - -public class MatchesListGistUpdaterTest { - - @Test - public void updateAllLeaguesTest() throws UnsupportedEncodingException { - MatchesListGistUpdater updater = new MatchesListGistUpdater(); - updater.updateAllLeagues(); - } -} diff --git a/src/test/java/de/jeyp91/gists/TeamIDMatcherTemplateCreatorTest.java b/src/test/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreatorTest.java similarity index 76% rename from src/test/java/de/jeyp91/gists/TeamIDMatcherTemplateCreatorTest.java rename to src/test/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreatorTest.java index 3b0289d..57658ab 100644 --- a/src/test/java/de/jeyp91/gists/TeamIDMatcherTemplateCreatorTest.java +++ b/src/test/java/de/jeyp91/teamidmatcher/TeamIDMatcherTemplateCreatorTest.java @@ -1,5 +1,6 @@ -package de.jeyp91.gists; +package de.jeyp91.teamidmatcher; +import de.jeyp91.teamidmatcher.TeamIDMatcherTemplateCreator; import org.junit.Test; public class TeamIDMatcherTemplateCreatorTest { diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchdayUpdaterTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchdayUpdaterTest.java index 75f98db..1b4da23 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchdayUpdaterTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchdayUpdaterTest.java @@ -6,7 +6,7 @@ public class TLWMatchdayUpdaterTest { @Test public void getUpdateSqlTest1() throws Exception { - TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 1, "Tippliga.json"); + TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 1, "Tippliga"); String sql = matchdaysUpdater.getUpdateSql(); @@ -16,7 +16,7 @@ public class TLWMatchdayUpdaterTest { @Test public void getUpdateSqlTest2() throws Exception { - TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 2, "Tippliga.json"); + TLWMatchdaysUpdater matchdaysUpdater = new TLWMatchdaysUpdater(2021, 2, "Tippliga"); String sql = matchdaysUpdater.getUpdateSql(); diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchdaysCreatorTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchdaysCreatorTest.java index a339af4..56966a6 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchdaysCreatorTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchdaysCreatorTest.java @@ -12,7 +12,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysTippligaTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga"); ArrayList matchdays = matchdaysCreator.getMatchdays(); assertEquals((Integer) 1, matchdays.get(0).getMatchday()); @@ -20,7 +20,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysWTLPokalTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "WTL_Pokal.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "WTL-Pokal"); ArrayList matchdays = matchdaysCreator.getMatchdays(); assertEquals((Integer) 1, matchdays.get(0).getMatchday()); @@ -29,7 +29,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysTippliga1SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } @@ -37,7 +37,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysTippliga2SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } @@ -45,7 +45,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysTippliga51SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 51, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 51, "Tippliga"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } @@ -53,7 +53,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysTippliga52SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 52, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 52, "Tippliga"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } @@ -61,7 +61,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysWTLPokal48SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } @@ -69,7 +69,7 @@ public class TLWMatchdaysCreatorTest { @Test public void getMatchdaysWTLPokal98SqlTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 98, "WTL_Pokal.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 98, "WTL-Pokal"); String sql = matchdaysCreator.getMatchdaysSQL(); // System.out.println(sql); } diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorFootballTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorFootballTest.java index 0d63191..c36c1c9 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorFootballTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorFootballTest.java @@ -10,7 +10,7 @@ public class TLWMatchesCreatorFootballTest { @Test public void getMatchesTest() { - TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 1, "WTL_Pokal.json"); + TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 1, "WTL-Pokal"); ArrayList matches = creator.getMatches(); assertEquals((Integer) 1, matches.get(0).getMatchNo()); @@ -20,14 +20,14 @@ public class TLWMatchesCreatorFootballTest { @Test public void getMatchesTippligaSqlTest() { - TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 2, "Tippliga.json"); + TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 2, "Tippliga"); String sql = creator.getSQLInsertString(); // System.out.println(sql); } @Test public void getMatchesWTLPokalSqlTest() { - TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 48, "WTL_Pokal.json"); + TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 48, "WTL-Pokal"); String sql = creator.getSQLInsertString(); // System.out.println(sql); } diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokalTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokalTest.java index d36e0ec..77a560a 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokalTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperPokalTest.java @@ -8,9 +8,9 @@ public class TLWMatchesCreatorTipperPokalTest { @Test public void getMatchesWTLPokalTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal"); - TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays()); + TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays()); String sql = creator.getSQLInsertString(); // System.out.println(sql); diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperTest.java index 66b9f50..09480a6 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchesCreatorTipperTest.java @@ -10,9 +10,9 @@ public class TLWMatchesCreatorTipperTest { @Test public void getMatchesTippligaTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga"); - TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays()); + TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays()); String sql = creator.getSQLInsertString(); // System.out.println(sql); diff --git a/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java b/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java index 36c7ef6..bdb271e 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWMatchesUpdaterFootballTest.java @@ -6,7 +6,7 @@ public class TLWMatchesUpdaterFootballTest { @Test public void getUpdateSqlTest1() { - TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 1, "Tippliga.json"); + TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 1, "Tippliga"); String sql = updater.getUpdateSQL(); // System.out.println(sql); @@ -15,7 +15,7 @@ public class TLWMatchesUpdaterFootballTest { @Test public void getUpdateSqlTest2() { - TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 2, "Tippliga.json"); + TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 2, "Tippliga"); String sql = updater.getUpdateSQL(); // System.out.println(sql); @@ -24,7 +24,7 @@ public class TLWMatchesUpdaterFootballTest { @Test public void getUpdateSqlTest48() { - TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 48, "WTL_Pokal.json"); + TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 48, "WTL-Pokal"); String sql = updater.getUpdateSQL(); // System.out.println(sql); diff --git a/src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java b/src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java index 03717d1..a62f630 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java @@ -10,7 +10,7 @@ import static org.junit.Assert.assertEquals; public class TLWTeamsCreatorTest { @Test public void getTeamsTippligaFootball1Test() { - TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, "Tippliga.json"); + TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, "Tippliga"); ArrayList matches = matchesCreator.getMatches(); TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 1, matches); @@ -20,9 +20,9 @@ public class TLWTeamsCreatorTest { @Test public void getTeamsTipper1TLTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga"); - TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 51, "1TL_Tipper.json", matchdaysCreator.getMatchdays()); + TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 51, "1. Tippliga Tipper", matchdaysCreator.getMatchdays()); ArrayList matches = creator.getMatches(); @@ -33,9 +33,9 @@ public class TLWTeamsCreatorTest { @Test public void getTeamsTipper2TLTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga"); - TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays()); + TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2. Tippliga Tipper", matchdaysCreator.getMatchdays()); ArrayList matches = creator.getMatches(); @@ -46,9 +46,9 @@ public class TLWTeamsCreatorTest { @Test public void getTeamsTipperWTLTest() throws ParseException { - TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json"); + TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL-Pokal"); - TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays()); + TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL-Pokal Tipper", matchdaysCreator.getMatchdays()); ArrayList matches = creator.getMatches(); diff --git a/src/test/java/de/jeyp91/tippliga/TLWTeamsUpdaterTest.java b/src/test/java/de/jeyp91/tippliga/TLWTeamsUpdaterTest.java index f68d63a..0c2085f 100644 --- a/src/test/java/de/jeyp91/tippliga/TLWTeamsUpdaterTest.java +++ b/src/test/java/de/jeyp91/tippliga/TLWTeamsUpdaterTest.java @@ -6,21 +6,21 @@ public class TLWTeamsUpdaterTest { @Test public void getInsertSQLTest1() throws Exception { - TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 1, "Tippliga.json"); + TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 1, "Tippliga"); String sql = teamsUpdater.getInsertSQL(); // System.out.println(sql); } @Test public void getInsertSQLTest2() throws Exception { - TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 2, "Tippliga.json"); + TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 2, "Tippliga"); String sql = teamsUpdater.getInsertSQL(); // System.out.println(sql); } @Test public void getInsertSQLTest48() throws Exception { - TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 48, "WTL_Pokal.json"); + TLWTeamsUpdater teamsUpdater = new TLWTeamsUpdater(2021, 48, "WTL-Pokal"); String sql = teamsUpdater.getInsertSQL(); // System.out.println(sql); } diff --git a/src/test/java/de/jeyp91/tippliga/TippligaConfigProviderTest.java b/src/test/java/de/jeyp91/tippliga/TippligaConfigProviderTest.java new file mode 100644 index 0000000..8c80ccc --- /dev/null +++ b/src/test/java/de/jeyp91/tippliga/TippligaConfigProviderTest.java @@ -0,0 +1,14 @@ +package de.jeyp91.tippliga; + +import de.jeyp91.tippligaforum.TippligaConfigProvider; +import org.json.simple.JSONObject; +import org.junit.Test; + +public class TippligaConfigProviderTest { + + @Test + public void getTippligaConfigTest() { + TippligaConfigProvider prov = new TippligaConfigProvider(2021); + JSONObject config = prov.getTippligaConfig("Tippliga"); + } +} diff --git a/src/test/java/de/jeyp91/tippliga/TippligaSQLConnectorTest.java b/src/test/java/de/jeyp91/tippliga/TippligaSQLConnectorTest.java index da1bfe1..160cb85 100644 --- a/src/test/java/de/jeyp91/tippliga/TippligaSQLConnectorTest.java +++ b/src/test/java/de/jeyp91/tippliga/TippligaSQLConnectorTest.java @@ -1,5 +1,6 @@ package de.jeyp91.tippliga; +import de.jeyp91.tippligaforum.TippligaSQLConnector; import org.junit.Before; import org.junit.Test; @@ -9,16 +10,16 @@ import static org.junit.Assert.assertEquals; public class TippligaSQLConnectorTest { - TippligaSQLConnector tl; + TippligaSQLConnector con; @Before public void setup() { - tl = new TippligaSQLConnector(); + con = TippligaSQLConnector.getInstance(); } @Test public void getTeamsBySeasonAndLeagueTest() { - ArrayList teams = tl.getTeams("2020", "1"); + ArrayList teams = con.getTeams("2020", "1"); assertEquals(84, teams.size()); @@ -34,7 +35,7 @@ public class TippligaSQLConnectorTest { @Test public void getTeamsByIdTest() { - ArrayList teams = tl.getTeams("1"); + ArrayList teams = con.getTeams("1"); assertEquals(2021, teams.get(0).getSeason()); assertEquals(1, teams.get(0).getLeague()); @@ -48,7 +49,7 @@ public class TippligaSQLConnectorTest { @Test public void getMatchesBySeasonAndLeague() { - ArrayList matches = tl.getMatches("2020", "1"); + ArrayList matches = con.getMatches("2020", "1"); assertEquals(468, matches.size()); @@ -63,4 +64,38 @@ public class TippligaSQLConnectorTest { assertEquals((Integer) 2, matches.get(0).getGoalsHome()); assertEquals((Integer) 1, matches.get(0).getGoalsGuest()); } + + @Test + public void replaceXmlMetacharactersTest() { + String post = "[code]\n" + + "{\"a\"}\n" + + "[/code]"; + String replacement = con.replaceXmlMetacharacters(post); + System.out.println(replacement); + } + + @Test + public void getChecksumTest() { + String post = "[code]\n" + + "{\"a\"}\n" + + "[/code]"; + String md5 = con.getChecksum(post); + System.out.println(md5); + } + + @Test + public void getPostUpdateQueryTest() { + int postId = 582; + String postText = "[code]\n" + + "{\"a\"}\n" + + "[/code]"; + String postTextClean = con.replaceXmlMetacharacters(postText); + String postChecksum = con.getChecksum(postText); + long postEditTime = 1604691314; + String postEditReason = "Update by tool."; + int postEditUser = 2; + + String query = con.getPostUpdateQuery(postId, postTextClean, postChecksum, postEditTime, postEditReason, postEditUser); + System.out.println(query); + } } diff --git a/src/test/java/de/jeyp91/gists/MatchesListCreatorTest.java b/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java similarity index 67% rename from src/test/java/de/jeyp91/gists/MatchesListCreatorTest.java rename to src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java index 094bd04..839fbba 100644 --- a/src/test/java/de/jeyp91/gists/MatchesListCreatorTest.java +++ b/src/test/java/de/jeyp91/tippligaforum/MatchesListCreatorTest.java @@ -1,5 +1,6 @@ -package de.jeyp91.gists; +package de.jeyp91.tippligaforum; +import de.jeyp91.tippligaforum.MatchesListCreator; import org.junit.Test; public class MatchesListCreatorTest { @@ -7,35 +8,35 @@ public class MatchesListCreatorTest { @Test public void getMatchesTest2664() { MatchesListCreator creator = new MatchesListCreator(2664); - String matches = creator.getMatchesBeautful(); -// System.out.println(matches); + String matches = creator.getMatchesBeautiful(); + System.out.println(matches); } @Test public void getMatchesTest2743() { MatchesListCreator creator = new MatchesListCreator(2743); - String matches = creator.getMatchesBeautful(); + String matches = creator.getMatchesBeautiful(); // System.out.println(matches); } @Test public void getMatchesTest2755() { MatchesListCreator creator = new MatchesListCreator(2755); - String matches = creator.getMatchesBeautful(); + String matches = creator.getMatchesBeautiful(); // System.out.println(matches); } @Test public void getMatchesTest2790() { MatchesListCreator creator = new MatchesListCreator(2790); - String matches = creator.getMatchesBeautful(); + String matches = creator.getMatchesBeautiful(); // System.out.println(matches); } @Test public void getMatchesTest2795() { MatchesListCreator creator = new MatchesListCreator(2795); - String matches = creator.getMatchesBeautful(); + String matches = creator.getMatchesBeautiful(); // System.out.println(matches); } } diff --git a/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java b/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java new file mode 100644 index 0000000..6ddd342 --- /dev/null +++ b/src/test/java/de/jeyp91/tippligaforum/MatchesListForumUpdaterTest.java @@ -0,0 +1,21 @@ +package de.jeyp91.tippligaforum; + +import de.jeyp91.tippligaforum.MatchesListForumUpdater; +import org.junit.Test; + +import java.io.UnsupportedEncodingException; + +public class MatchesListForumUpdaterTest { + + @Test + public void updateAllLeaguesTest() { + MatchesListForumUpdater updater = new MatchesListForumUpdater(); + updater.updateAllLeagues(); + } + + @Test + public void updateLeagueTest() { + MatchesListForumUpdater updater = new MatchesListForumUpdater(); + updater.updateLeague(2755); + } +} diff --git a/tokens/StoredCredential b/tokens/StoredCredential index 5824350f3b86be1ad958f6907a42e9538919d82a..351afb0ee172b90f95521539affbed20976074dd 100644 GIT binary patch delta 190 zcmX@eagbv}1Y^B(h(VTtdtsKhZ&;MMr*4^lhI?L0xqrHAsfkf>plfDQZkk!Lp}(oQ zXM9lTnbjZkmB_cu;b7 zaF}OCX{kwZg}b+baagFIUs$}Wv3aDod1aBYznMj3WO zK56TQ(qv5Wsn`XM1xb`dv=T&~U~o=qg50^BltevWz;?v0a48EVWsS!B*$!u!spNH0 z_@?S&#~#338z8<}ts}GCBC<{&g1(AFTMS1{Q<2~LQ?<$