Skip to content

Commit

Permalink
Removed redundant tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Sep 24, 2019
1 parent f4fb606 commit 344c91b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 40 deletions.
Expand Up @@ -31,10 +31,10 @@
*/
package net.fortuna.ical4j.model.property


import net.fortuna.ical4j.model.CalendarDateFormat
import spock.lang.Specification

import java.time.ZonedDateTime
import java.time.Period

class TriggerSpec extends Specification {

Expand All @@ -43,40 +43,8 @@ class TriggerSpec extends Specification {
new Trigger(value).value == expectedValue

where:
value | expectedValue
java.time.Period.ZERO | 'P0D'
net.fortuna.ical4j.model.CalendarDateFormat.UTC_DATE_TIME_FORMAT.parse('20110131T012647Z') | '20110131T012647Z'
value | expectedValue
Period.ZERO | 'P0D'
CalendarDateFormat.UTC_DATE_TIME_FORMAT.parse('20110131T012647Z') | '20110131T012647Z'
}

def 'verify trigger date-time converts to UTC'() {
setup: 'override platform default timezone'
def originalPlatformTz = TimeZone.default
TimeZone.default = TimeZone.getTimeZone('Australia/Melbourne')

expect: 'derived value is expected'
new Trigger(net.fortuna.ical4j.model.CalendarDateFormat.UTC_DATE_TIME_FORMAT.parse(value)).value == expectedValue

cleanup: 'restore platform default timezone'
TimeZone.default = originalPlatformTz

where:
value | expectedValue
'20110131T012647Z' | '20110130T142647Z'
}

def 'verify original date-time is not modified'() {
given: 'a date in a non-UTC timezone'
def originalTzDefault = TimeZone.default
TimeZone.default = TimeZone.getTimeZone('Australia/Melbourne')
ZonedDateTime dateTime = ZonedDateTime.now()

when: 'the date is used to construct a trigger'
Trigger trigger = [dateTime.toInstant()]

then: "the original date's timezone is not modified"
assert !dateTime.utc

cleanup:
TimeZone.default = originalTzDefault
}
}
Expand Up @@ -31,11 +31,11 @@
*/
package net.fortuna.ical4j.model.property;

import java.text.ParseException;

import junit.framework.TestSuite;
import net.fortuna.ical4j.model.PropertyTest;

import java.text.ParseException;

/**
* $Id$
*
Expand Down Expand Up @@ -69,7 +69,6 @@ public static TestSuite suite() throws ParseException {
TestSuite suite = new TestSuite();
LastModified modified = new LastModified("20081124T090000");
suite.addTest(new LastModifiedTest(modified, "20081124T090000"));
suite.addTest(new LastModifiedTest("testValidationException", modified));

modified = new LastModified("20081124T090000Z");
suite.addTest(new LastModifiedTest("testValidation", modified));
Expand Down

0 comments on commit 344c91b

Please sign in to comment.