Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jul 18, 2020
1 parent 36014f7 commit d05140d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 16 deletions.
Expand Up @@ -96,7 +96,7 @@ class ComponentGroupTest extends Specification {
def components = new ComponentList<VEvent>([event, rev1, rev2, rev3])

when: 'recurrence instances are calculated'
Period period = Period.parse '20101113T000000/P3W'
Period period = Period.parse '20101113/P3W'
def recurrences = new ComponentGroup(components.all, uid).calculateRecurrenceSet(period)

then: 'the expected number of recurrences are returned'
Expand Down
28 changes: 13 additions & 15 deletions src/test/groovy/net/fortuna/ical4j/model/ComponentSpec.groovy
Expand Up @@ -3,37 +3,35 @@ package net.fortuna.ical4j.model
import net.fortuna.ical4j.model.component.VEvent
import spock.lang.Specification

import java.time.Instant

class ComponentSpec extends Specification {

def "test Component.calculateRecurrenceSet"() {
given: 'a component'
VEvent component = new ContentBuilder().with {
vevent {
dtstart '20140630T000000Z'
dtend '20140630T010000Z'
dtstart '20140630T000000', parameters: parameters { tzid_ 'Australia/Melbourne' }
dtend '20140630T010000', parameters: parameters { tzid_ 'Australia/Melbourne' }
rrule 'FREQ=MONTHLY'
}
}
and: 'an expected list of periods'
def expectedPeriods = new PeriodList<Instant>(CalendarDateFormat.UTC_DATE_TIME_FORMAT)
TreeSet expectedPeriods = []
expectedPeriods.addAll(expectedResults.collect { Period.parse(it)})

expect: 'calculate recurrence set returns the expected results'
component.calculateRecurrenceSet(period) == expectedPeriods

where:
period | expectedResults
Period.parse('20140630T000000Z/20150630T000000Z') | ['20140630T000000Z/PT1H','20140730T000000Z/PT1H',
'20140830T000000Z/PT1H',
'20140930T000000Z/PT1H',
'20141030T000000Z/PT1H',
'20141130T000000Z/PT1H',
'20141230T000000Z/PT1H',
'20150130T000000Z/PT1H',
'20150330T000000Z/PT1H',
'20150430T000000Z/PT1H',
'20150530T000000Z/PT1H', '20150630T000000Z/PT1H']
Period.parse('20140629T000000Z/20150630T000000Z') | ['20140630T000000/PT1H','20140730T000000/PT1H',
'20140830T000000/PT1H',
'20140930T000000/PT1H',
'20141030T000000/PT1H',
'20141130T000000/PT1H',
'20141230T000000/PT1H',
'20150130T000000/PT1H',
'20150330T000000/PT1H',
'20150430T000000/PT1H',
'20150530T000000/PT1H', '20150630T000000/PT1H']
}
}

0 comments on commit d05140d

Please sign in to comment.