@@ -7,14 +7,23 @@ package at.bitfire.ical4android.validation
7
7
import at.bitfire.ical4android.Event
8
8
import at.bitfire.ical4android.util.DateUtils
9
9
import net.fortuna.ical4j.model.Date
10
+ import net.fortuna.ical4j.model.DateList
10
11
import net.fortuna.ical4j.model.DateTime
12
+ import net.fortuna.ical4j.model.Property
13
+ import net.fortuna.ical4j.model.PropertyList
11
14
import net.fortuna.ical4j.model.Recur
15
+ import net.fortuna.ical4j.model.TimeZone
12
16
import net.fortuna.ical4j.model.TimeZoneRegistry
13
17
import net.fortuna.ical4j.model.TimeZoneRegistryFactory
18
+ import net.fortuna.ical4j.model.component.VTimeZone
19
+ import net.fortuna.ical4j.model.parameter.Value
14
20
import net.fortuna.ical4j.model.property.DtEnd
15
21
import net.fortuna.ical4j.model.property.DtStart
22
+ import net.fortuna.ical4j.model.property.ExDate
23
+ import net.fortuna.ical4j.model.property.RDate
16
24
import net.fortuna.ical4j.model.property.RRule
17
25
import net.fortuna.ical4j.model.property.RecurrenceId
26
+ import net.fortuna.ical4j.model.property.TzId
18
27
import org.junit.Assert.assertArrayEquals
19
28
import org.junit.Assert.assertEquals
20
29
import org.junit.Assert.assertFalse
@@ -394,14 +403,48 @@ class EventValidatorTest {
394
403
.interval(2 )
395
404
.build())
396
405
))
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
+ ))
397
436
uid = " 76c08fb1-99a3-41cf-b482-2d3b06648814"
398
437
})
399
438
}
400
439
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
403
444
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())
405
448
406
449
// Test event from reader, the reader will repair the event itself
407
450
val eventFromReader = Event .eventsFromReader(StringReader (
@@ -422,14 +465,16 @@ class EventValidatorTest {
422
465
" SUMMARY:exception of recurring event\n " +
423
466
" RRULE:FREQ=DAILY;COUNT=6;INTERVAL=2\n " + // but remove this one
424
467
" 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
425
470
" DTSTART;TZID=Europe/Paris:20240221T110000\n " +
426
471
" DTEND;TZID=Europe/Paris:20240221T120000\n " +
427
472
" UID:76c08fb1-99a3-41cf-b482-2d3b06648814\n " +
428
473
" END:VEVENT\n " +
429
474
" END:VCALENDAR"
430
475
)).first()
431
476
assertTrue(eventFromReader.rRules.size == 1 )
432
- assertTrue(eventFromReader.exceptions.first.rRules.isEmpty())
477
+ assertTrue(eventFromReader.exceptions.first() .rRules.isEmpty())
433
478
}
434
479
435
480
@Test
0 commit comments