Skip to content

Commit

Permalink
Use int params instead of a string for TestUtils.date()
Browse files Browse the repository at this point in the history
  • Loading branch information
mangstadt committed Oct 28, 2023
1 parent 2027fff commit 915150b
Show file tree
Hide file tree
Showing 46 changed files with 543 additions and 520 deletions.
26 changes: 13 additions & 13 deletions src/test/java/biweekly/component/VEventTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -214,33 +214,33 @@ public void validate_dateEnd_without_dateStart() {
public void validate_dateStart_before_dateEnd() {
TestComponent parent = new TestComponent();
VEvent component = new VEvent();
component.setDateStart(date("2000-01-10"));
component.setDateEnd(date("2000-01-01"));
component.setDateStart(date(2000, 1, 10));
component.setDateEnd(date(2000, 1, 1));
assertValidate(component).parents(parent).run(16);
}

@Test
public void validate_different_date_datatypes() {
TestComponent parent = new TestComponent();
VEvent component = new VEvent();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateEnd(new DateEnd(date("2000-01-10"), true));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateEnd(new DateEnd(date(2000, 1, 10), true));
assertValidate(component).parents(parent).run(17);

parent = new TestComponent();
component = new VEvent();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateEnd(new DateEnd(date("2000-01-10"), false));
component.setRecurrenceId(new RecurrenceId(date("2000-01-01"), true));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateEnd(new DateEnd(date(2000, 1, 10), false));
component.setRecurrenceId(new RecurrenceId(date(2000, 1, 1), true));
assertValidate(component).parents(parent).run(19);
}

@Test
public void validate_dateEnd_with_duration() {
TestComponent parent = new TestComponent();
VEvent component = new VEvent();
component.setDateStart(date("2000-01-01"));
component.setDateEnd(date("2000-01-10"));
component.setDateStart(date(2000, 1, 1));
component.setDateEnd(date(2000, 1, 10));
component.setDuration(new Duration.Builder().build());
assertValidate(component).parents(parent).run(18);
}
Expand All @@ -258,8 +258,8 @@ public void validate_time_in_rrule() {
//@formatter:on
for (Recurrence recurrence : recurrences) {
VEvent component = new VEvent();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateEnd(new DateEnd(date("2000-01-10"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateEnd(new DateEnd(date(2000, 1, 10), false));
component.setRecurrenceRule(recurrence);
assertValidate(component).parents(parent).run(5);
}
Expand All @@ -269,8 +269,8 @@ public void validate_time_in_rrule() {
public void validate_multiple_rrules() {
TestComponent parent = new TestComponent();
VEvent component = new VEvent();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateEnd(new DateEnd(date("2000-01-10"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateEnd(new DateEnd(date(2000, 1, 10), false));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
assertValidate(component).parents(parent).run(6);
Expand Down
18 changes: 9 additions & 9 deletions src/test/java/biweekly/component/VFreeBusyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,16 @@ public void validate_cardinality_required() {
public void validate_cardinality_optional() {
VFreeBusy component = new VFreeBusy();
component.addProperty(new Contact(""));
component.addProperty(new DateStart(date("2000-01-01")));
component.addProperty(new DateEnd(date("2000-01-10")));
component.addProperty(new DateStart(date(2000, 1, 1)));
component.addProperty(new DateEnd(date(2000, 1, 10)));
component.addProperty(new Organizer(null, null));
component.addProperty(new Url(""));
assertValidate(component).versions(V1_0).run(48);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run();

component.addProperty(new Contact(""));
component.addProperty(new DateStart(date("2000-01-01")));
component.addProperty(new DateEnd(date("2000-01-10")));
component.addProperty(new DateStart(date(2000, 1, 1)));
component.addProperty(new DateEnd(date(2000, 1, 10)));
component.addProperty(new Organizer("", ""));
component.addProperty(new Url(""));
assertValidate(component).versions(V1_0).run(48, 3, 3, 3, 3, 3);
Expand All @@ -81,25 +81,25 @@ public void validate_cardinality_optional() {
@Test
public void validate_no_startDate() {
VFreeBusy component = new VFreeBusy();
component.setDateEnd(new DateEnd(date("2000-01-10"), true));
component.setDateEnd(new DateEnd(date(2000, 1, 10), true));
assertValidate(component).versions(V1_0).run(48, 15);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run(15);
}

@Test
public void validate_dates_do_not_have_times() {
VFreeBusy component = new VFreeBusy();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateEnd(new DateEnd(date("2000-01-10"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateEnd(new DateEnd(date(2000, 1, 10), false));
assertValidate(component).versions(V1_0).run(48, 20, 20);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run(20, 20);
}

@Test
public void validate_startDate_before_endDate() {
VFreeBusy component = new VFreeBusy();
component.setDateStart(new DateStart(date("2000-01-10"), true));
component.setDateEnd(new DateEnd(date("2000-01-01"), true));
component.setDateStart(new DateStart(date(2000, 1, 10), true));
component.setDateEnd(new DateEnd(date(2000, 1, 1), true));
assertValidate(component).versions(V1_0).run(48, 16);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run(16);
}
Expand Down
8 changes: 4 additions & 4 deletions src/test/java/biweekly/component/VJournalTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ public void validate_status() {
@Test
public void validate_different_date_datatypes() {
VJournal component = new VJournal();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setRecurrenceId(new RecurrenceId(date("2000-01-01"), true));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setRecurrenceId(new RecurrenceId(date(2000, 1, 1), true));
assertValidate(component).versions(V1_0).run(48, 19);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run(19);
}
Expand All @@ -185,7 +185,7 @@ public void validate_time_in_rrule() {
//@formatter:on
for (Recurrence recurrence : recurrences) {
VJournal component = new VJournal();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setRecurrenceRule(recurrence);
assertValidate(component).versions(V1_0).run(48, 5);
assertValidate(component).versions(V2_0_DEPRECATED, V2_0).run(5);
Expand All @@ -195,7 +195,7 @@ public void validate_time_in_rrule() {
@Test
public void validate_multiple_rrules() {
VJournal component = new VJournal();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
assertValidate(component).versions(V1_0).run(48, 6);
Expand Down
26 changes: 13 additions & 13 deletions src/test/java/biweekly/component/VTodoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,30 @@ public void validate_status() {
@Test
public void validate_dateStart_before_dateDue() {
VTodo component = new VTodo();
component.setDateStart(date("2000-01-10"));
component.setDateDue(date("2000-01-01"));
component.setDateStart(date(2000, 1, 10));
component.setDateDue(date(2000, 1, 1));
assertValidate(component).run(22);
}

@Test
public void validate_different_date_datatypes() {
VTodo component = new VTodo();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateDue(new DateDue(date("2000-01-10"), true));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateDue(new DateDue(date(2000, 1, 10), true));
assertValidate(component).run(23);

component = new VTodo();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateDue(new DateDue(date("2000-01-10"), false));
component.setRecurrenceId(new RecurrenceId(date("2000-01-01"), true));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateDue(new DateDue(date(2000, 1, 10), false));
component.setRecurrenceId(new RecurrenceId(date(2000, 1, 1), true));
assertValidate(component).run(19);
}

@Test
public void validate_dateDue_with_duration() {
VTodo component = new VTodo();
component.setDateStart(date("2000-01-01"));
component.setDateDue(date("2000-01-10"));
component.setDateStart(date(2000, 1, 1));
component.setDateDue(date(2000, 1, 10));
component.setDuration(new Duration.Builder().build());
assertValidate(component).run(24);
}
Expand All @@ -228,8 +228,8 @@ public void validate_time_in_rrule() {
//@formatter:on
for (Recurrence recurrence : recurrences) {
VTodo component = new VTodo();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateDue(new DateDue(date("2000-01-10"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateDue(new DateDue(date(2000, 1, 10), false));
component.setRecurrenceRule(recurrence);
assertValidate(component).run(5);
}
Expand All @@ -238,8 +238,8 @@ public void validate_time_in_rrule() {
@Test
public void validate_multiple_rrules() {
VTodo component = new VTodo();
component.setDateStart(new DateStart(date("2000-01-01"), false));
component.setDateDue(new DateDue(date("2000-01-10"), false));
component.setDateStart(new DateStart(date(2000, 1, 1), false));
component.setDateDue(new DateDue(date(2000, 1, 10), false));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
component.addProperty(new RecurrenceRule(new Recurrence.Builder(Frequency.DAILY).build()));
assertValidate(component).run(6);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/biweekly/io/ICalTimeZoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ public void dtstart_missing_time_component() throws Throwable {
}

ICalTimeZone tz = new ICalTimeZone(component);
Date anyTimeAfterNov1 = utc("1970-12-01 00:00:00");
Date anyTimeAfterNov1 = utc(1970, 12, 1, 0, 0, 0);
Boundary boundary = tz.getObservanceBoundary(anyTimeAfterNov1);
assertEquals(new DateTimeValueImpl(1970, 11, 1, 0, 0, 0), boundary.getObservanceInStart());
}
Expand Down
Loading

0 comments on commit 915150b

Please sign in to comment.