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 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 matchdays = creator.getMatchdays(); matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday); } @Test public void findEventTest() { List allEvents = getAllEvents(2023); Event event = findEvent(allEvents, 2023, 1, 1, 2); assertEquals(event.getStart(), 2); } @Test public void updateEventTest() { List allEvents = getAllEvents(2023); Event event = findEvent(allEvents, 2023, 1, 1, 1); TLWMatchday matchday = new TLWMatchday(2023, 1, 1, 0, "2022-08-06 20:30:00", "", "", "1. Spieltag", 12); updateEvent(event, matchday, matchday.getDeliveryDate(), 1); assertEquals(event.size(), 18); } @Test public void createOrUpdateEventsForMatchdayWTLPokalTest() { TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 48, "WTL-Pokal"); ArrayList matchdays = creator.getMatchdays(); // createOrUpdateEventsForMatchday(matchdays.get(4)); matchdays.forEach(TippligaGoogleEventManager::createOrUpdateEventsForMatchday); } @Test public void createOrUpdateEventTest() { TLWMatchday matchday = new TLWMatchday(2023, 1, 1, 0, "2022-08-05 20:30:00", "", "", "1. Spieltag", 12); createOrUpdateEvent(matchday, matchday.getDeliveryDate(), 1); } @Test public void deleteEventTippligaTest() { TLWMatchdaysCreator creator = new TLWMatchdaysCreator(2022, 1, "Tippliga"); ArrayList 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 matchdays = creator.getMatchdays(); matchdays.forEach(tlwMatchday -> { TippligaGoogleEventManager.deleteEvent(tlwMatchday, 1); TippligaGoogleEventManager.deleteEvent(tlwMatchday, 2); TippligaGoogleEventManager.deleteEvent(tlwMatchday, 3); }); } }