Refactor and clean up code

This commit is contained in:
2020-09-27 23:26:41 +02:00
parent 283efc775b
commit a484010285
20 changed files with 349 additions and 373 deletions

View File

@@ -0,0 +1,11 @@
package de.jeyp91.tippliga;
public class TLWFootballMatchesUpdater {
public TLWFootballMatchesUpdater() {
}
public String getUpdateSQL() {
return "";
}
}

View File

@@ -127,8 +127,6 @@ public class TLWMatch extends BaseMatch {
this.matchday = matchday;
this.league = league;
this.matchNo = matchNo;
this.formulaHome = "D";
this.formulaGuest = "D";
this.status = status;
this.koMatch = koMatch;
this.matchDatetime = matchDatetime;
@@ -169,35 +167,42 @@ public class TLWMatch extends BaseMatch {
return this.groupId;
}
public Integer isSameMatch(OpenLigaDBMatch compareMatch) {
if(this.getSeason() != compareMatch.getSeason()) {
return COMPARISON_DIFFERENT;
public String getFormulaHome() {
String formula = "'D'";
if(this.teamIdHome != null) {
return "''";
}
if(this.getMatchday() != compareMatch.getMatchday()) {
return COMPARISON_DIFFERENT;
else if (this.formulaHome != null) {
formula = this.formulaHome;
}
if(this.getTeamIdHome() != compareMatch.getTeamIdHome()) {
return COMPARISON_DIFFERENT;
return formula;
}
public String getFormulaGuest() {
String formula = "'D'";
if(this.teamIdGuest != null) {
return "''";
}
if(this.getTeamIdGuest() != compareMatch.getTeamIdGuest()) {
return COMPARISON_DIFFERENT;
else if (this.formulaGuest != null) {
formula = this.formulaGuest;
}
String thisDateTime = this.getMatchDateTime().replace("T", " ");
String tempDateTime = compareMatch.getMatchDateTime().replace("T", " ");
if(!tempDateTime.equals(thisDateTime)) {
return COMPARISON_DIFFERENT_DATETIME;
}
if(this.goalsHome != compareMatch.getGoalsHome() ||
this.goalsGuest != compareMatch.getGoalsGuest()) {
return COMPARISON_DIFFERENT_RESULT;
}
return COMPARISON_IDENTICAL;
return formula;
}
public String getSQLQueryInsert() {
return "INSERT INTO phpbb_footb_matches VALUES (" +
getSQLQueryValues()
+ ");";
}
public String getSQLQueryReplace() {
return "REPLACE INTO phpbb_footb_matches VALUES (" +
getSQLQueryValues()
+ ");";
}
String query = "REPLACE INTO phpbb_footb_matches VALUES (" +
this.season + ", " +
public String getSQLQueryValues() {
return this.season + ", " +
this.league + ", " +
this.matchNo + ", " +
nullToSqlEmptyString(this.teamIdHome) + ", " +
@@ -206,20 +211,22 @@ public class TLWMatch extends BaseMatch {
nullToSqlEmptyString(this.goalsGuest) + ", " +
this.matchday + ", " +
this.status + ", " +
"'" + this.matchDatetime + "', " +
"'" + this.groupId + "', " +
"'" + this.formulaHome + "', " +
"'" + this.formulaGuest + "', " +
nullToSqlEmptyString(this.matchDatetime) + ", " +
nullToSqlEmptyString(this.groupId) + ", " +
getFormulaHome() + ", " +
getFormulaGuest() + ", " +
nullToSqlEmptyString(this.koMatch) + ", " +
nullToSqlEmptyString(this.goalsOvertimeHome) + ", " +
nullToSqlEmptyString(this.goalsOvertimeGuest) + ", " +
nullToSqlEmptyString(this.showTable) + ", " +
"'0.00','0.00','0.00','0.00');";
return query;
"'0.00','0.00','0.00','0.00'";
}
private String nullToSqlEmptyString(Integer number) {
return number != null ? number.toString() : "''";
}
private String nullToSqlEmptyString(String string) {
return string != null ? "'"+string+"'" : "''";
}
}

View File

@@ -13,7 +13,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class TLWFootballMatchdaysCreator {
public class TLWMatchdaysCreator {
int season;
int league;
@@ -21,11 +21,11 @@ public class TLWFootballMatchdaysCreator {
int matchesPerMatchday;
JSONObject configObject;
public TLWFootballMatchdaysCreator (int season, int league, String configPath){
public TLWMatchdaysCreator(int season, int league, String configPath){
this.season = season;
this.league = league;
TLWFootballMatchesCreator matchesCreator = new TLWFootballMatchesCreator(2021, 1, configPath);
TLWMatchesCreatorFootball matchesCreator = new TLWMatchesCreatorFootball(2021, 1, configPath);
this.matches = matchesCreator.getMatches();
JSONParser jsonParser = new JSONParser();

View 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;
}
}

View File

@@ -15,7 +15,7 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class TLWFootballMatchesCreator {
public class TLWMatchesCreatorFootball extends TLWMatchesCreatorBase {
int season;
int league;
@@ -25,20 +25,17 @@ public class TLWFootballMatchesCreator {
int nextMatchNo = 1;
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.league = league;
conn = new APIFootballConnector(season - 1);
this.conn = new APIFootballConnector(season - 1);
URL url = Resources.getResource(season + "\\" + configFileName);
String jsonConfig = null;
this.TLWMatches = new ArrayList<>();
try {
JSONParser jsonParser = new JSONParser();
jsonConfig = Resources.toString(url, StandardCharsets.UTF_8);
@@ -60,7 +57,7 @@ public class TLWFootballMatchesCreator {
for(int i = 0; i < this.matchdayConfig.size(); i++) {
int TLWMatchday = ((Long) ((JSONObject) this.matchdayConfig.get(i)).get("TLWMatchday")).intValue();
JSONArray matchesConfig = (JSONArray)((JSONObject) this.matchdayConfig.get(i)).get("matchesConfig");
ArrayList<APIFootballMatch> APIFootballMatches = getMatchesForMatchday(matchesConfig);
ArrayList<APIFootballMatch> APIFootballMatches = getAPIFootballMatchesForMatchday(matchesConfig);
int tempNumberOfMatchesBackup = this.matchesPerMatchday;
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<>();
for (Object singleConfigObject : config) {
JSONObject singleConfig = (JSONObject) singleConfigObject;
@@ -140,52 +137,4 @@ public class TLWFootballMatchesCreator {
long diffDays = diffTime / (1000 * 60 * 60 * 24);
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;
}
}

View File

@@ -11,18 +11,17 @@ import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
public class TLWTipperMatchesCreator {
public class TLWMatchesCreatorTipperLeague extends TLWMatchesCreatorBase {
int season;
int league;
ArrayList<TLWMatch> TLWMatches;
JSONArray matchPairingConfig;
JSONObject tipperList;
JSONArray tipperTeamConfig;
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.league = league;
this.matchdays = matchdays;
@@ -31,8 +30,6 @@ public class TLWTipperMatchesCreator {
URL tipperListUrl = Resources.getResource(season + "\\" + configFileName);
URL tipperTeamConfigUrl = Resources.getResource("Tipper_Team_Config.json");
this.TLWMatches = new ArrayList<>();
try {
JSONParser jsonParser = new JSONParser();
@@ -87,50 +84,11 @@ public class TLWTipperMatchesCreator {
}
}
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;
}
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) {
String deliveryDate = "";
for (TLWMatchday matchdayObject : this.matchdays) {

View File

@@ -11,7 +11,7 @@ import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
public class TLWTipperPokalMatchesCreator {
public class TLWMatchesCreatorTipperPokal extends TLWMatchesCreatorBase{
int season;
int league;
@@ -21,7 +21,7 @@ public class TLWTipperPokalMatchesCreator {
JSONArray tipperTeamConfig;
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.league = league;
this.matchdays = matchdays;
@@ -51,16 +51,14 @@ public class TLWTipperPokalMatchesCreator {
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 guestName = this.tipperList.get(String.valueOf(2 * i)).toString();
String homeName = this.tipperList.get(String.valueOf(2 * matchNo - 1)).toString();
String guestName = this.tipperList.get(String.valueOf(2 * matchNo)).toString();
int teamIdHome = getTeamIdFromTipperName(homeName);
int teamIdGuest = getTeamIdFromTipperName(guestName);
int matchNo = i;
String matchDatetime = getDeliveryDateForMatchday(matchday);
TLWMatch tlwMatch = new TLWMatch(this.season, this.league, matchday, matchNo, teamIdHome, teamIdGuest, matchDatetime);
@@ -85,41 +83,6 @@ public class TLWTipperPokalMatchesCreator {
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) {
String deliveryDate = "";
for (TLWMatchday matchdayObject : this.matchdays) {

View File

@@ -17,7 +17,7 @@ public class TLWTeam {
private String groupId;
private int matchday;
public TLWTeam(ResultSet rset) throws SQLException {
public TLWTeam(ResultSet rset) {
final int SEASON = 1;
final int LEAGUE = 2;
final int TEAM_ID = 3;
@@ -27,14 +27,19 @@ public class TLWTeam {
final int GROUP_ID = 7;
final int MATCHDAY = 8;
this.season = Integer.parseInt(rset.getString(SEASON));
this.league = Integer.parseInt(rset.getString(LEAGUE));
this.teamId = Integer.parseInt(rset.getString(TEAM_ID));
this.teamName = rset.getString(TEAM_NAME);
this.teamNameShort = rset.getString(TEAM_NAME_SHORT);
this.teamSymbol = rset.getString(TEAM_SYMBOL);
this.groupId = rset.getString(GROUP_ID);
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
try {
this.season = Integer.parseInt(rset.getString(SEASON));
this.league = Integer.parseInt(rset.getString(LEAGUE));
this.teamId = Integer.parseInt(rset.getString(TEAM_ID));
this.teamName = rset.getString(TEAM_NAME);
this.teamNameShort = rset.getString(TEAM_NAME_SHORT);
this.teamSymbol = rset.getString(TEAM_SYMBOL);
this.groupId = rset.getString(GROUP_ID);
this.matchday = Integer.parseInt(rset.getString(MATCHDAY));
} catch (SQLException e) {
/* TODO */
e.printStackTrace();
}
}
public int getSeason() {

View File

@@ -4,13 +4,13 @@ import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.Set;
public class TLWTeamsPokalCreator {
public class TLWTeamsCreator {
int season;
int league;
ArrayList<TLWMatch> matches;
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.league = league;
this.matches = matches;

View File

@@ -3,6 +3,7 @@ package de.jeyp91.tippliga;
import de.jeyp91.tippliga.TLWMatch;
import de.jeyp91.tippliga.TLWTeam;
import javax.xml.transform.Result;
import java.util.ArrayList;
import java.sql.Connection;
import java.sql.DriverManager;
@@ -34,66 +35,67 @@ public class TippligaSQLConnector {
public ArrayList<TLWTeam> getTeamsBySeasonAndLeague(String season, String 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;
}
public ArrayList<TLWTeam> getTeamsById(String id) {
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + ";";
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();
String queryString = "SELECT * FROM `phpbb_footb_teams` WHERE `team_id` = " + id + " ORDER BY `season` DESC;";
ArrayList<TLWTeam> teams = new ArrayList<>();
for (ResultSet rset : executeQuery(queryString)) {
teams.add(new TLWTeam(rset));
}
return teams;
}
public ArrayList<TLWMatch> getMatchesBySeasonAndLeague(String season, String league) {
String queryString = "SELECT * FROM `phpbb_footb_matches` WHERE `season` = " + season + " AND `league` = " + league + ";";
Statement stmt = null;
ResultSet rset = null;
ArrayList<TLWMatch> matches = new ArrayList<TLWMatch>();
try {
stmt = con.createStatement();
rset = stmt.executeQuery(queryString);
while (rset.next()) {
matches.add(new TLWMatch(rset));
}
} catch (SQLException throwables) {
throwables.printStackTrace();
private ArrayList<TLWMatch> getMatches(String queryString) {
ArrayList<TLWMatch> matches = new ArrayList<>();
for (ResultSet rset : executeQuery(queryString)) {
matches.add(new TLWMatch(rset));
}
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) {
String queryString = "UPDATE `phpbb_footb_matches` "
+ "SET match_datetime = " + datetime
+ " WHERE `season` = " + season
+ " AND `league` = " + league
+ " 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;
}
}

View File

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

View File

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

View File

@@ -6,11 +6,11 @@ import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
public class TLWFootballMatchesCreatorTest {
public class TLWMatchesCreatorFootballTest {
@Test
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();
assertEquals((Integer) 1, matches.get(0).getMatchNo());
@@ -20,14 +20,14 @@ public class TLWFootballMatchesCreatorTest {
@Test
public void getMatchesTippligaSqlTest() {
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(2021, 2, "Tippliga.json");
TLWMatchesCreatorFootball creator = new TLWMatchesCreatorFootball(2021, 2, "Tippliga.json");
String sql = creator.getSQLInsertString();
System.out.println(sql);
}
@Test
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();
System.out.println(sql);
}

View File

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

View File

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

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

View File

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

View File

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

View File

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

View File

@@ -1,8 +1,5 @@
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.Test;
@@ -53,7 +50,7 @@ public class TippligaSQLConnectorTest {
@Test
public void getMatchesBySeasonAndLeague() {
ArrayList<TLWMatch> matches = tl.getMatchesBySeasonAndLeague("2020", "1");
ArrayList<TLWMatch> matches = tl.getMatches("2020", "1");
assertEquals(468, matches.size());