First version with ability to create database for new season

This commit is contained in:
2020-09-27 19:05:20 +02:00
parent b97e15be7d
commit 283efc775b
75 changed files with 106536 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package de.jeyp91;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TeamIDMatcherTest {
@Test
public void getOpenLigaDbIdFromTippligaIdTest() {
int openligaDBID;
openligaDBID = TeamIDMatcher.getOpenLigaDbIdFromTippligaId(1);
assertEquals(40, openligaDBID);
openligaDBID = TeamIDMatcher.getOpenLigaDbIdFromTippligaId(16);
assertEquals(54, openligaDBID);
openligaDBID = TeamIDMatcher.getOpenLigaDbIdFromTippligaId(12);
assertEquals(7, openligaDBID);
}
@Test
public void getTippligaIdFromOpenLigaDbIdTest() {
int openligaDBID;
openligaDBID = TeamIDMatcher.getTippligaIdFromOpenLigaDbId(40);
assertEquals(1, openligaDBID);
openligaDBID = TeamIDMatcher.getTippligaIdFromOpenLigaDbId(54);
assertEquals(16, openligaDBID);
openligaDBID = TeamIDMatcher.getTippligaIdFromOpenLigaDbId(7);
assertEquals(12, openligaDBID);
}
}

View File

@@ -0,0 +1,17 @@
package de.jeyp91.apifootball;
import de.jeyp91.openligadb.OpenLigaDBConnector;
import org.junit.Test;
import java.util.ArrayList;
public class APIFootballConnectorTest {
@Test
public void APITestGetMatchDataOfMatchdayBundesliga() {
APIFootballConnector apiFootballConnector = new APIFootballConnector(2020);
ArrayList<APIFootballMatch> matchesOfMatchday = apiFootballConnector.getMatchDataByLeagueAndMatchday(2677, 1);
assert matchesOfMatchday.get(0).getTeamIdHome() == 744;
assert matchesOfMatchday.get(0).getTeamIdGuest() == 159;
}
}

View File

@@ -0,0 +1,36 @@
package de.jeyp91.googlecalendar;
import com.google.api.client.util.DateTime;
import com.google.api.services.calendar.model.Event;
import de.jeyp91.tippliga.TLWMatchday;
import org.junit.Test;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class GoogleCalendarConnectorTest {
@Test
public void getAllEventsStartingFromDateTimeTest()
{
DateTime dateTime = new DateTime("2020-01-01T00:00:00");
List<Event> events = GoogleCalendarConnector.getAllEventsStartingFromDateTime(1, dateTime);
assertEquals("Tippliga 20. Spieltag tippen!", events.get(0).getSummary());
DateTime startExpected = new DateTime("2020-01-17T20:30:00+01:00");
DateTime startActual = events.get(0).getStart().getDateTime();
assertEquals(startExpected, startActual);
assertEquals("Tippliga 21. Spieltag tippen!", events.get(1).getSummary());
startExpected = new DateTime("2020-01-24T20:30:00+01:00");
startActual = events.get(1).getStart().getDateTime();
assertEquals(startExpected, startActual);
}
@Test
public void createEventTest() {
TLWMatchday matchday = new TLWMatchday(2020, 1, 1, 0, "2020-07-01 20:30:00", "", "", "", 1);
GoogleCalendarConnector.createNewEvent(matchday);
}
}

View File

@@ -0,0 +1,77 @@
package de.jeyp91.openligadb;
import org.junit.Test;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class OpenLigaDBConnectorTest {
@Test
public void APITestGetMatchDataOfMatchdayBundesliga() {
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
ArrayList<OpenLigaDBMatch> matches = openLigaDBConnector.getMatchDataOfMatchday(2020, "bl1", 1);
assertEquals(9, matches.size());
OpenLigaDBMatch match;
match = matches.get(0);
assertEquals((Integer) 55277, match.getMatchId());
assertEquals((Integer) 40, match.getTeamIdHome());
assertEquals((Integer) 54, match.getTeamIdGuest());
assertEquals((Integer) 2020, match.getSeason());
assertEquals("2019-08-16T20:30:00", match.getMatchDateTime());
assertEquals((Integer) 1, match.getMatchday());
assertEquals((Integer) 2, match.getGoalsHome());
assertEquals((Integer) 2, match.getGoalsGuest());
assertTrue(match.getMatchIsFinished());
match = matches.get(1);
assertEquals((Integer) 55278, match.getMatchId());
assertEquals((Integer) 7, match.getTeamIdHome());
assertEquals((Integer) 95, match.getTeamIdGuest());
assertEquals((Integer) 2020, match.getSeason());
assertEquals("2019-08-17T15:30:00", match.getMatchDateTime());
assertEquals((Integer) 1, match.getMatchday());
assertEquals((Integer) 5, match.getGoalsHome());
assertEquals((Integer) 1, match.getGoalsGuest());
assertTrue(match.getMatchIsFinished());
}
@Test
public void APITestGetMatchDataOfMatchdayDFBPokal() {
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
ArrayList<OpenLigaDBMatch> matches = openLigaDBConnector.getMatchDataOfMatchday(2020, "dfb2019", 1);
assert matches.size() == 32;
OpenLigaDBMatch match = matches.get(0);
assertEquals((Integer) 54926, match.getMatchId());
assertEquals((Integer) 563, match.getTeamIdHome());
assertEquals((Integer) 7, match.getTeamIdGuest());
assertEquals((Integer) 2020, match.getSeason());
assertEquals("2019-08-09T20:45:00", match.getMatchDateTime());
assertEquals((Integer) 1, match.getMatchday());
assertEquals((Integer) 0, match.getGoalsHome());
assertEquals((Integer) 2, match.getGoalsGuest());
assertTrue(match.getMatchIsFinished());
}
@Test
public void APITestGetMatchDataOfSingleMatch() {
OpenLigaDBConnector openLigaDBConnector = new OpenLigaDBConnector();
OpenLigaDBMatch match = openLigaDBConnector.getMatchDataOfSingleMatch(55583);
assertEquals((Integer) 55583, match.getMatchId());
assertEquals((Integer) 16, match.getTeamIdHome());
assertEquals((Integer) 55, match.getTeamIdGuest());
assertEquals((Integer) 2020, match.getSeason());
assertEquals("2019-07-26T20:30:00", match.getMatchDateTime());
assertEquals((Integer) 1, match.getMatchday());
assertEquals((Integer) 2, match.getGoalsHome());
assertEquals((Integer) 1, match.getGoalsGuest());
assertTrue(match.getMatchIsFinished());
}
}

