Add support for google calendar
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user