2 * Copyright (c) 2010-2021 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
154 @SuppressWarnings("null")
156 public void testCommandTagCode() {
157 List<Event> events = null;
159 int tagsPerEvent = 8;
161 // test just begun events: first in the series
162 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:55:00Z"),
163 Instant.parse("2020-01-28T16:05:00Z"));
164 assertNotNull(events);
165 assertEquals(eventCount, events.size());
166 for (Event event : events) {
167 List<CommandTag> cmdTags = event.commandTags;
168 assertEquals(tagsPerEvent, cmdTags.size());
170 for (CommandTag cmdTag : cmdTags) {
171 if (cmdTag.getTagType() == CommandTagType.BEGIN) {
172 assertTrue(cmdTag.isAuthorized("abc"));
173 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
174 assertTrue(cmdTag.getCommand() != null);
178 assertEquals(tagsPerEvent / 2, beginTags);
181 // test just begun events: third in the series
182 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-30T15:55:00Z"),
183 Instant.parse("2020-01-30T16:05:00Z"));
184 assertNotNull(events);
185 assertEquals(eventCount, events.size());
186 for (Event event : events) {
187 List<CommandTag> cmdTags = event.commandTags;
188 assertEquals(tagsPerEvent, cmdTags.size());
190 for (CommandTag cmdTag : cmdTags) {
191 if (cmdTag.getTagType() == CommandTagType.BEGIN) {
192 assertTrue(cmdTag.isAuthorized("abc"));
193 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
194 assertTrue(cmdTag.getCommand() != null);
198 assertEquals(tagsPerEvent / 2, beginTags);
201 // test outside of window: begun events, too early
202 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:50:00Z"),
203 Instant.parse("2020-01-28T15:55:00Z"));
204 assertNotNull(events);
205 assertEquals(0, events.size());
207 // test outside of window: begun events, too late
208 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T16:05:00Z"),
209 Instant.parse("2020-01-28T16:10:00Z"));
210 assertNotNull(events);
211 assertEquals(0, events.size());
213 // test just ended events: first in the series
214 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:25:00Z"),
215 Instant.parse("2020-01-28T16:35:00Z"));
216 assertNotNull(events);
217 assertEquals(eventCount, events.size());
218 for (Event event : events) {
219 List<CommandTag> cmdTags = event.commandTags;
220 assertEquals(tagsPerEvent, cmdTags.size());
222 for (CommandTag cmdTag : cmdTags) {
223 if (cmdTag.getTagType() == CommandTagType.END) {
224 assertTrue(cmdTag.isAuthorized("abc"));
225 assertTrue(cmdTag.getItemName().matches("^\\w+$"));
226 assertTrue(cmdTag.getCommand() != null);
230 assertEquals(tagsPerEvent / 2, endTags);
233 // test outside of window: ended events, too early
234 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:20:00Z"),
235 Instant.parse("2020-01-28T16:25:00Z"));
236 assertNotNull(events);
237 assertEquals(0, events.size());
239 // test outside of window: ended events, too late
240 events = calendar3.getJustEndedEvents(Instant.parse("2020-01-28T16:35:00Z"),
241 Instant.parse("2020-01-28T16:40:00Z"));
242 assertNotNull(events);
243 assertEquals(0, events.size());
245 // test a valid just begun event with both good and bad authorization codes
246 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T15:55:00Z"),
247 Instant.parse("2020-01-28T16:05:00Z"));
248 assertNotNull(events);
249 assertTrue(events.size() > 0);
250 List<CommandTag> cmdTags = events.get(0).commandTags;
251 assertTrue(cmdTags.size() > 0);
252 CommandTag cmd = cmdTags.get(0);
253 // accept correct, empty or null configuration codes
254 assertTrue(cmd.isAuthorized("abc"));
255 assertTrue(cmd.isAuthorized(""));
256 assertTrue(cmd.isAuthorized(null));
257 // reject incorrect configuration code
258 assertFalse(cmd.isAuthorized("123"));
260 // test tag syntax: Test Series #1
261 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T19:25:00Z"),
262 Instant.parse("2020-01-28T19:35:00Z"));
263 assertNotNull(events);
264 assertEquals(1, events.size());
265 cmdTags = events.get(0).commandTags;
266 assertEquals(11, cmdTags.size());
268 // BEGIN:Calendar_Test_Color:ON:abc
269 assertEquals("Calendar_Test_Color", cmdTags.get(0).getItemName());
270 assertTrue(cmdTags.get(0).isAuthorized("abc"));
271 Command cmd0 = cmdTags.get(0).getCommand();
273 assertEquals(OnOffType.class, cmd0.getClass());
275 // BEGIN:Calendar_Test_Contact:OPEN:abc
276 Command cmd1 = cmdTags.get(1).getCommand();
278 assertEquals(OpenClosedType.class, cmd1.getClass());
280 // BEGIN:Calendar_Test_Dimmer:ON:abc
281 Command cmd2 = cmdTags.get(2).getCommand();
283 assertEquals(OnOffType.class, cmd2.getClass());
285 // BEGIN:Calendar_Test_Number:12.3:abc
286 Command cmd3 = cmdTags.get(3).getCommand();
288 assertEquals(QuantityType.class, cmd3.getClass());
290 // BEGIN:Calendar_Test_Temperature:12.3°C:abc
291 Command cmd4 = cmdTags.get(4).getCommand();
293 assertEquals(QuantityType.class, cmd4.getClass());
295 // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
296 Command cmd5 = cmdTags.get(5).getCommand();
298 assertEquals(QuantityType.class, cmd5.getClass());
300 // BEGIN:Calendar_Test_Speed:12.3m/s:abc
301 Command cmd6 = cmdTags.get(6).getCommand();
303 assertEquals(QuantityType.class, cmd6.getClass());
305 // BEGIN:Calendar_Test_Player:PLAY:abc
306 Command cmd7 = cmdTags.get(7).getCommand();
308 assertEquals(PlayPauseType.class, cmd7.getClass());
310 // BEGIN:Calendar_Test_RollerShutter:UP:abc
311 Command cmd8 = cmdTags.get(8).getCommand();
313 assertEquals(UpDownType.class, cmd8.getClass());
315 // BEGIN:Calendar_Test_String:Test Series #1:abc
316 Command cmd9 = cmdTags.get(9).getCommand();
318 assertEquals(StringType.class, cmd9.getClass());
320 // BEGIN:Calendar_Test_Switch:ON:abc
321 Command cmd10 = cmdTags.get(10).getCommand();
322 assertNotNull(cmd10);
323 assertEquals(OnOffType.class, cmd10.getClass());
325 // test tag syntax: Test Series #4
326 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:10:00Z"),
327 Instant.parse("2020-01-28T20:20:00Z"));
328 assertNotNull(events);
329 assertEquals(1, events.size());
330 cmdTags = events.get(0).commandTags;
331 assertEquals(11, cmdTags.size());
333 // BEGIN:Calendar_Test_Color:0%:abc
334 cmd0 = cmdTags.get(0).getCommand();
336 assertEquals(PercentType.class, cmd0.getClass());
338 // BEGIN:Calendar_Test_Contact:CLOSED:abc
339 cmd1 = cmdTags.get(1).getCommand();
341 assertEquals(OpenClosedType.class, cmd1.getClass());
343 // BEGIN:Calendar_Test_Dimmer:0%:abc
344 cmd2 = cmdTags.get(2).getCommand();
346 assertEquals(PercentType.class, cmd2.getClass());
348 // BEGIN:Calendar_Test_Number:-12.3:abc
349 cmd3 = cmdTags.get(3).getCommand();
351 assertEquals(QuantityType.class, cmd3.getClass());
353 // BEGIN:Calendar_Test_Temperature:-12.3°C:abc
354 cmd4 = cmdTags.get(4).getCommand();
356 assertEquals(QuantityType.class, cmd4.getClass());
358 // BEGIN:Calendar_Test_Pressure:500mmHg:abc
359 cmd5 = cmdTags.get(5).getCommand();
361 assertEquals(QuantityType.class, cmd5.getClass());
363 // BEGIN:Calendar_Test_Speed:12300000mm/h:abc
364 cmd6 = cmdTags.get(6).getCommand();
366 assertEquals(QuantityType.class, cmd6.getClass());
368 // BEGIN:Calendar_Test_Player:REWIND:abc
369 cmd7 = cmdTags.get(7).getCommand();
371 assertEquals(RewindFastforwardType.class, cmd7.getClass());
373 // BEGIN:Calendar_Test_RollerShutter:100%:abc
374 cmd8 = cmdTags.get(8).getCommand();
376 assertEquals(PercentType.class, cmd8.getClass());
378 // BEGIN:Calendar_Test_String:Test Series #4:abc
379 cmd9 = cmdTags.get(9).getCommand();
381 assertEquals(StringType.class, cmd9.getClass());
383 // BEGIN:Calendar_Test_Switch:OFF:abc
384 cmd10 = cmdTags.get(10).getCommand();
385 assertNotNull(cmd10);
386 assertEquals(OnOffType.class, cmd10.getClass());
388 // test tag syntax: Test Series #5
389 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:25:00Z"),
390 Instant.parse("2020-01-28T20:35:00Z"));
391 assertNotNull(events);
392 assertEquals(1, events.size());
393 cmdTags = events.get(0).commandTags;
394 assertEquals(11, cmdTags.size());
396 // BEGIN:Calendar_Test_Color:240,100,100:abc
397 cmd0 = cmdTags.get(0).getCommand();
399 assertEquals(HSBType.class, cmd0.getClass());
401 // BEGIN:Calendar_Test_Contact:OPEN:abc
402 cmd1 = cmdTags.get(1).getCommand();
404 assertEquals(OpenClosedType.class, cmd1.getClass());
406 // BEGIN:Calendar_Test_Dimmer:50%:abc
407 cmd2 = cmdTags.get(2).getCommand();
409 assertEquals(PercentType.class, cmd2.getClass());
411 // BEGIN:Calendar_Test_Number:-0:abc
412 cmd3 = cmdTags.get(3).getCommand();
414 assertEquals(QuantityType.class, cmd3.getClass());
416 // BEGIN:Calendar_Test_Temperature:0K:abc
417 cmd4 = cmdTags.get(4).getCommand();
419 assertEquals(QuantityType.class, cmd4.getClass());
421 // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
422 cmd5 = cmdTags.get(5).getCommand();
424 assertEquals(QuantityType.class, cmd5.getClass());
426 // BEGIN:Calendar_Test_Speed:12.3km/h:abc
427 cmd6 = cmdTags.get(6).getCommand();
429 assertEquals(QuantityType.class, cmd6.getClass());
431 // BEGIN:Calendar_Test_Player:PLAY:abc
432 cmd7 = cmdTags.get(7).getCommand();
434 assertEquals(PlayPauseType.class, cmd7.getClass());
436 // BEGIN:Calendar_Test_RollerShutter:50%:abc
437 cmd8 = cmdTags.get(8).getCommand();
439 assertEquals(PercentType.class, cmd8.getClass());
441 // BEGIN:Calendar_Test_String:Test Series #5:abc
442 cmd9 = cmdTags.get(9).getCommand();
444 assertEquals(StringType.class, cmd9.getClass());
446 // BEGIN:Calendar_Test_Switch:ON:abc
447 cmd10 = cmdTags.get(10).getCommand();
448 assertNotNull(cmd10);
449 assertEquals(OnOffType.class, cmd10.getClass());
451 // test bad command tag syntax: Test Series #6
452 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:40:00Z"),
453 Instant.parse("2020-01-28T20:50:00Z"));
454 assertNotNull(events);
455 assertEquals(1, events.size());
456 cmdTags = events.get(0).commandTags;
457 // Test Series #6 contains only "bad" command tags as follows..
459 // tags with wrong case prefix..
464 // tags that are missing ":" field delimiters..
467 // tags with too few field delimiters..
470 // tags with too many field delimiters..
471 // BEGIN:www:xxx:yyy:zzz
473 // tags with an invalid prefix..
474 // BEGINX:xxx:yyy:zzz
476 // BEGIN :xxx:yyy:zzz
477 // BEGIN :xxx:yyy:zzz
479 // tags with an empty Item Name
484 // tags with bad Item Name
489 // tags with an empty Target State value
494 // Note: All of the above tags must be rejected! => Assert cmdTags.size() == 0 !
496 assertEquals(0, cmdTags.size());
498 // test HTML command tag syntax: Test Series #7
499 events = calendar3.getJustBegunEvents(Instant.parse("2020-01-28T20:55:00Z"),
500 Instant.parse("2020-01-28T21:05:00Z"));
501 assertNotNull(events);
502 assertEquals(1, events.size());
503 cmdTags = events.get(0).commandTags;
504 assertEquals(8, cmdTags.size());
506 // <p>BEGIN:Calendar_Test_Temperature:12.3°C:abc</p>
507 cmd0 = cmdTags.get(0).getCommand();
509 assertEquals(QuantityType.class, cmd0.getClass());
511 // <p>END:Calendar_Test_Temperature:23.4°C:abc</p>
512 cmd1 = cmdTags.get(1).getCommand();
514 assertEquals(QuantityType.class, cmd1.getClass());
516 // <p>BEGIN:Calendar_Test_Switch:ON:abc</p>
517 cmd2 = cmdTags.get(2).getCommand();
519 assertEquals(OnOffType.class, cmd2.getClass());
521 // <p>END:Calendar_Test_Switch:OFF:abc</p>
522 cmd3 = cmdTags.get(3).getCommand();
524 assertEquals(OnOffType.class, cmd3.getClass());
526 // <p>BEGIN:Calendar_Test_String:the quick:abc</p>
527 cmd4 = cmdTags.get(4).getCommand();
529 assertEquals(StringType.class, cmd4.getClass());
531 // <p>END:Calendar_Test_String:brown fox:abc</p>
532 cmd5 = cmdTags.get(5).getCommand();
534 assertEquals(StringType.class, cmd5.getClass());
536 // </p><p>BEGIN:Calendar_Test_Number:12.3:abc</p>
537 cmd6 = cmdTags.get(6).getCommand();
539 assertEquals(QuantityType.class, cmd6.getClass());
541 // <p>END:Calendar_Test_Number:23.4:abc</p>
542 cmd7 = cmdTags.get(7).getCommand();
544 assertEquals(QuantityType.class, cmd7.getClass());
547 @SuppressWarnings("null")
549 public void testGetFilteredEventsBetween() {
550 Event[] expectedFilteredEvents1 = new Event[] {
551 new Event("Test Series in UTC", Instant.parse("2019-09-12T09:05:00Z"),
552 Instant.parse("2019-09-12T09:10:00Z"), ""),
553 new Event("Test Event in UTC+2", Instant.parse("2019-09-14T08:00:00Z"),
554 Instant.parse("2019-09-14T09:00:00Z"), "") };
555 List<Event> realFilteredEvents1 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
556 Instant.parse("2019-09-15T06:00:00Z"), null, 3);
557 assertArrayEquals(expectedFilteredEvents1, realFilteredEvents1.toArray(new Event[0]));
559 Event[] expectedFilteredEvents2 = new Event[] {
560 new Event("Evt", Instant.parse("2019-11-10T10:00:00Z"), Instant.parse("2019-11-10T11:45:00Z"), ""),
561 new Event("Evt", Instant.parse("2019-11-17T10:00:00Z"), Instant.parse("2019-11-17T11:45:00Z"), ""),
562 new Event("Evt", Instant.parse("2019-12-01T10:00:00Z"), Instant.parse("2019-12-01T11:45:00Z"), "") };
563 List<Event> realFilteredEvents2 = calendar2.getFilteredEventsBetween(Instant.parse("2019-11-08T06:00:00Z"),
564 Instant.parse("2019-12-31T06:00:00Z"), null, 3);
565 assertArrayEquals(expectedFilteredEvents2, realFilteredEvents2.toArray(new Event[] {}));
567 Event[] expectedFilteredEvents3 = new Event[] { new Event("Test Event in UTC+2",
568 Instant.parse("2019-09-14T08:00:00Z"), Instant.parse("2019-09-14T09:00:00Z"), "") };
569 List<Event> realFilteredEvents3 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
570 Instant.parse("2019-09-15T06:00:00Z"),
571 new EventTextFilter(EventTextFilter.Field.SUMMARY, "utc+2", EventTextFilter.Type.TEXT), 3);
572 assertArrayEquals(expectedFilteredEvents3, realFilteredEvents3.toArray(new Event[] {}));
574 Event[] expectedFilteredEvents4 = new Event[] { new Event("Test Series in UTC",
575 Instant.parse("2019-09-12T09:05:00Z"), Instant.parse("2019-09-12T09:10:00Z"), "") };
576 List<Event> realFilteredEvents4 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-12T06:00:00Z"),
577 Instant.parse("2019-09-15T06:00:00Z"),
578 new EventTextFilter(EventTextFilter.Field.SUMMARY, ".*UTC$", EventTextFilter.Type.REGEX), 3);
579 assertArrayEquals(expectedFilteredEvents4, realFilteredEvents4.toArray(new Event[] {}));
581 List<Event> realFilteredEvents5 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-15T06:00:00Z"),
582 Instant.parse("2019-09-12T06:00:00Z"), null, 3);
583 assertEquals(0, realFilteredEvents5.size());
585 List<Event> realFilteredEvents6 = calendar.getFilteredEventsBetween(Instant.parse("2019-09-15T06:00:00Z"),
586 Instant.parse("2019-12-31T00:00:00Z"), null, 3);
587 assertEquals(0, realFilteredEvents6.size());