View File

@@ -0,0 +1,43 @@
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,34 @@
package de.jeyp91.tippliga;
import org.junit.Test;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
public class TLWFootballMatchesCreatorTest {
@Test
public void getMatchesTest() {
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(2021, 1, "WTL_Pokal.json");
ArrayList<TLWMatch> matches = creator.getMatches();
assertEquals((Integer) 1, matches.get(0).getMatchNo());
assertEquals((Integer) 11, matches.get(10).getMatchNo());
System.out.println(matches.get(0).getSQLQueryReplace());
}
@Test
public void getMatchesTippligaSqlTest() {
TLWFootballMatchesCreator creator = new TLWFootballMatchesCreator(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");
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 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

@@ -0,0 +1,20 @@
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

@@ -0,0 +1,16 @@
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

@@ -0,0 +1,71 @@
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;
import java.util.ArrayList;
import static org.junit.Assert.assertEquals;
public class TippligaSQLConnectorTest {
TippligaSQLConnector tl;
@Before
public void setup() {
tl = new TippligaSQLConnector();
}
@Test
public void getTeamsBySeasonAndLeagueTest() {
ArrayList<TLWTeam> teams = tl.getTeamsBySeasonAndLeague("2020", "1");
assertEquals(84, teams.size());
assertEquals(2020, teams.get(0).getSeason());
assertEquals(1, teams.get(0).getLeague());
assertEquals(1, teams.get(0).getTeamId());
assertEquals("Bayern München", teams.get(0).getTeamName());
assertEquals("Bayern", teams.get(0).getTeamNameShort());
assertEquals("FC Bayern Muenchen.png", teams.get(0).getTeamSymbol());
assertEquals("", teams.get(0).getGroupId());
assertEquals(0, teams.get(0).getMatchday());
}
@Test
public void getTeamsByIdTest() {
ArrayList<TLWTeam> teams = tl.getTeamsById("1");
assertEquals(39, teams.size());
assertEquals(2011, teams.get(0).getSeason());
assertEquals(1, teams.get(0).getLeague());
assertEquals(1, teams.get(0).getTeamId());
assertEquals("Bayern München", teams.get(0).getTeamName());
assertEquals("Bayern", teams.get(0).getTeamNameShort());
assertEquals("FC Bayern Muenchen.png", teams.get(0).getTeamSymbol());
assertEquals("", teams.get(0).getGroupId());
assertEquals(0, teams.get(0).getMatchday());
}
@Test
public void getMatchesBySeasonAndLeague() {
ArrayList<TLWMatch> matches = tl.getMatchesBySeasonAndLeague("2020", "1");
assertEquals(468, matches.size());
assertEquals((Integer) 2020, matches.get(0).getSeason());
assertEquals((Integer) 1, matches.get(0).getLeague());
assertEquals((Integer) 1, matches.get(0).getMatchday());
assertEquals("", matches.get(0).getGroupId());
assertEquals((Integer) 1, matches.get(0).getMatchNo());
assertEquals("2019-07-26 20:30:00", matches.get(0).getMatchDateTime());
assertEquals((Integer) 8, matches.get(0).getTeamIdHome());
assertEquals((Integer) 15, matches.get(0).getTeamIdGuest());
assertEquals((Integer) 2, matches.get(0).getGoalsHome());
assertEquals((Integer) 1, matches.get(0).getGoalsGuest());
}
}