2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.icalendar.internal.logic;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.io.FileInputStream;
18 import java.io.IOException;
19 import java.time.Instant;
20 import java.util.List;
22 import org.junit.jupiter.api.BeforeEach;
23 import org.junit.jupiter.api.Test;
24 import org.openhab.core.library.types.HSBType;
25 import org.openhab.core.library.types.OnOffType;
26 import org.openhab.core.library.types.OpenClosedType;
27 import org.openhab.core.library.types.PercentType;
28 import org.openhab.core.library.types.PlayPauseType;
29 import org.openhab.core.library.types.QuantityType;
30 import org.openhab.core.library.types.RewindFastforwardType;
31 import org.openhab.core.library.types.StringType;
32 import org.openhab.core.library.types.UpDownType;
33 import org.openhab.core.types.Command;
36 * Tests for presentable calendar.
38 * @author Michael Wodniok - Initial contribution.
39 * @author Andrew Fiddian-Green - Tests for Command Tag code
40 * @author Michael Wodniok - Extended Tests for filtered Events
43 public class BiweeklyPresentableCalendarTest {
44 private AbstractPresentableCalendar calendar;
45 private AbstractPresentableCalendar calendar2;
46 private AbstractPresentableCalendar calendar3;
49 public void setUp() throws IOException, CalendarException {
50 calendar = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test.ics"));
51 calendar2 = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test2.ics"));
52 calendar3 = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test3.ics"));
56 * Tests recurrence and whether TimeZone is interpolated in a right way.
59 public void testIsEventPresent() {
61 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-08T09:04:00Z")));
62 assertTrue(calendar.isEventPresent(Instant.parse("2019-09-08T09:08:00Z")));
63 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-08T09:11:00Z")));
65 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-09T09:04:00Z")));
66 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-09T09:08:00Z")));
67 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-09T09:11:00Z")));
69 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-10T09:04:00Z")));
70 assertTrue(calendar.isEventPresent(Instant.parse("2019-09-10T09:08:00Z")));
71 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-10T09:11:00Z")));
73 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-11T09:04:00Z")));
74 assertTrue(calendar.isEventPresent(Instant.parse("2019-09-11T09:08:00Z")));
75 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-11T09:11:00Z")));
77 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-12T09:04:00Z")));
78 assertTrue(calendar.isEventPresent(Instant.parse("2019-09-12T09:08:00Z")));
79 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-12T09:11:00Z")));
81 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-13T09:04:00Z")));
82 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-13T09:08:00Z")));
83 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-13T09:11:00Z")));
85 // Test in CEST (UTC+2)
86 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-14T07:59:00Z")));
87 assertTrue(calendar.isEventPresent(Instant.parse("2019-09-14T08:03:00Z")));
88 assertFalse(calendar.isEventPresent(Instant.parse("2019-09-14T09:01:00Z")));
90 // Test Series with cancelled event by Davdroid
91 assertFalse(calendar2.isEventPresent(Instant.parse("2019-11-03T09:55:00Z")));
92 assertTrue(calendar2.isEventPresent(Instant.parse("2019-11-03T10:01:00Z")));
93 assertFalse(calendar2.isEventPresent(Instant.parse("2019-11-03T13:00:00Z")));
95 assertFalse(calendar2.isEventPresent(Instant.parse("2019-11-24T09:55:00Z")));
96 assertFalse(calendar2.isEventPresent(Instant.parse("2019-11-24T10:01:00Z")));
97 assertFalse(calendar2.isEventPresent(Instant.parse("2019-11-24T13:00:00Z")));
101 * This test relies on a working isEventPresent and assumes the calculation
102 * of recurrence is done the same way.
105 public void testGetCurrentEvent() {
106 Event currentEvent = calendar.getCurrentEvent(Instant.parse("2019-09-10T09:07:00Z"));
107 assertNotNull(currentEvent);
108 assertTrue("Test Series in UTC".contentEquals(currentEvent.title));
109 assertEquals(0, Instant.parse("2019-09-10T09:05:00Z").compareTo(currentEvent.start));
110 assertEquals(0, Instant.parse("2019-09-10T09:10:00Z").compareTo(currentEvent.end));
112 Event nonExistingEvent = calendar.getCurrentEvent(Instant.parse("2019-09-09T09:07:00Z"));
113 assertNull(nonExistingEvent);
117 * This test relies on a working isEventPresent and assumes the calculation
118 * of recurrence is done the same way.
121 public void testGetNextEvent() {
122 // positive case: next event of series
123 Event nextEventOfSeries = calendar.getNextEvent(Instant.parse("2019-09-10T09:07:00Z"));
124 assertNotNull(nextEventOfSeries);
125 assertTrue("Test Series in UTC".contentEquals(nextEventOfSeries.title));
126 assertEquals(0, Instant.parse("2019-09-11T09:05:00Z").compareTo(nextEventOfSeries.start));
127 assertEquals(0, Instant.parse("2019-09-11T09:10:00Z").compareTo(nextEventOfSeries.end));
129 // positive case: next event after series
130 Event nextEventOutsideSeries = calendar.getNextEvent(Instant.parse("2019-09-12T09:07:00Z"));
131 assertNotNull(nextEventOutsideSeries);
132 assertTrue("Test Event in UTC+2".contentEquals(nextEventOutsideSeries.title));
133 assertEquals(0, Instant.parse("2019-09-14T08:00:00Z").compareTo(nextEventOutsideSeries.start));
134 assertEquals(0, Instant.parse("2019-09-14T09:00:00Z").compareTo(nextEventOutsideSeries.end));
136 // positive case: next event should be also set if currently none is present
137 Event nextEventIndependent = calendar.getNextEvent(Instant.parse("2019-09-13T09:07:00Z"));
138 assertTrue(nextEventOutsideSeries.equals(nextEventIndependent));
140 // negative case: after last event there is no next
141 Event nonExistingEvent = calendar.getNextEvent(Instant.parse("2019-09-14T12:00:00Z"));
142 assertNull(nonExistingEvent);
144 // mixed case: cancelled events also not show up as next
145 Event nextEventAfterCancelled = calendar2.getNextEvent(Instant.parse("2019-11-24T09:55:00Z"));
146 assertNotNull(nextEventAfterCancelled);
147 assertEquals(0, Instant.parse("2019-12-01T10:00:00Z").compareTo(nextEventAfterCancelled.start));
151 * This test checks for Events that have just begun or ended, and if so it checks for Command Tags
152 * and checks if these tags are valid
155 public void testCommandTagCode() {
156 List<Event> events = null;
158 int tagsPerEvent = 8;
160 // test just begun events: first in the series
161 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:55:00Z"),
162 Instant.parse("2020-01-28T16:05:00Z"));
163 assertNotNull(events);
164 assertEquals(eventCount, events.size());
165 for (Event event : events) {
166 List<CommandTag> cmdTags = event.commandTags;
167 assertEquals(tagsPerEvent, cmdTags.size());
169 for (CommandTag cmdTag : cmdTags) {
170 if (cmdTag.getTagType() == CommandTagType.BEGIN) {
171 assertTrue(cmdTag.isAuthorized("abc"));
172 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
173 assertTrue(cmdTag.getCommand() != null);
177 assertEquals(tagsPerEvent / 2, beginTags);
180 // test just begun events: third in the series
181 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-30T15:55:00Z"),
182 Instant.parse("2020-01-30T16:05:00Z"));
183 assertNotNull(events);
184 assertEquals(eventCount, events.size());
185 for (Event event : events) {
186 List<CommandTag> cmdTags = event.commandTags;
187 assertEquals(tagsPerEvent, cmdTags.size());
189 for (CommandTag cmdTag : cmdTags) {
190 if (cmdTag.getTagType() == CommandTagType.BEGIN) {
191 assertTrue(cmdTag.isAuthorized("abc"));
192 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
193 assertTrue(cmdTag.getCommand() != null);
197 assertEquals(tagsPerEvent / 2, beginTags);
200 // test outside of window: begun events, too early
201 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:50:00Z"),
202 Instant.parse("2020-01-28T15:55:00Z"));
203 assertNotNull(events);
204 assertEquals(0, events.size());
206 // test outside of window: begun events, too late
207 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T16:05:00Z"),
208 Instant.parse("2020-01-28T16:10:00Z"));
209 assertNotNull(events);
210 assertEquals(0, events.size());
212 // test just ended events: first in the series
213 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:25:00Z"),
214 Instant.parse("2020-01-28T16:35:00Z"));
215 assertNotNull(events);
216 assertEquals(eventCount, events.size());
217 for (Event event : events) {
218 List<CommandTag> cmdTags = event.commandTags;
219 assertEquals(tagsPerEvent, cmdTags.size());
221 for (CommandTag cmdTag : cmdTags) {
222 if (cmdTag.getTagType() == CommandTagType.END) {
223 assertTrue(cmdTag.isAuthorized("abc"));
224 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
225 assertTrue(cmdTag.getCommand() != null);
229 assertEquals(tagsPerEvent / 2, endTags);
232 // test outside of window: ended events, too early
233 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:20:00Z"),
234 Instant.parse("2020-01-28T16:25:00Z"));
235 assertNotNull(events);
236 assertEquals(0, events.size());
238 // test outside of window: ended events, too late
239 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:35:00Z"),
240 Instant.parse("2020-01-28T16:40:00Z"));
241 assertNotNull(events);
242 assertEquals(0, events.size());
244 // test a valid just begun event with both good and bad authorization codes
245 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:55:00Z"),
246 Instant.parse("2020-01-28T16:05:00Z"));
247 assertNotNull(events);
248 assertTrue(events.size() > 0);
249 List<CommandTag> cmdTags = events.get(0).commandTags;
250 assertTrue(cmdTags.size() > 0);
251 CommandTag cmd = cmdTags.get(0);
252 // accept correct, empty or null configuration codes
253 assertTrue(cmd.isAuthorized("abc"));
254 assertTrue(cmd.isAuthorized(""));
255 assertTrue(cmd.isAuthorized(null));
256 // reject incorrect configuration code
257 assertFalse(cmd.isAuthorized("123"));
259 // test tag syntax: Test Series #1
260 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T19:25:00Z"),
261 Instant.parse("2020-01-28T19:35:00Z"));
262 assertNotNull(events);
263 assertEquals(1, events.size());
264 cmdTags = events.get(0).commandTags;
265 assertEquals(11, cmdTags.size());
267 // BEGIN:Calendar_Test_Color:ON:abc
268 assertEquals("Calendar_Test_Color", cmdTags.get(0).getItemName());
269 assertTrue(cmdTags.get(0).isAuthorized("abc"));
270 Command cmd0 = cmdTags.get(0).getCommand();
272 assertEquals(OnOffType.class, cmd0.getClass());
274 // BEGIN:Calendar_Test_Contact:OPEN:abc
275 Command cmd1 = cmdTags.get(1).getCommand();
277 assertEquals(OpenClosedType.class, cmd1.getClass());
279 // BEGIN:Calendar_Test_Dimmer:ON:abc
280 Command cmd2 = cmdTags.get(2).getCommand();
282 assertEquals(OnOffType.class, cmd2.getClass());
284 // BEGIN:Calendar_Test_Number:12.3:abc
285 Command cmd3 = cmdTags.get(3).getCommand();
287 assertEquals(QuantityType.class, cmd3.getClass());
289 // BEGIN:Calendar_Test_Temperature:12.3°C:abc
290 Command cmd4 = cmdTags.get(4).getCommand();
292 assertEquals(QuantityType.class, cmd4.getClass());
294 // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
295 Command cmd5 = cmdTags.get(5).getCommand();
297 assertEquals(QuantityType.class, cmd5.getClass());
299 // BEGIN:Calendar_Test_Speed:12.3m/s:abc
300 Command cmd6 = cmdTags.get(6).getCommand();
302 assertEquals(QuantityType.class, cmd6.getClass());
304 // BEGIN:Calendar_Test_Player:PLAY:abc
305 Command cmd7 = cmdTags.get(7).getCommand();
307 assertEquals(PlayPauseType.class, cmd7.getClass());
309 // BEGIN:Calendar_Test_RollerShutter:UP:abc
310 Command cmd8 = cmdTags.get(8).getCommand();
312 assertEquals(UpDownType.class, cmd8.getClass());
314 // BEGIN:Calendar_Test_String:Test Series #1:abc
315 Command cmd9 = cmdTags.get(9).getCommand();
317 assertEquals(StringType.class, cmd9.getClass());
319 // BEGIN:Calendar_Test_Switch:ON:abc
320 Command cmd10 = cmdTags.get(10).getCommand();
321 assertNotNull(cmd10);
322 assertEquals(OnOffType.class, cmd10.getClass());
324 // test tag syntax: Test Series #4
325 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:10:00Z"),
326 Instant.parse("2020-01-28T20:20:00Z"));
327 assertNotNull(events);
328 assertEquals(1, events.size());
329 cmdTags = events.get(0).commandTags;
330 assertEquals(11, cmdTags.size());
332 // BEGIN:Calendar_Test_Color:0%:abc
333 cmd0 = cmdTags.get(0).getCommand();
335 assertEquals(PercentType.class, cmd0.getClass());
337 // BEGIN:Calendar_Test_Contact:CLOSED:abc
338 cmd1 = cmdTags.get(1).getCommand();
340 assertEquals(OpenClosedType.class, cmd1.getClass());
342 // BEGIN:Calendar_Test_Dimmer:0%:abc
343 cmd2 = cmdTags.get(2).getCommand();
345 assertEquals(PercentType.class, cmd2.getClass());
347 // BEGIN:Calendar_Test_Number:-12.3:abc
348 cmd3 = cmdTags.get(3).getCommand();
350 assertEquals(QuantityType.class, cmd3.getClass());
352 // BEGIN:Calendar_Test_Temperature:-12.3°C:abc
353 cmd4 = cmdTags.get(4).getCommand();
355 assertEquals(QuantityType.class, cmd4.getClass());
357 // BEGIN:Calendar_Test_Pressure:500mmHg:abc
358 cmd5 = cmdTags.get(5).getCommand();
360 assertEquals(QuantityType.class, cmd5.getClass());
362 // BEGIN:Calendar_Test_Speed:12300000mm/h:abc
363 cmd6 = cmdTags.get(6).getCommand();
365 assertEquals(QuantityType.class, cmd6.getClass());
367 // BEGIN:Calendar_Test_Player:REWIND:abc
368 cmd7 = cmdTags.get(7).getCommand();
370 assertEquals(RewindFastforwardType.class, cmd7.getClass());
372 // BEGIN:Calendar_Test_RollerShutter:100%:abc
373 cmd8 = cmdTags.get(8).getCommand();
375 assertEquals(PercentType.class, cmd8.getClass());
377 // BEGIN:Calendar_Test_String:Test Series #4:abc
378 cmd9 = cmdTags.get(9).getCommand();
380 assertEquals(StringType.class, cmd9.getClass());
382 // BEGIN:Calendar_Test_Switch:OFF:abc
383 cmd10 = cmdTags.get(10).getCommand();
384 assertNotNull(cmd10);
385 assertEquals(OnOffType.class, cmd10.getClass());
387 // test tag syntax: Test Series #5
388 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:25:00Z"),
389 Instant.parse("2020-01-28T20:35:00Z"));
390 assertNotNull(events);
391 assertEquals(1, events.size());
392 cmdTags = events.get(0).commandTags;
393 assertEquals(11, cmdTags.size());
395 // BEGIN:Calendar_Test_Color:240,100,100:abc
396 cmd0 = cmdTags.get(0).getCommand();
398 assertEquals(HSBType.class, cmd0.getClass());
400 // BEGIN:Calendar_Test_Contact:OPEN:abc
401 cmd1 = cmdTags.get(1).getCommand();
403 assertEquals(OpenClosedType.class, cmd1.getClass());
405 // BEGIN:Calendar_Test_Dimmer:50%:abc
406 cmd2 = cmdTags.get(2).getCommand();
408 assertEquals(PercentType.class, cmd2.getClass());
410 // BEGIN:Calendar_Test_Number:-0:abc
411 cmd3 = cmdTags.get(3).getCommand();
413 assertEquals(QuantityType.class, cmd3.getClass());
415 // BEGIN:Calendar_Test_Temperature:0K:abc
416 cmd4 = cmdTags.get(4).getCommand();
418 assertEquals(QuantityType.class, cmd4.getClass());
420 // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
421 cmd5 = cmdTags.get(5).getCommand();
423 assertEquals(QuantityType.class, cmd5.getClass());
425 // BEGIN:Calendar_Test_Speed:12.3km/h:abc
426 cmd6 = cmdTags.get(6).getCommand();
428 assertEquals(QuantityType.class, cmd6.getClass());
430 // BEGIN:Calendar_Test_Player:PLAY:abc
431 cmd7 = cmdTags.get(7).getCommand();
433 assertEquals(PlayPauseType.class, cmd7.getClass());
435 // BEGIN:Calendar_Test_RollerShutter:50%:abc
436 cmd8 = cmdTags.get(8).getCommand();
438 assertEquals(PercentType.class, cmd8.getClass());
440 // BEGIN:Calendar_Test_String:Test Series #5:abc
441 cmd9 = cmdTags.get(9).getCommand();
443 assertEquals(StringType.class, cmd9.getClass());
445 // BEGIN:Calendar_Test_Switch:ON:abc
446 cmd10 = cmdTags.get(10).getCommand();
447 assertNotNull(cmd10);
448 assertEquals(OnOffType.class, cmd10.getClass());
450 // test bad command tag syntax: Test Series #6
451 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:40:00Z"),
452 Instant.parse("2020-01-28T20:50:00Z"));
453 assertNotNull(events);
454 assertEquals(1, events.size());
455 cmdTags = events.get(0).commandTags;
456 // Test Series #6 contains only "bad" command tags as follows..
458 // tags with wrong case prefix..
463 // tags that are missing ":" field delimiters..
466 // tags with too few field delimiters..
469 // tags with too many field delimiters..
470 // BEGIN:www:xxx:yyy:zzz
472 // tags with an invalid prefix..
473 // BEGINX:xxx:yyy:zzz
475 // BEGIN :xxx:yyy:zzz
476 // BEGIN :xxx:yyy:zzz
478 // tags with an empty Item Name
483 // tags with bad Item Name
488 // tags with an empty Target State value
493 // Note: All of the above tags must be rejected! => Assert cmdTags.size() == 0 !
495 assertEquals(0, cmdTags.size());
497 // test HTML command tag syntax: Test Series #7
498 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:55:00Z"),
499 Instant.parse("2020-01-28T21:05:00Z"));
500 assertNotNull(events);
501 assertEquals(1, events.size());
502 cmdTags = events.get(0).commandTags;
503 assertEquals(8, cmdTags.size());
505 // <p>BEGIN:Calendar_Test_Temperature:12.3°C:abc</p>
506 cmd0 = cmdTags.get(0).getCommand();
508 assertEquals(QuantityType.class, cmd0.getClass());
510 // <p>END:Calendar_Test_Temperature:23.4°C:abc</p>
511 cmd1 = cmdTags.get(1).getCommand();
513 assertEquals(QuantityType.class, cmd1.getClass());
515 // <p>BEGIN:Calendar_Test_Switch:ON:abc</p>
516 cmd2 = cmdTags.get(2).getCommand();
518 assertEquals(OnOffType.class, cmd2.getClass());
520 // <p>END:Calendar_Test_Switch:OFF:abc</p>
521 cmd3 = cmdTags.get(3).getCommand();
523 assertEquals(OnOffType.class, cmd3.getClass());
525 // <p>BEGIN:Calendar_Test_String:the quick:abc</p>
526 cmd4 = cmdTags.get(4).getCommand();
528 assertEquals(StringType.class, cmd4.getClass());
530 // <p>END:Calendar_Test_String:brown fox:abc</p>
531 cmd5 = cmdTags.get(5).getCommand();
533 assertEquals(StringType.class, cmd5.getClass());
535 // </p><p>BEGIN:Calendar_Test_Number:12.3:abc</p>
536 cmd6 = cmdTags.get(6).getCommand();
538 assertEquals(QuantityType.class, cmd6.getClass());
540 // <p>END:Calendar_Test_Number:23.4:abc</p>
541 cmd7 = cmdTags.get(7).getCommand();
543 assertEquals(QuantityType.class, cmd7.getClass());
546 @SuppressWarnings("null")
548 public void testGetFilteredEventsBetween() {
549 Event[] expectedFilteredEvents1 = new Event[] {
550 new Event("Test Series in UTC", Instant.parse("2019-09-12T09:05:00Z"),
551 Instant.parse("2019-09-12T09:10:00Z"), ""),
552 new Event("Test Event in UTC+2", Instant.parse("2019-09-14T08:00:00Z"),
553 Instant.parse("2019-09-14T09:00:00Z"), "") };
554 List<Event> realFilteredEvents1 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
555 Instant.parse("2019-09-15T06:00:00Z"), null, 3);
556 assertArrayEquals(expectedFilteredEvents1, realFilteredEvents1.toArray(new Event[0]));
558 Event[] expectedFilteredEvents2 = new Event[] {
559 new Event("Evt", Instant.parse("2019-11-10T10:00:00Z"), Instant.parse("2019-11-10T11:45:00Z"), ""),
560 new Event("Evt", Instant.parse("2019-11-17T10:00:00Z"), Instant.parse("2019-11-17T11:45:00Z"), ""),
561 new Event("Evt", Instant.parse("2019-12-01T10:00:00Z"), Instant.parse("2019-12-01T11:45:00Z"), "") };
562 List<Event> realFilteredEvents2 = calendar2.getFilteredEventsBetween(Instant.parse("2019-11-08T06:00:00Z"),
563 Instant.parse("2019-12-31T06:00:00Z"), null, 3);
564 assertArrayEquals(expectedFilteredEvents2, realFilteredEvents2.toArray(new Event[] {}));
566 Event[] expectedFilteredEvents3 = new Event[] { new Event("Test Event in UTC+2",
567 Instant.parse("2019-09-14T08:00:00Z"), Instant.parse("2019-09-14T09:00:00Z"), "") };
568 List<Event> realFilteredEvents3 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
569 Instant.parse("2019-09-15T06:00:00Z"),
570 new EventTextFilter(EventTextFilter.Field.SUMMARY, "utc+2", EventTextFilter.Type.TEXT), 3);
571 assertArrayEquals(expectedFilteredEvents3, realFilteredEvents3.toArray(new Event[] {}));
573 Event[] expectedFilteredEvents4 = new Event[] { new Event("Test Series in UTC",
574 Instant.parse("2019-09-12T09:05:00Z"), Instant.parse("2019-09-12T09:10:00Z"), "") };
575 List<Event> realFilteredEvents4 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
576 Instant.parse("2019-09-15T06:00:00Z"),
577 new EventTextFilter(EventTextFilter.Field.SUMMARY, ".*UTC$", EventTextFilter.Type.REGEX), 3);
578 assertArrayEquals(expectedFilteredEvents4, realFilteredEvents4.toArray(new Event[] {}));
580 List<Event> realFilteredEvents5 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-15T06:00:00Z"),
581 Instant.parse("2019-09-12T06:00:00Z"), null, 3);
582 assertEquals(0, realFilteredEvents5.size());
584 List<Event> realFilteredEvents6 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-15T06:00:00Z"),
585 Instant.parse("2019-12-31T00:00:00Z"), null, 3);
586 assertEquals(0, realFilteredEvents6.size());