Update dependencies and add support for google calendar html event description

This commit is contained in:
2022-11-07 18:00:29 +01:00
parent 87c3dd21c6
commit dac3f31a37
3 changed files with 34 additions and 22 deletions

View File

@@ -6,8 +6,8 @@ apply plugin: 'java'
apply plugin: 'application'
mainClassName = 'App'
sourceCompatibility = 11
targetCompatibility = 11
sourceCompatibility = 14
targetCompatibility = 14
version = '1.0'
compileJava.options.encoding = 'UTF-8'
compileTestJava.options.encoding = "UTF-8"
@@ -18,15 +18,15 @@ repositories {
}
dependencies {
implementation 'mysql:mysql-connector-java:8.0.29'
implementation 'mysql:mysql-connector-java:8.0.30'
implementation 'org.apache.httpcomponents:httpclient:4.5.13'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation 'com.google.code.gson:gson:2.9.0'
implementation 'com.google.code.gson:gson:2.10'
implementation platform('com.amazonaws:aws-java-sdk-bom:1.11.896')
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.239'
implementation 'com.google.api-client:google-api-client:1.33.2'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.33.1'
implementation 'com.google.apis:google-api-services-calendar:v3-rev20211026-1.32.1'
implementation 'com.amazonaws:aws-java-sdk-s3:1.12.332'
implementation 'com.google.api-client:google-api-client:2.0.0'
implementation 'com.google.oauth-client:google-oauth-client-jetty:1.34.1'
implementation 'com.google.apis:google-api-services-calendar:v3-rev20220715-2.0.0'
testImplementation 'junit:junit:4.13.2'
compile 'com.google.guava:guava:31.1-jre'
compile group: 'commons-cli', name: 'commons-cli', version: '1.3.1'

View File

@@ -59,8 +59,14 @@ public class TippligaGoogleEventManager {
public static Event findEvent(List<Event> allEvents, Integer season, Integer league, Integer matchday, Integer deliveryDateNumber) {
String description = getDescription(season, league, matchday, deliveryDateNumber);
String descriptionHtml = getDescriptionHTML(season, league, matchday, deliveryDateNumber);
for (Event event : allEvents) {
if (event.getDescription().replaceAll("\\s+","").equals(description.replaceAll("\\s+",""))) return event;
if (
(event.getDescription().replaceAll("\\s+","").equals(description.replaceAll("\\s+","")))
|| event.getDescription().equals(descriptionHtml)
) {
return event;
}
}
return null;
}
@@ -151,11 +157,7 @@ public class TippligaGoogleEventManager {
// Set reminder to 12 hours before
Event.Reminders reminders = new Event.Reminders();
reminders.setUseDefault(false);
EventReminder[] reminderOverrides = new EventReminder[] {
new EventReminder().setMethod("popup").setMinutes(12 * 60),
};
reminders.setOverrides(Arrays.asList(reminderOverrides));
reminders.setUseDefault(true);
return new Event()
.setSummary(summary)
@@ -171,6 +173,12 @@ public class TippligaGoogleEventManager {
return "Saison: " + season + "\n" + "Liga: " + league + "\n" + "Spieltag: " + matchday + "\n" + "Abgabeschluss: " + deliverDateNumber;
}
private static String getDescriptionHTML(Integer season, Integer league, Integer matchday, Integer deliverDateNumber) {
league = league == 2 ? 1 : league;
return "<html-blob>Saison: " + season + "<br>" + "Liga: " + league + "<br>" + "Spieltag: " + matchday + "<br>" + "Abgabeschluss: " + deliverDateNumber + "</html-blob>";
}
public static void updateAllMatchdays(ArrayList<TLWMatchday> matchdays) {
matchdays.forEach(tlwMatchday -> {
createOrUpdateEvent(tlwMatchday, tlwMatchday.getDeliveryDate(), 1);

View File

@@ -18,7 +18,7 @@ public class TippligaGoogleEventManagerTest {
@Test
public void getAllEventsStartingFromDateTimeTest()
{
DateTime dateTime = new DateTime("2020-01-01T00:00:00");
DateTime dateTime = new DateTime("2022-11-07T00:00:00");
List<Event> events = getAllEventsStartingFromDateTime(dateTime);
@@ -28,7 +28,7 @@ public class TippligaGoogleEventManagerTest {
assertEquals(startExpected, startActual);
assertEquals("Tippliga 21. Spieltag tippen!", events.get(1).getSummary());
startExpected = new DateTime("2020-01-24T20:30:00+01:00");
startExpected = new DateTime("2020- 01-24T20:30:00+01:00");
startActual = events.get(1).getStart().getDateTime();
assertEquals(startExpected, startActual);
}
@@ -44,7 +44,7 @@ public class TippligaGoogleEventManagerTest {
@Test
public void findEventTest() {
List<Event> allEvents = getAllEvents(2023);
Event event = findEvent(allEvents, 2023, 1, 1, 2);
Event event = findEvent(allEvents, 2023, 1, 15, 1);
assert event != null;
assertEquals(event.getStart().size(), 2);
}
@@ -52,11 +52,15 @@ public class TippligaGoogleEventManagerTest {
@Test
public void updateEventTest() {
List<Event> 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);
assert event != null;
updateEvent(event, matchday, matchday.getDeliveryDate(), 1);
assertEquals(event.size(), 18);
Event event1 = findEvent(allEvents, 2023, 1, 15, 1);
Event event2 = findEvent(allEvents, 2023, 1, 15, 2);
TLWMatchday matchday = new TLWMatchday(2023, 1, 15, 0, "2022-11-08 18:30:00", "2022-11-09 18:30:00", "", "15. Spieltag", 12);
assert event1 != null;
assert event2 != null;
updateEvent(event1, matchday, matchday.getDeliveryDate(), 1);
updateEvent(event2, matchday, matchday.getDeliveryDate2(), 2);
assertEquals(event1.size(), 18);
assertEquals(event2.size(), 18);
}
@Test