Skip to content

Commit

Permalink
Test refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
benfortuna committed Jun 12, 2020
1 parent 39ff97e commit ba84b41
Show file tree
Hide file tree
Showing 19 changed files with 27 additions and 52 deletions.
Expand Up @@ -188,7 +188,7 @@ public Available createComponent() {

@Override
public Available createComponent(PropertyList properties) throws URISyntaxException {
return new Available(new PropertyList(properties));
return new Available(properties);
}

@Override
Expand Down
Expand Up @@ -22,9 +22,7 @@ class CalendarBuilderSpec extends Specification {
System.out.println(cal2);
InputStream stream = new ByteArrayInputStream(cal2.getBytes(Charset.forName("UTF-8")));
CalendarBuilder builder = new CalendarBuilder();
Calendar calendar = null;

calendar = builder.build(stream);
Calendar calendar = builder.build(stream);

then: 'the result is as expected'
calendar as String == cal2.replaceAll('\n', '\r\n')
Expand Down
Expand Up @@ -14,7 +14,7 @@ class DurationSpec extends Specification {

where:
value | expectedValue
'P7D' | 'P7D'
'P7D' | 'P1W'
'-P1W' | '-P1W'
'P52W' | 'P52W'
'PT10M' | 'PT10M'
Expand Down
Expand Up @@ -14,7 +14,7 @@ class TzIdSpec extends Specification {
where:
tzIdString | expectedString
'Australia/Melbourne' | 'Australia/Melbourne'
'UTC+10' | 'UTC+10:00'
'UTC+10' | 'UTC+10'
}

def 'test custom zone id instance creation'() {
Expand All @@ -26,7 +26,7 @@ class TzIdSpec extends Specification {
where:
tzIdString | expectedString
'/tzurl.org/Australia/Melbourne' | '/tzurl.org/Australia/Melbourne'
'Canberra, Melbourne, Sydney' | 'Canberra, Melbourne, Sydney'
'Canberra, Melbourne, Sydney' | 'Canberra\\, Melbourne\\, Sydney'
}

def 'test unsuccessfull instance creation'() {
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/net/fortuna/ical4j/filter/FilterTest.java
Expand Up @@ -138,11 +138,11 @@ public static TestSuite suite() throws FileNotFoundException, IOException, Parse
calendar.getComponents().add(e2);
calendar.getComponents().add(e3);

Predicate<Component> organiserRuleMatch = new HasPropertyRule(organizer);
Predicate<Component> attendee1RuleMatch = new HasPropertyRule(a1);
Predicate<Component> organiserRuleMatch = new HasPropertyRule<>(organizer);
Predicate<Component> attendee1RuleMatch = new HasPropertyRule<>(a1);

Predicate<Component> organiserRuleNoMatch = new HasPropertyRule(new Organizer(new URI("Mailto:X@example.com")));
Predicate<Component> attendeeRuleNoMatch = new HasPropertyRule(new Attendee(new URI("Mailto:X@example.com")));
Predicate<Component> organiserRuleNoMatch = new HasPropertyRule<>(new Organizer(new URI("Mailto:X@example.com")));
Predicate<Component> attendeeRuleNoMatch = new HasPropertyRule<>(new Attendee(new URI("Mailto:X@example.com")));

TestSuite suite = new TestSuite();
//testFilterMatchAll..
Expand Down
3 changes: 1 addition & 2 deletions src/test/java/net/fortuna/ical4j/filter/PeriodRuleTest.java
Expand Up @@ -97,10 +97,9 @@ protected void tearDown() {
* Test handling of recurrence rules.
* @throws ParserException
* @throws IOException
* @throws ParseException
*/
/*
public void testRecurrenceRules() throws ParserException, IOException, ParseException {
public void testRecurrenceRules() throws ParserException, IOException {
Calendar rCal = Calendars.load("etc/samples/valid/LH1.ics");
Period period = new Period(new DateTime("20060831T000000Z"), new DateTime("20070831T230000Z"));
Filter filter = new Filter(new PeriodRule(period));
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/net/fortuna/ical4j/model/CalendarTest.java
Expand Up @@ -40,9 +40,7 @@
import org.junit.Before;
import org.junit.Test;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.time.DayOfWeek;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoField;
Expand Down Expand Up @@ -80,7 +78,7 @@ public void testValid() throws ValidationException {
}

@Test
public void testValid2() throws ParseException, IOException, URISyntaxException {
public void testValid2() throws URISyntaxException {
TzId tzParam = new TzId(TimeZoneRegistry.getGlobalZoneId("Australia/Melbourne").getId());

// Add events, etc..
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/net/fortuna/ical4j/model/ComponentTest.java
Expand Up @@ -33,7 +33,6 @@

import junit.framework.TestCase;
import junit.framework.TestSuite;
import net.fortuna.ical4j.data.ParserException;
import net.fortuna.ical4j.model.component.CalendarComponent;
import net.fortuna.ical4j.model.property.DtEnd;
import net.fortuna.ical4j.model.property.DtStart;
Expand All @@ -44,9 +43,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.time.Instant;
import java.time.LocalDate;
import java.time.temporal.Temporal;
Expand Down Expand Up @@ -150,7 +146,7 @@ public void testCalculateRecurrenceSet() {
* @return
*/
@SuppressWarnings("serial")
public static TestSuite suite() throws ValidationException, ParseException, IOException, URISyntaxException, ParserException {
public static TestSuite suite() throws Exception {
TestSuite suite = new TestSuite();

Component component = new Component("test") {
Expand Down
6 changes: 1 addition & 5 deletions src/test/java/net/fortuna/ical4j/model/DateListTest.java
Expand Up @@ -34,8 +34,6 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;

import java.text.ParseException;

/**
* $Id$
*
Expand All @@ -53,7 +51,6 @@ public class DateListTest extends TestCase {
/**
* @param value
* @param expectedSize
* @throws ParseException
*/
public DateListTest(String value, int expectedSize) {
this(DateList.parse(value), expectedSize);
Expand All @@ -78,9 +75,8 @@ public void testSize() {

/**
* @return
* @throws ParseException
*/
public static TestSuite suite() throws ParseException {
public static TestSuite suite() {
TestSuite suite = new TestSuite();
suite.addTest(new DateListTest(new DateList(), 0));
suite.addTest(new DateListTest(new Date().toString(), 1));
Expand Down
4 changes: 1 addition & 3 deletions src/test/java/net/fortuna/ical4j/model/PeriodTest.java
Expand Up @@ -37,7 +37,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand Down Expand Up @@ -413,9 +412,8 @@ public void testIsEmpty() {

/**
* @return
* @throws ParseException
*/
public static Test suite() throws ParseException {
public static Test suite() {
TestSuite suite = new TestSuite();

ZonedDateTime past = ZonedDateTime.now().withYear(1980).withMonth(1).withDayOfMonth(23);
Expand Down
5 changes: 2 additions & 3 deletions src/test/java/net/fortuna/ical4j/model/PropertyTest.java
Expand Up @@ -135,8 +135,7 @@ public Property copy() {
/**
* Test deep copy of properties.
*/
public void testCopy() throws IOException, URISyntaxException,
ParseException {
public void testCopy() throws IOException, URISyntaxException {
Property copy = property.copy();
assertEquals(property, copy);

Expand Down Expand Up @@ -180,7 +179,7 @@ public final void testValidationException() {
* @throws ParseException
*/
@SuppressWarnings("serial")
public void testImmutable() throws IOException, URISyntaxException, ParseException {
public void testImmutable() throws IOException, URISyntaxException {
try {
property.setValue("");
fail("UnsupportedOperationException should be thrown");
Expand Down
Expand Up @@ -67,7 +67,7 @@ public AvailableTest(String testMethod, Available component) {
* @return
* @throws SocketException
*/
public static TestSuite suite() throws SocketException {
public static TestSuite suite() {
TestSuite suite = new TestSuite();

Available a = new Available();
Expand Down
Expand Up @@ -68,7 +68,7 @@ public VAlarmTest(String testMethod, VAlarm component) {
* @throws IOException
* @throws ParseException
*/
public static TestSuite suite() throws ParseException, IOException, URISyntaxException {
public static TestSuite suite() throws URISyntaxException {
TestSuite suite = new TestSuite();

VAlarm alarm = new VAlarm();
Expand Down
Expand Up @@ -65,7 +65,7 @@ public VAvailabilityTest(String testMethod, VAvailability component) {
* @return
* @throws SocketException
*/
public static TestSuite suite() throws SocketException {
public static TestSuite suite() {
TestSuite suite = new TestSuite();

VAvailability a = new VAvailability();
Expand Down
Expand Up @@ -531,7 +531,7 @@ public void testGetOccurrence() throws IOException, ParseException, URISyntaxExc
* @throws IOException
* @throws ParserException
*/
public static TestSuite suite() throws ValidationException, ParseException, IOException, URISyntaxException, ParserException {
public static TestSuite suite() throws ValidationException, IOException, ParserException {
UidGenerator uidGenerator = new RandomUidGenerator();

ZonedDateTime weekday9AM = ZonedDateTime.now().withYear(2005).withMonth(3).withDayOfMonth(7)
Expand Down
Expand Up @@ -41,7 +41,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
import java.text.ParseException;
Expand Down Expand Up @@ -362,8 +361,7 @@ public void testFreeBusyPeriods() {
/**
* @return
*/
public static TestSuite suite() throws ParseException, URISyntaxException,
IOException {
public static TestSuite suite() throws ParseException, URISyntaxException {
TestSuite suite = new TestSuite();

suite.addTest(new VFreeBusyTest("testVFreeBusyComponentList"));
Expand Down
Expand Up @@ -36,7 +36,6 @@
import net.fortuna.ical4j.model.PropertyTest;
import net.fortuna.ical4j.model.TimeZoneRegistry;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;

Expand Down Expand Up @@ -72,8 +71,7 @@ public DateListPropertyTest(String testMethod, DateListProperty property) {
/**
*
*/
public void testCopy() throws IOException, URISyntaxException,
ParseException {
public void testCopy() throws URISyntaxException {
Property copy = property.copy();
assertEquals(property, copy);
if (property.getTimeZone() != null) {
Expand Down
Expand Up @@ -38,9 +38,7 @@
import net.fortuna.ical4j.model.TimeZoneRegistry;
import net.fortuna.ical4j.model.parameter.TzId;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.Temporal;
Expand Down Expand Up @@ -79,8 +77,7 @@ public DatePropertyTest(String testMethod, DateProperty property) {
/**
*
*/
public void testCopy() throws IOException, URISyntaxException,
ParseException {
public void testCopy() throws URISyntaxException {
Property copy = property.copy();
assertEquals(property, copy);
}
Expand Down
10 changes: 4 additions & 6 deletions src/test/java/net/fortuna/ical4j/model/property/VersionTest.java
Expand Up @@ -31,14 +31,12 @@
*/
package net.fortuna.ical4j.model.property;

import java.io.IOException;
import java.net.URISyntaxException;
import java.text.ParseException;

import junit.framework.TestSuite;

import net.fortuna.ical4j.model.PropertyTest;

import java.io.IOException;
import java.net.URISyntaxException;

/**
* Created on 16/03/2005
*
Expand Down Expand Up @@ -73,7 +71,7 @@ public VersionTest(String testMethod, Version property) {
/*
* Test that the constant VERSION_2_0 is immutable.
*/
public void testImmutable() throws IOException, URISyntaxException, ParseException {
public void testImmutable() throws IOException, URISyntaxException {
super.testImmutable();

try {
Expand Down

0 comments on commit ba84b41

Please sign in to comment.