Add support for google calendar
This commit is contained in:
@@ -1,36 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
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 de.jeyp91.tippliga.TLWMatchdaysCreator;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static de.jeyp91.googlecalendar.TippligaGoogleEventManager.*;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TippligaGoogleEventManagerTest {
|
||||
|
||||
@Test
|
||||
public void getAllEventsStartingFromDateTimeTest()
|
||||
{
|
||||
DateTime dateTime = new DateTime("2020-01-01T00:00:00");
|
||||
|
||||
List<Event> events = getAllEventsStartingFromDateTime(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 createOrUpdateEventsForMatchdayTippligaTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void createOrUpdateEventsForMatchdayWTLPokalTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
// createOrUpdateEventsForMatchday(matchdays.get(4));
|
||||
|
||||
matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void updateEventTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
createOrUpdateEvent(matchdays.get(28), matchdays.get(28).getDeliveryDate(), 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteEventTippligaTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 1, "Tippliga");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(tlwMatchday -> {
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 1);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 2);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 3);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void deleteEventWTLPokalTest() {
|
||||
TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 48, "WTL-Pokal");
|
||||
ArrayList<TLWMatchday> matchdays = creator.getMatchdays();
|
||||
|
||||
matchdays.forEach(tlwMatchday -> {
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 1);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 2);
|
||||
TippligaGoogleEventManager.deleteEvent(tlwMatchday, 3);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ public class TLWMatchesUpdaterFootballTest {
|
||||
|
||||
@Test
|
||||
public void getUpdateSqlTest1() {
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2021, 1, "Tippliga");
|
||||
TLWMatchesUpdaterFootball updater = new TLWMatchesUpdaterFootball(2022, 1, "Tippliga");
|
||||
String sql = updater.getUpdateSQL();
|
||||
|
||||
// System.out.println(sql);
|
||||
|
||||
Reference in New Issue
Block a user