@@ -7,14 +7,23 @@ package at.bitfire.ical4android.validation
77import at.bitfire.ical4android.Event
88import at.bitfire.ical4android.util.DateUtils
99import net.fortuna.ical4j.model.Date
10+ import net.fortuna.ical4j.model.DateList
1011import net.fortuna.ical4j.model.DateTime
12+ import net.fortuna.ical4j.model.Property
13+ import net.fortuna.ical4j.model.PropertyList
1114import net.fortuna.ical4j.model.Recur
15+ import net.fortuna.ical4j.model.TimeZone
1216import net.fortuna.ical4j.model.TimeZoneRegistry
1317import net.fortuna.ical4j.model.TimeZoneRegistryFactory
18+ import net.fortuna.ical4j.model.component.VTimeZone
19+ import net.fortuna.ical4j.model.parameter.Value
1420import net.fortuna.ical4j.model.property.DtEnd
1521import net.fortuna.ical4j.model.property.DtStart
22+ import net.fortuna.ical4j.model.property.ExDate
23+ import net.fortuna.ical4j.model.property.RDate
1624import net.fortuna.ical4j.model.property.RRule
1725import net.fortuna.ical4j.model.property.RecurrenceId
26+ import net.fortuna.ical4j.model.property.TzId
1827import org.junit.Assert.assertArrayEquals
1928import org.junit.Assert.assertEquals
2029import org.junit.Assert.assertFalse
@@ -394,14 +403,48 @@ class EventValidatorTest {
394403 .interval(2 )
395404 .build())
396405 ))
406+ rDates.addAll(listOf (
407+ RDate (DateList (Value (" 19970714T123000Z" ))),
408+ RDate (
409+ DateList (
410+ Value (" 19960403T020000Z" ),
411+ TimeZone (
412+ VTimeZone (
413+ PropertyList <Property >(1 ).apply {
414+ add(TzId (" US-EASTERN" ))
415+ }
416+ )
417+ )
418+ )
419+ )
420+ ))
421+ exDates.addAll(listOf (
422+ ExDate (DateList (Value (" 19970714T123000Z" ))),
423+ ExDate (
424+ DateList (
425+ Value (" 19960403T020000Z" ),
426+ TimeZone (
427+ VTimeZone (
428+ PropertyList <Property >(1 ).apply {
429+ add(TzId (" US-EASTERN" ))
430+ }
431+ )
432+ )
433+ )
434+ )
435+ ))
397436 uid = " 76c08fb1-99a3-41cf-b482-2d3b06648814"
398437 })
399438 }
400439 assertTrue(manualEvent.rRules.size == 1 )
401- assertTrue(manualEvent.exceptions.first.rRules.size == 2 )
402- EventValidator .removeRRulesOfExceptions(manualEvent.exceptions) // Repair the manually created event
440+ assertTrue(manualEvent.exceptions.first().rRules.size == 2 )
441+ assertTrue(manualEvent.exceptions.first().rDates.size == 2 )
442+ assertTrue(manualEvent.exceptions.first().exDates.size == 2 )
443+ EventValidator .removeRecurrenceOfExceptions(manualEvent.exceptions) // Repair the manually created event
403444 assertTrue(manualEvent.rRules.size == 1 )
404- assertTrue(manualEvent.exceptions.first.rRules.isEmpty())
445+ assertTrue(manualEvent.exceptions.first().rRules.isEmpty())
446+ assertTrue(manualEvent.exceptions.first().rDates.isEmpty())
447+ assertTrue(manualEvent.exceptions.first().exDates.isEmpty())
405448
406449 // Test event from reader, the reader will repair the event itself
407450 val eventFromReader = Event .eventsFromReader(StringReader (
@@ -422,14 +465,16 @@ class EventValidatorTest {
422465 " SUMMARY:exception of recurring event\n " +
423466 " RRULE:FREQ=DAILY;COUNT=6;INTERVAL=2\n " + // but remove this one
424467 " RRULE:FREQ=DAILY;COUNT=6;INTERVAL=2\n " + // and this one
468+ " EXDATE;TZID=Europe/Paris:20240704T193000\n " + // also this
469+ " RDATE;TZID=US-EASTERN:19970714T083000\n " + // and this
425470 " DTSTART;TZID=Europe/Paris:20240221T110000\n " +
426471 " DTEND;TZID=Europe/Paris:20240221T120000\n " +
427472 " UID:76c08fb1-99a3-41cf-b482-2d3b06648814\n " +
428473 " END:VEVENT\n " +
429474 " END:VCALENDAR"
430475 )).first()
431476 assertTrue(eventFromReader.rRules.size == 1 )
432- assertTrue(eventFromReader.exceptions.first.rRules.isEmpty())
477+ assertTrue(eventFromReader.exceptions.first() .rRules.isEmpty())
433478 }
434479
435480 @Test
0 commit comments