Refactor and clean up code
This commit is contained in:
@@ -0,0 +1,11 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
public class TLWFootballMatchesUpdater {
|
||||||
|
public TLWFootballMatchesUpdater() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUpdateSQL() {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -127,8 +127,6 @@ public class TLWMatch extends BaseMatch {
|
|||||||
this.matchday = matchday;
|
this.matchday = matchday;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
this.matchNo = matchNo;
|
this.matchNo = matchNo;
|
||||||
this.formulaHome = "D";
|
|
||||||
this.formulaGuest = "D";
|
|
||||||
this.status = status;
|
this.status = status;
|
||||||
this.koMatch = koMatch;
|
this.koMatch = koMatch;
|
||||||
this.matchDatetime = matchDatetime;
|
this.matchDatetime = matchDatetime;
|
||||||
@@ -169,35 +167,42 @@ public class TLWMatch extends BaseMatch {
|
|||||||
return this.groupId;
|
return this.groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer isSameMatch(OpenLigaDBMatch compareMatch) {
|
public String getFormulaHome() {
|
||||||
if(this.getSeason() != compareMatch.getSeason()) {
|
String formula = "'D'";
|
||||||
return COMPARISON_DIFFERENT;
|
if(this.teamIdHome != null) {
|
||||||
|
return "''";
|
||||||
}
|
}
|
||||||
if(this.getMatchday() != compareMatch.getMatchday()) {
|
else if (this.formulaHome != null) {
|
||||||
return COMPARISON_DIFFERENT;
|
formula = this.formulaHome;
|
||||||
}
|
}
|
||||||
if(this.getTeamIdHome() != compareMatch.getTeamIdHome()) {
|
return formula;
|
||||||
return COMPARISON_DIFFERENT;
|
}
|
||||||
|
|
||||||
|
public String getFormulaGuest() {
|
||||||
|
String formula = "'D'";
|
||||||
|
if(this.teamIdGuest != null) {
|
||||||
|
return "''";
|
||||||
}
|
}
|
||||||
if(this.getTeamIdGuest() != compareMatch.getTeamIdGuest()) {
|
else if (this.formulaGuest != null) {
|
||||||
return COMPARISON_DIFFERENT;
|
formula = this.formulaGuest;
|
||||||
}
|
}
|
||||||
String thisDateTime = this.getMatchDateTime().replace("T", " ");
|
return formula;
|
||||||
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
|
}
|
||||||
if(!tempDateTime.equals(thisDateTime)) {
|
|
||||||
return COMPARISON_DIFFERENT_DATETIME;
|
public String getSQLQueryInsert() {
|
||||||
}
|
return "INSERT INTO phpbb_footb_matches VALUES (" +
|
||||||
if(this.goalsHome != compareMatch.getGoalsHome() ||
|
getSQLQueryValues()
|
||||||
this.goalsGuest != compareMatch.getGoalsGuest()) {
|
+ ");";
|
||||||
return COMPARISON_DIFFERENT_RESULT;
|
|
||||||
}
|
|
||||||
return COMPARISON_IDENTICAL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSQLQueryReplace() {
|
public String getSQLQueryReplace() {
|
||||||
|
return "REPLACE INTO phpbb_footb_matches VALUES (" +
|
||||||
|
getSQLQueryValues()
|
||||||
|
+ ");";
|
||||||
|
}
|
||||||
|
|
||||||
String query = "REPLACE INTO phpbb_footb_matches VALUES (" +
|
public String getSQLQueryValues() {
|
||||||
this.season + ", " +
|
return this.season + ", " +
|
||||||
this.league + ", " +
|
this.league + ", " +
|
||||||
this.matchNo + ", " +
|
this.matchNo + ", " +
|
||||||
nullToSqlEmptyString(this.teamIdHome) + ", " +
|
nullToSqlEmptyString(this.teamIdHome) + ", " +
|
||||||
@@ -206,20 +211,22 @@ public class TLWMatch extends BaseMatch {
|
|||||||
nullToSqlEmptyString(this.goalsGuest) + ", " +
|
nullToSqlEmptyString(this.goalsGuest) + ", " +
|
||||||
this.matchday + ", " +
|
this.matchday + ", " +
|
||||||
this.status + ", " +
|
this.status + ", " +
|
||||||
"'" + this.matchDatetime + "', " +
|
nullToSqlEmptyString(this.matchDatetime) + ", " +
|
||||||
"'" + this.groupId + "', " +
|
nullToSqlEmptyString(this.groupId) + ", " +
|
||||||
"'" + this.formulaHome + "', " +
|
getFormulaHome() + ", " +
|
||||||
"'" + this.formulaGuest + "', " +
|
getFormulaGuest() + ", " +
|
||||||
nullToSqlEmptyString(this.koMatch) + ", " +
|
nullToSqlEmptyString(this.koMatch) + ", " +
|
||||||
nullToSqlEmptyString(this.goalsOvertimeHome) + ", " +
|
nullToSqlEmptyString(this.goalsOvertimeHome) + ", " +
|
||||||
nullToSqlEmptyString(this.goalsOvertimeGuest) + ", " +
|
nullToSqlEmptyString(this.goalsOvertimeGuest) + ", " +
|
||||||
nullToSqlEmptyString(this.showTable) + ", " +
|
nullToSqlEmptyString(this.showTable) + ", " +
|
||||||
"'0.00','0.00','0.00','0.00');";
|
"'0.00','0.00','0.00','0.00'";
|
||||||
|
|
||||||
return query;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String nullToSqlEmptyString(Integer number) {
|
private String nullToSqlEmptyString(Integer number) {
|
||||||
return number != null ? number.toString() : "''";
|
return number != null ? number.toString() : "''";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String nullToSqlEmptyString(String string) {
|
||||||
|
return string != null ? "'"+string+"'" : "''";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TLWFootballMatchdaysCreator {
|
public class TLWMatchdaysCreator {
|
||||||
|
|
||||||
int season;
|
int season;
|
||||||
int league;
|
int league;
|
||||||
@@ -21,11 +21,11 @@ public class TLWFootballMatchdaysCreator {
|
|||||||
int matchesPerMatchday;
|
int matchesPerMatchday;
|
||||||
JSONObject configObject;
|
JSONObject configObject;
|
||||||
|
|
||||||
public TLWFootballMatchdaysCreator (int season, int league, String configPath){
|
public TLWMatchdaysCreator(int season, int league, String configPath){
|
||||||
this.season = season;
|
this.season = season;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
|
|
||||||
TLWFootballMatchesCreator matchesCreator = new TLWFootballMatchesCreator(2021, 1, configPath);
|
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
|
||||||
this.matches = matchesCreator.getMatches();
|
this.matches = matchesCreator.getMatches();
|
||||||
|
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
54
src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorBase.java
Normal file
54
src/main/java/de/jeyp91/tippliga/TLWMatchesCreatorBase.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
import de.jeyp91.apifootball.APIFootballConnector;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public abstract class TLWMatchesCreatorBase {
|
||||||
|
|
||||||
|
ArrayList<TLWMatch> TLWMatches;
|
||||||
|
APIFootballConnector conn;
|
||||||
|
|
||||||
|
public TLWMatchesCreatorBase() {
|
||||||
|
this.TLWMatches = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<TLWMatch> getMatches() {
|
||||||
|
return this.TLWMatches;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSQLInsertString() {
|
||||||
|
String sql = "";
|
||||||
|
|
||||||
|
ArrayList<TLWMatch> tlwMatches = getMatches();
|
||||||
|
|
||||||
|
// Add matches from config
|
||||||
|
for(TLWMatch match : tlwMatches) {
|
||||||
|
sql += match.getSQLQueryInsert() + "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
return sql;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getNumberOfMatchdays() {
|
||||||
|
int matchday = 0;
|
||||||
|
for(TLWMatch match : this.TLWMatches) {
|
||||||
|
if(match.getMatchday() > matchday) {
|
||||||
|
matchday = match.getMatchday();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return matchday;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<TLWMatch> getMatchesForMatchday(int matchday) {
|
||||||
|
ArrayList<TLWMatch> matches = new ArrayList<>();
|
||||||
|
|
||||||
|
for(TLWMatch match : this.TLWMatches) {
|
||||||
|
if (match.getMatchday() == matchday) {
|
||||||
|
matches.add(match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return matches;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ import java.text.SimpleDateFormat;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class TLWFootballMatchesCreator {
|
public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
|
||||||
|
|
||||||
int season;
|
int season;
|
||||||
int league;
|
int league;
|
||||||
@@ -25,20 +25,17 @@ public class TLWFootballMatchesCreator {
|
|||||||
int nextMatchNo = 1;
|
int nextMatchNo = 1;
|
||||||
JSONArray matchdayConfig;
|
JSONArray matchdayConfig;
|
||||||
|
|
||||||
APIFootballConnector conn;
|
public TLWMatchesCreatorFootball(int season, int league, String configFileName) {
|
||||||
|
|
||||||
ArrayList<TLWMatch> TLWMatches;
|
super();
|
||||||
|
|
||||||
public TLWFootballMatchesCreator(int season, int league, String configFileName) {
|
|
||||||
this.season = season;
|
this.season = season;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
conn = new APIFootballConnector(season - 1);
|
this.conn = new APIFootballConnector(season - 1);
|
||||||
|
|
||||||
URL url = Resources.getResource(season + "\\" + configFileName);
|
URL url = Resources.getResource(season + "\\" + configFileName);
|
||||||
String jsonConfig = null;
|
String jsonConfig = null;
|
||||||
|
|
||||||
this.TLWMatches = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
|
||||||
@@ -60,7 +57,7 @@ public class TLWFootballMatchesCreator {
|
|||||||
for(int i = 0; i < this.matchdayConfig.size(); i++) {
|
for(int i = 0; i < this.matchdayConfig.size(); i++) {
|
||||||
int TLWMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("TLWMatchday")).intValue();
|
int TLWMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("TLWMatchday")).intValue();
|
||||||
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
|
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
|
||||||
ArrayList<APIFootballMatch> APIFootballMatches = getMatchesForMatchday(matchesConfig);
|
ArrayList<APIFootballMatch> APIFootballMatches = getAPIFootballMatchesForMatchday(matchesConfig);
|
||||||
|
|
||||||
int tempNumberOfMatchesBackup = this.matchesPerMatchday;
|
int tempNumberOfMatchesBackup = this.matchesPerMatchday;
|
||||||
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
if(((JSONObject) this.matchdayConfig.get(i)).containsKey("numberOfMatches")) {
|
||||||
@@ -112,7 +109,7 @@ public class TLWFootballMatchesCreator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ArrayList<APIFootballMatch> getMatchesForMatchday(JSONArray config) {
|
private ArrayList<APIFootballMatch> getAPIFootballMatchesForMatchday(JSONArray config) {
|
||||||
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
ArrayList<APIFootballMatch> apiFootballMatches = new ArrayList<>();
|
||||||
for (Object singleConfigObject : config) {
|
for (Object singleConfigObject : config) {
|
||||||
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
JSONObject singleConfig = (JSONObject) singleConfigObject;
|
||||||
@@ -140,52 +137,4 @@ public class TLWFootballMatchesCreator {
|
|||||||
long diffDays = diffTime / (1000 * 60 * 60 * 24);
|
long diffDays = diffTime / (1000 * 60 * 60 * 24);
|
||||||
return (int) diffDays;
|
return (int) diffDays;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<TLWMatch> getMatches() {
|
|
||||||
return this.TLWMatches;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSQLInsertString() {
|
|
||||||
String sql = "";
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> tlwMatches = getMatches();
|
|
||||||
|
|
||||||
// Add matches from config
|
|
||||||
for(TLWMatch match : tlwMatches) {
|
|
||||||
String teamIdHome = match.getTeamIdHome() != null ? match.getTeamIdHome().toString() : "''";
|
|
||||||
String teamIdGuest = match.getTeamIdGuest() != null ? match.getTeamIdGuest().toString() : "''";
|
|
||||||
|
|
||||||
String matchSql = "REPLACE INTO phpbb_footb_matches VALUES(";
|
|
||||||
matchSql += match.getSeason().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getLeague().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getMatchNo().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += teamIdHome;
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += teamIdGuest;
|
|
||||||
// No goals while creating league
|
|
||||||
matchSql += ", '', '', ";
|
|
||||||
matchSql += match.getMatchday().toString();
|
|
||||||
// status 0 while creating
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getStatus().toString();
|
|
||||||
matchSql += ", '";
|
|
||||||
matchSql += match.getMatchDateTime();
|
|
||||||
// group_id, formula_home, formula_guest
|
|
||||||
matchSql += "', '', '', '', '";
|
|
||||||
// ko_match,
|
|
||||||
matchSql += match.getKoMatch();
|
|
||||||
// goals_overtime_home, goals_overtime_guest
|
|
||||||
matchSql += "', '', '', ";
|
|
||||||
// show_table
|
|
||||||
matchSql += "0";
|
|
||||||
// trend, odd_1, odd_x, odd_2, rating
|
|
||||||
matchSql += ", '', '0.00', '0.00', '0.00', '0.00');\n";
|
|
||||||
sql += matchSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sql;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -11,18 +11,17 @@ import java.net.URL;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TLWTipperMatchesCreator {
|
public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
|
||||||
|
|
||||||
int season;
|
int season;
|
||||||
int league;
|
int league;
|
||||||
|
|
||||||
ArrayList<TLWMatch> TLWMatches;
|
|
||||||
JSONArray matchPairingConfig;
|
JSONArray matchPairingConfig;
|
||||||
JSONObject tipperList;
|
JSONObject tipperList;
|
||||||
JSONArray tipperTeamConfig;
|
JSONArray tipperTeamConfig;
|
||||||
ArrayList<TLWMatchday> matchdays;
|
ArrayList<TLWMatchday> matchdays;
|
||||||
|
|
||||||
public TLWTipperMatchesCreator(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
public TLWMatchesCreatorTipperLeague(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
||||||
this.season = season;
|
this.season = season;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
this.matchdays = matchdays;
|
this.matchdays = matchdays;
|
||||||
@@ -31,8 +30,6 @@ public class TLWTipperMatchesCreator {
|
|||||||
URL tipperListUrl = Resources.getResource(season + "\\" + configFileName);
|
URL tipperListUrl = Resources.getResource(season + "\\" + configFileName);
|
||||||
URL tipperTeamConfigUrl = Resources.getResource("Tipper_Team_Config.json");
|
URL tipperTeamConfigUrl = Resources.getResource("Tipper_Team_Config.json");
|
||||||
|
|
||||||
this.TLWMatches = new ArrayList<>();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JSONParser jsonParser = new JSONParser();
|
JSONParser jsonParser = new JSONParser();
|
||||||
|
|
||||||
@@ -87,50 +84,11 @@ public class TLWTipperMatchesCreator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(teamId == 0) {
|
if(teamId == 0) {
|
||||||
System.out.println("Did not find Tipper ID for " + name);
|
System.out.println("ERROR! Did not find Tipper ID for " + name);
|
||||||
}
|
}
|
||||||
return teamId;
|
return teamId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<TLWMatch> getMatches() {
|
|
||||||
return this.TLWMatches;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSQLInsertString() {
|
|
||||||
String sql = "";
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> tlwMatches = getMatches();
|
|
||||||
|
|
||||||
// Add matches from config
|
|
||||||
for(TLWMatch match : tlwMatches) {
|
|
||||||
String matchSql = "REPLACE INTO phpbb_footb_matches VALUES(";
|
|
||||||
matchSql += match.getSeason().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getLeague().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getMatchNo().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getTeamIdHome().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getTeamIdGuest().toString();
|
|
||||||
// No goals while creating league
|
|
||||||
matchSql += ", '', '', ";
|
|
||||||
matchSql += match.getMatchday().toString();
|
|
||||||
// status 0 while creating
|
|
||||||
matchSql += ", 0, '";
|
|
||||||
matchSql += match.getMatchDateTime();
|
|
||||||
// group_id, formula_home, formula_guest, ko_match, goals_overtime_home, goals_overtime_guest
|
|
||||||
matchSql += "', '', '', '', 0, '', '', ";
|
|
||||||
// show_table
|
|
||||||
matchSql += "0";
|
|
||||||
// trend, odd_1, odd_x, odd_2, rating
|
|
||||||
matchSql += ", '', '0.00', '0.00', '0.00', '0.00');\n";
|
|
||||||
sql += matchSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDeliveryDateForMatchday(int matchday) {
|
private String getDeliveryDateForMatchday(int matchday) {
|
||||||
String deliveryDate = "";
|
String deliveryDate = "";
|
||||||
for (TLWMatchday matchdayObject : this.matchdays) {
|
for (TLWMatchday matchdayObject : this.matchdays) {
|
||||||
@@ -11,7 +11,7 @@ import java.net.URL;
|
|||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class TLWTipperPokalMatchesCreator {
|
public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
|
||||||
|
|
||||||
int season;
|
int season;
|
||||||
int league;
|
int league;
|
||||||
@@ -21,7 +21,7 @@ public class TLWTipperPokalMatchesCreator {
|
|||||||
JSONArray tipperTeamConfig;
|
JSONArray tipperTeamConfig;
|
||||||
ArrayList<TLWMatchday> matchdays;
|
ArrayList<TLWMatchday> matchdays;
|
||||||
|
|
||||||
public TLWTipperPokalMatchesCreator(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
public TLWMatchesCreatorTipperPokal(int season, int league, String configFileName, ArrayList<TLWMatchday> matchdays) {
|
||||||
this.season = season;
|
this.season = season;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
this.matchdays = matchdays;
|
this.matchdays = matchdays;
|
||||||
@@ -51,16 +51,14 @@ public class TLWTipperPokalMatchesCreator {
|
|||||||
|
|
||||||
int matchday = 1;
|
int matchday = 1;
|
||||||
|
|
||||||
for(int i = 1; i < 13; i++) {
|
for(int matchNo = 1; matchNo < 13; matchNo++) {
|
||||||
|
|
||||||
String homeName = this.tipperList.get(String.valueOf(2 * i - 1)).toString();
|
String homeName = this.tipperList.get(String.valueOf(2 * matchNo - 1)).toString();
|
||||||
String guestName = this.tipperList.get(String.valueOf(2 * i)).toString();
|
String guestName = this.tipperList.get(String.valueOf(2 * matchNo)).toString();
|
||||||
|
|
||||||
int teamIdHome = getTeamIdFromTipperName(homeName);
|
int teamIdHome = getTeamIdFromTipperName(homeName);
|
||||||
int teamIdGuest = getTeamIdFromTipperName(guestName);
|
int teamIdGuest = getTeamIdFromTipperName(guestName);
|
||||||
|
|
||||||
int matchNo = i;
|
|
||||||
|
|
||||||
String matchDatetime = getDeliveryDateForMatchday(matchday);
|
String matchDatetime = getDeliveryDateForMatchday(matchday);
|
||||||
|
|
||||||
TLWMatch tlwMatch = new TLWMatch(this.season, this.league, matchday, matchNo, teamIdHome, teamIdGuest, matchDatetime);
|
TLWMatch tlwMatch = new TLWMatch(this.season, this.league, matchday, matchNo, teamIdHome, teamIdGuest, matchDatetime);
|
||||||
@@ -85,41 +83,6 @@ public class TLWTipperPokalMatchesCreator {
|
|||||||
return this.TLWMatches;
|
return this.TLWMatches;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSQLInsertString() {
|
|
||||||
String sql = "";
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> tlwMatches = getMatches();
|
|
||||||
|
|
||||||
// Add matches from config
|
|
||||||
for(TLWMatch match : tlwMatches) {
|
|
||||||
String matchSql = "REPLACE INTO phpbb_footb_matches VALUES(";
|
|
||||||
matchSql += match.getSeason().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getLeague().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getMatchNo().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getTeamIdHome().toString();
|
|
||||||
matchSql += ", ";
|
|
||||||
matchSql += match.getTeamIdGuest().toString();
|
|
||||||
// No goals while creating league
|
|
||||||
matchSql += ", '', '', ";
|
|
||||||
matchSql += match.getMatchday().toString();
|
|
||||||
// status 0 while creating
|
|
||||||
matchSql += ", 0, '";
|
|
||||||
matchSql += match.getMatchDateTime();
|
|
||||||
// group_id, formula_home, formula_guest, ko_match, goals_overtime_home, goals_overtime_guest
|
|
||||||
matchSql += "', '', '', '', 0, '', '', ";
|
|
||||||
// show_table
|
|
||||||
matchSql += "0";
|
|
||||||
// trend, odd_1, odd_x, odd_2, rating
|
|
||||||
matchSql += ", '', '0.00', '0.00', '0.00', '0.00');\n";
|
|
||||||
sql += matchSql;
|
|
||||||
}
|
|
||||||
|
|
||||||
return sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
private String getDeliveryDateForMatchday(int matchday) {
|
private String getDeliveryDateForMatchday(int matchday) {
|
||||||
String deliveryDate = "";
|
String deliveryDate = "";
|
||||||
for (TLWMatchday matchdayObject : this.matchdays) {
|
for (TLWMatchday matchdayObject : this.matchdays) {
|
||||||
@@ -17,7 +17,7 @@ public class TLWTeam {
|
|||||||
private String groupId;
|
private String groupId;
|
||||||
private int matchday;
|
private int matchday;
|
||||||
|
|
||||||
public TLWTeam(ResultSet rset) throws SQLException {
|
public TLWTeam(ResultSet rset) {
|
||||||
final int SEASON = 1;
|
final int SEASON = 1;
|
||||||
final int LEAGUE = 2;
|
final int LEAGUE = 2;
|
||||||
final int TEAM_ID = 3;
|
final int TEAM_ID = 3;
|
||||||
@@ -27,14 +27,19 @@ public class TLWTeam {
|
|||||||
final int GROUP_ID = 7;
|
final int GROUP_ID = 7;
|
||||||
final int MATCHDAY = 8;
|
final int MATCHDAY = 8;
|
||||||
|
|
||||||
this.season = Integer.parseInt(rset.getString(SEASON));
|
try {
|
||||||
this.league = Integer.parseInt(rset.getString(LEAGUE));
|
this.season = Integer.parseInt(rset.getString(SEASON));
|
||||||
this.teamId = Integer.parseInt(rset.getString(TEAM_ID));
|
this.league = Integer.parseInt(rset.getString(LEAGUE));
|
||||||
this.teamName = rset.getString(TEAM_NAME);
|
this.teamId = Integer.parseInt(rset.getString(TEAM_ID));
|
||||||
this.teamNameShort = rset.getString(TEAM_NAME_SHORT);
|
this.teamName = rset.getString(TEAM_NAME);
|
||||||
this.teamSymbol = rset.getString(TEAM_SYMBOL);
|
this.teamNameShort = rset.getString(TEAM_NAME_SHORT);
|
||||||
this.groupId = rset.getString(GROUP_ID);
|
this.teamSymbol = rset.getString(TEAM_SYMBOL);
|
||||||
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
|
this.groupId = rset.getString(GROUP_ID);
|
||||||
|
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
/* TODO */
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSeason() {
|
public int getSeason() {
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ import java.util.ArrayList;
|
|||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class TLWTeamsPokalCreator {
|
public class TLWTeamsCreator {
|
||||||
int season;
|
int season;
|
||||||
int league;
|
int league;
|
||||||
ArrayList<TLWMatch> matches;
|
ArrayList<TLWMatch> matches;
|
||||||
TippligaSQLConnector connector = new TippligaSQLConnector();
|
TippligaSQLConnector connector = new TippligaSQLConnector();
|
||||||
|
|
||||||
public TLWTeamsPokalCreator(int season, int league, ArrayList<TLWMatch> matches) {
|
public TLWTeamsCreator(int season, int league, ArrayList<TLWMatch> matches) {
|
||||||
this.season = season;
|
this.season = season;
|
||||||
this.league = league;
|
this.league = league;
|
||||||
this.matches = matches;
|
this.matches = matches;
|
||||||
@@ -3,6 +3,7 @@ package de.jeyp91.tippliga;
|
|||||||
import de.jeyp91.tippliga.TLWMatch;
|
import de.jeyp91.tippliga.TLWMatch;
|
||||||
import de.jeyp91.tippliga.TLWTeam;
|
import de.jeyp91.tippliga.TLWTeam;
|
||||||
|
|
||||||
|
import javax.xml.transform.Result;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.DriverManager;
|
import java.sql.DriverManager;
|
||||||
@@ -34,66 +35,67 @@ public class TippligaSQLConnector {
|
|||||||
|
|
||||||
public ArrayList<TLWTeam> getTeamsBySeasonAndLeague(String season, String league) {
|
public ArrayList<TLWTeam> getTeamsBySeasonAndLeague(String season, String league) {
|
||||||
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
||||||
Statement stmt = null;
|
|
||||||
ResultSet rset = null;
|
|
||||||
ArrayList<TLWTeam> teams = new ArrayList<TLWTeam>();
|
|
||||||
try {
|
|
||||||
stmt = con.createStatement();
|
|
||||||
rset = stmt.executeQuery(queryString);
|
|
||||||
while ( rset.next()) {
|
|
||||||
teams.add(new TLWTeam(rset));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
/* TODO */
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
teams.sort((t1, t2) -> t1.getTeamId() - t2.getTeamId());
|
ArrayList<TLWTeam> teams = new ArrayList<>();
|
||||||
|
for (ResultSet rset : executeQuery(queryString)) {
|
||||||
|
teams.add(new TLWTeam(rset));
|
||||||
|
}
|
||||||
|
|
||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<TLWTeam> getTeamsById(String id) {
|
public ArrayList<TLWTeam> getTeamsById(String id) {
|
||||||
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + ";";
|
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + " ORDER BY `season` DESC;";
|
||||||
Statement stmt = null;
|
|
||||||
ResultSet rset = null;
|
ArrayList<TLWTeam> teams = new ArrayList<>();
|
||||||
ArrayList<TLWTeam> teams = new ArrayList<TLWTeam>();
|
for (ResultSet rset : executeQuery(queryString)) {
|
||||||
try {
|
teams.add(new TLWTeam(rset));
|
||||||
stmt = con.createStatement();
|
|
||||||
rset = stmt.executeQuery(queryString);
|
|
||||||
while ( rset.next()) {
|
|
||||||
teams.add(new TLWTeam(rset));
|
|
||||||
}
|
|
||||||
} catch (SQLException e) {
|
|
||||||
/* TODO */
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return teams;
|
return teams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<TLWMatch> getMatchesBySeasonAndLeague(String season, String league) {
|
private ArrayList<TLWMatch> getMatches(String queryString) {
|
||||||
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
|
||||||
Statement stmt = null;
|
ArrayList<TLWMatch> matches = new ArrayList<>();
|
||||||
ResultSet rset = null;
|
for (ResultSet rset : executeQuery(queryString)) {
|
||||||
ArrayList<TLWMatch> matches = new ArrayList<TLWMatch>();
|
matches.add(new TLWMatch(rset));
|
||||||
try {
|
|
||||||
stmt = con.createStatement();
|
|
||||||
rset = stmt.executeQuery(queryString);
|
|
||||||
while (rset.next()) {
|
|
||||||
matches.add(new TLWMatch(rset));
|
|
||||||
}
|
|
||||||
} catch (SQLException throwables) {
|
|
||||||
throwables.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<TLWMatch> getMatches(String season, String league) {
|
||||||
|
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + ";";
|
||||||
|
return getMatches(queryString);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<TLWMatch> getMatches(String season, String league, String matchday) {
|
||||||
|
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + "AND `matchday` = " + matchday + ";";
|
||||||
|
return getMatches(queryString);
|
||||||
|
}
|
||||||
|
|
||||||
public void updateMatchDateTime(String season, String league, String matchNo, String datetime) {
|
public void updateMatchDateTime(String season, String league, String matchNo, String datetime) {
|
||||||
String queryString = "UPDATE `phpbb_footb_matches` "
|
String queryString = "UPDATE `phpbb_footb_matches` "
|
||||||
+ "SET match_datetime = " + datetime
|
+ "SET match_datetime = " + datetime
|
||||||
+ " WHERE `season` = " + season
|
+ " WHERE `season` = " + season
|
||||||
+ " AND `league` = " + league
|
+ " AND `league` = " + league
|
||||||
+ " AND match_no = " + matchNo + ";";
|
+ " AND match_no = " + matchNo + ";";
|
||||||
|
executeQuery(queryString);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ArrayList<ResultSet> executeQuery (String queryString){
|
||||||
|
Statement stmt;
|
||||||
|
ResultSet rset;
|
||||||
|
ArrayList<ResultSet> results = new ArrayList<>();
|
||||||
|
try {
|
||||||
|
stmt = con.createStatement();
|
||||||
|
rset = stmt.executeQuery(queryString);
|
||||||
|
while (rset.next()) {
|
||||||
|
results.add(rset);
|
||||||
|
}
|
||||||
|
} catch (SQLException throwables) {
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
package de.jeyp91.tippliga;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class TLWFootballMatchdaysCreatorTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchdaysWTLPokalTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 1, "WTL_Pokal.json");
|
|
||||||
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
|
||||||
|
|
||||||
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchdaysWTLPokalSqlTest() {
|
|
||||||
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 98, "WTL_Pokal.json");
|
|
||||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchdaysTippligaTest() {
|
|
||||||
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 1, "Tippliga.json");
|
|
||||||
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
|
||||||
|
|
||||||
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchdaysTippligaSqlTest() {
|
|
||||||
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 52, "Tippliga.json");
|
|
||||||
String sql = matchdaysCreator.getMatchdaysSQL();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class TLWMatchdaysCreatorTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysTippligaTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json");
|
||||||
|
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
||||||
|
|
||||||
|
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysWTLPokalTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "WTL_Pokal.json");
|
||||||
|
ArrayList<TLWMatchday> matchdays = matchdaysCreator.getMatchdays();
|
||||||
|
|
||||||
|
assertEquals((Integer) 1, matchdays.get(0).getMatchday());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysTippliga1SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysTippliga2SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysTippliga51SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 51, "Tippliga.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysTippliga52SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 52, "Tippliga.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysWTLPokal48SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchdaysWTLPokal98SqlTest() {
|
||||||
|
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 98, "WTL_Pokal.json");
|
||||||
|
String sql = matchdaysCreator.getMatchdaysSQL();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,11 +6,11 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class TLWFootballMatchesCreatorTest {
|
public class TLWMatchesCreatorFootballTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMatchesTest() {
|
public void getMatchesTest() {
|
||||||
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(2021, 1, "WTL_Pokal.json");
|
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 1, "WTL_Pokal.json");
|
||||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||||
|
|
||||||
assertEquals((Integer) 1, matches.get(0).getMatchNo());
|
assertEquals((Integer) 1, matches.get(0).getMatchNo());
|
||||||
@@ -20,14 +20,14 @@ public class TLWFootballMatchesCreatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMatchesTippligaSqlTest() {
|
public void getMatchesTippligaSqlTest() {
|
||||||
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(2021, 2, "Tippliga.json");
|
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 2, "Tippliga.json");
|
||||||
String sql = creator.getSQLInsertString();
|
String sql = creator.getSQLInsertString();
|
||||||
System.out.println(sql);
|
System.out.println(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMatchesWTLPokalSqlTest() {
|
public void getMatchesWTLPokalSqlTest() {
|
||||||
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(2021, 48, "WTL_Pokal.json");
|
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 48, "WTL_Pokal.json");
|
||||||
String sql = creator.getSQLInsertString();
|
String sql = creator.getSQLInsertString();
|
||||||
System.out.println(sql);
|
System.out.println(sql);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class TLWMatchesCreatorTipperPokalTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesWTLPokalTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json");
|
||||||
|
|
||||||
|
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays());
|
||||||
|
|
||||||
|
String sql = creator.getSQLInsertString();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class TLWMatchesCreatorTipperTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getMatchesTippligaTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json");
|
||||||
|
|
||||||
|
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays());
|
||||||
|
|
||||||
|
String sql = creator.getSQLInsertString();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
58
src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java
Normal file
58
src/test/java/de/jeyp91/tippliga/TLWTeamsCreatorTest.java
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
public class TLWTeamsCreatorTest {
|
||||||
|
@Test
|
||||||
|
public void getTeamsTippligaFootball1Test() {
|
||||||
|
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, "Tippliga.json");
|
||||||
|
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
||||||
|
|
||||||
|
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 1, matches);
|
||||||
|
String sql = teamCreator.getSql();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getTeamsTipper1TLTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 1, "Tippliga.json");
|
||||||
|
|
||||||
|
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 51, "1TL_Tipper.json", matchdaysCreator.getMatchdays());
|
||||||
|
|
||||||
|
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||||
|
|
||||||
|
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 51, matches);
|
||||||
|
String sql = teamCreator.getSql();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getTeamsTipper2TLTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 2, "Tippliga.json");
|
||||||
|
|
||||||
|
TLWMatchesCreatorTipperLeague creator = new TLWMatchesCreatorTipperLeague(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays());
|
||||||
|
|
||||||
|
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||||
|
|
||||||
|
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 52, matches);
|
||||||
|
String sql = teamCreator.getSql();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getTeamsTipperWTLTest() {
|
||||||
|
TLWMatchdaysCreator matchdaysCreator = new TLWMatchdaysCreator(2021, 48, "WTL_Pokal.json");
|
||||||
|
|
||||||
|
TLWMatchesCreatorTipperPokal creator = new TLWMatchesCreatorTipperPokal(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays());
|
||||||
|
|
||||||
|
ArrayList<TLWMatch> matches = creator.getMatches();
|
||||||
|
|
||||||
|
TLWTeamsCreator teamCreator = new TLWTeamsCreator(2021, 98, matches);
|
||||||
|
String sql = teamCreator.getSql();
|
||||||
|
System.out.println(sql);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
package de.jeyp91.tippliga;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class TLWTeamsPokalCreatorTest {
|
|
||||||
@Test
|
|
||||||
public void getTeamsWTLPokalTest() {
|
|
||||||
TLWFootballMatchesCreator matchesCreator = new TLWFootballMatchesCreator(2021, 2, "Tippliga.json");
|
|
||||||
ArrayList<TLWMatch> matches = matchesCreator.getMatches();
|
|
||||||
|
|
||||||
TLWTeamsPokalCreator teamCreator = new TLWTeamsPokalCreator(2021, 2, matches);
|
|
||||||
String sql = teamCreator.getSql();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getTeamsTipper1TLTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 1, "Tippliga.json");
|
|
||||||
|
|
||||||
TLWTipperMatchesCreator creator = new TLWTipperMatchesCreator(2021, 51, "1TL_Tipper.json", matchdaysCreator.getMatchdays());
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
|
||||||
|
|
||||||
TLWTeamsPokalCreator teamCreator = new TLWTeamsPokalCreator(2021, 51, matches);
|
|
||||||
String sql = teamCreator.getSql();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getTeamsTipper2TLTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 2, "Tippliga.json");
|
|
||||||
|
|
||||||
TLWTipperMatchesCreator creator = new TLWTipperMatchesCreator(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays());
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
|
||||||
|
|
||||||
TLWTeamsPokalCreator teamCreator = new TLWTeamsPokalCreator(2021, 52, matches);
|
|
||||||
String sql = teamCreator.getSql();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getTeamsTipperWTLTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 48, "WTL_Pokal.json");
|
|
||||||
|
|
||||||
TLWTipperPokalMatchesCreator creator = new TLWTipperPokalMatchesCreator(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays());
|
|
||||||
|
|
||||||
ArrayList<TLWMatch> matches = creator.getMatches();
|
|
||||||
|
|
||||||
TLWTeamsPokalCreator teamCreator = new TLWTeamsPokalCreator(2021, 98, matches);
|
|
||||||
String sql = teamCreator.getSql();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
package de.jeyp91.tippliga;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class TLWTipperMatchesCreatorTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchesTippligaTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 2, "Tippliga.json");
|
|
||||||
|
|
||||||
TLWTipperMatchesCreator creator = new TLWTipperMatchesCreator(2021, 52, "2TL_Tipper.json", matchdaysCreator.getMatchdays());
|
|
||||||
|
|
||||||
String sql = creator.getSQLInsertString();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
package de.jeyp91.tippliga;
|
|
||||||
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class TLWTipperPokalMatchesCreatorTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void getMatchesWTLPokalTest() {
|
|
||||||
TLWFootballMatchdaysCreator matchdaysCreator = new TLWFootballMatchdaysCreator(2021, 48, "WTL_Pokal.json");
|
|
||||||
|
|
||||||
TLWTipperPokalMatchesCreator creator = new TLWTipperPokalMatchesCreator(2021, 98, "WTL_Tipper.json", matchdaysCreator.getMatchdays());
|
|
||||||
|
|
||||||
String sql = creator.getSQLInsertString();
|
|
||||||
System.out.println(sql);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
package de.jeyp91.tippliga;
|
package de.jeyp91.tippliga;
|
||||||
|
|
||||||
import de.jeyp91.tippliga.TLWMatch;
|
|
||||||
import de.jeyp91.tippliga.TLWTeam;
|
|
||||||
import de.jeyp91.tippliga.TippligaSQLConnector;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -53,7 +50,7 @@ public class TippligaSQLConnectorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getMatchesBySeasonAndLeague() {
|
public void getMatchesBySeasonAndLeague() {
|
||||||
ArrayList<TLWMatch> matches = tl.getMatchesBySeasonAndLeague("2020", "1");
|
ArrayList<TLWMatch> matches = tl.getMatches("2020", "1");
|
||||||
|
|
||||||
assertEquals(468, matches.size());
|
assertEquals(468, matches.size());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user