]> git.basschouten.com Git - openhab-addons.git/blob
dead9ac63c01dfcb942f571f9ab37799d6020d72
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.icalendar.internal.logic;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.io.FileInputStream;
18 import java.io.IOException;
19 import java.time.Instant;
20 import java.util.List;
21
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;
34
35 /**
36  * Tests for presentable calendar.
37  *
38  * @author Michael Wodniok - Initial contribution.
39  *
40  * @author Andrew Fiddian-Green - Tests for Command Tag code
41  *
42  */
43 public class BiweeklyPresentableCalendarTest {
44     private AbstractPresentableCalendar calendar;
45     private AbstractPresentableCalendar calendar2;
46     private AbstractPresentableCalendar calendar3;
47
48     @BeforeEach
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"));
53     }
54
55     /**
56      * Tests recurrence and whether TimeZone is interpolated in a right way.
57      */
58     @Test
59     public void testIsEventPresent() {
60         // Test series
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")));
64
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")));
68
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")));
72
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")));
76
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")));
80
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")));
84
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")));
89
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")));
94
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")));
98     }
99
100     /**
101      * This test relies on a working isEventPresent and assumes the calculation
102      * of recurrence is done the same way.
103      */
104     @Test
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));
111
112         Event nonExistingEvent = calendar.getCurrentEvent(Instant.parse("2019-09-09T09:07:00Z"));
113         assertNull(nonExistingEvent);
114     }
115
116     /**
117      * This test relies on a working isEventPresent and assumes the calculation
118      * of recurrence is done the same way.
119      */
120     @Test
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));
128
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));
135
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));
139
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);
143
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));
148     }
149
150     /**
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
153      */
154     @Test
155     public void testCommandTagCode() {
156         List<Event> events = null;
157         int eventCount = 2;
158         int tagsPerEvent = 8;
159
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());
168             int beginTags = 0;
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);
174                     beginTags++;
175                 }
176             }
177             assertEquals(tagsPerEvent / 2, beginTags);
178         }
179
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());
188             int beginTags = 0;
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);
194                     beginTags++;
195                 }
196             }
197             assertEquals(tagsPerEvent / 2, beginTags);
198         }
199
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());
205
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());
211
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());
220             int endTags = 0;
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);
226                     endTags++;
227                 }
228             }
229             assertEquals(tagsPerEvent / 2, endTags);
230         }
231
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());
237
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());
243
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"));
258
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());
266
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();
271         assertNotNull(cmd0);
272         assertEquals(OnOffType.class, cmd0.getClass());
273
274         // BEGIN:Calendar_Test_Contact:OPEN:abc
275         Command cmd1 = cmdTags.get(1).getCommand();
276         assertNotNull(cmd1);
277         assertEquals(OpenClosedType.class, cmd1.getClass());
278
279         // BEGIN:Calendar_Test_Dimmer:ON:abc
280         Command cmd2 = cmdTags.get(2).getCommand();
281         assertNotNull(cmd2);
282         assertEquals(OnOffType.class, cmd2.getClass());
283
284         // BEGIN:Calendar_Test_Number:12.3:abc
285         Command cmd3 = cmdTags.get(3).getCommand();
286         assertNotNull(cmd3);
287         assertEquals(QuantityType.class, cmd3.getClass());
288
289         // BEGIN:Calendar_Test_Temperature:12.3°C:abc
290         Command cmd4 = cmdTags.get(4).getCommand();
291         assertNotNull(cmd4);
292         assertEquals(QuantityType.class, cmd4.getClass());
293
294         // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
295         Command cmd5 = cmdTags.get(5).getCommand();
296         assertNotNull(cmd5);
297         assertEquals(QuantityType.class, cmd5.getClass());
298
299         // BEGIN:Calendar_Test_Speed:12.3m/s:abc
300         Command cmd6 = cmdTags.get(6).getCommand();
301         assertNotNull(cmd6);
302         assertEquals(QuantityType.class, cmd6.getClass());
303
304         // BEGIN:Calendar_Test_Player:PLAY:abc
305         Command cmd7 = cmdTags.get(7).getCommand();
306         assertNotNull(cmd7);
307         assertEquals(PlayPauseType.class, cmd7.getClass());
308
309         // BEGIN:Calendar_Test_RollerShutter:UP:abc
310         Command cmd8 = cmdTags.get(8).getCommand();
311         assertNotNull(cmd8);
312         assertEquals(UpDownType.class, cmd8.getClass());
313
314         // BEGIN:Calendar_Test_String:Test Series #1:abc
315         Command cmd9 = cmdTags.get(9).getCommand();
316         assertNotNull(cmd9);
317         assertEquals(StringType.class, cmd9.getClass());
318
319         // BEGIN:Calendar_Test_Switch:ON:abc
320         Command cmd10 = cmdTags.get(10).getCommand();
321         assertNotNull(cmd10);
322         assertEquals(OnOffType.class, cmd10.getClass());
323
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());
331
332         // BEGIN:Calendar_Test_Color:0%:abc
333         cmd0 = cmdTags.get(0).getCommand();
334         assertNotNull(cmd0);
335         assertEquals(PercentType.class, cmd0.getClass());
336
337         // BEGIN:Calendar_Test_Contact:CLOSED:abc
338         cmd1 = cmdTags.get(1).getCommand();
339         assertNotNull(cmd1);
340         assertEquals(OpenClosedType.class, cmd1.getClass());
341
342         // BEGIN:Calendar_Test_Dimmer:0%:abc
343         cmd2 = cmdTags.get(2).getCommand();
344         assertNotNull(cmd2);
345         assertEquals(PercentType.class, cmd2.getClass());
346
347         // BEGIN:Calendar_Test_Number:-12.3:abc
348         cmd3 = cmdTags.get(3).getCommand();
349         assertNotNull(cmd3);
350         assertEquals(QuantityType.class, cmd3.getClass());
351
352         // BEGIN:Calendar_Test_Temperature:-12.3°C:abc
353         cmd4 = cmdTags.get(4).getCommand();
354         assertNotNull(cmd4);
355         assertEquals(QuantityType.class, cmd4.getClass());
356
357         // BEGIN:Calendar_Test_Pressure:500mmHg:abc
358         cmd5 = cmdTags.get(5).getCommand();
359         assertNotNull(cmd5);
360         assertEquals(QuantityType.class, cmd5.getClass());
361
362         // BEGIN:Calendar_Test_Speed:12300000mm/h:abc
363         cmd6 = cmdTags.get(6).getCommand();
364         assertNotNull(cmd6);
365         assertEquals(QuantityType.class, cmd6.getClass());
366
367         // BEGIN:Calendar_Test_Player:REWIND:abc
368         cmd7 = cmdTags.get(7).getCommand();
369         assertNotNull(cmd7);
370         assertEquals(RewindFastforwardType.class, cmd7.getClass());
371
372         // BEGIN:Calendar_Test_RollerShutter:100%:abc
373         cmd8 = cmdTags.get(8).getCommand();
374         assertNotNull(cmd8);
375         assertEquals(PercentType.class, cmd8.getClass());
376
377         // BEGIN:Calendar_Test_String:Test Series #4:abc
378         cmd9 = cmdTags.get(9).getCommand();
379         assertNotNull(cmd9);
380         assertEquals(StringType.class, cmd9.getClass());
381
382         // BEGIN:Calendar_Test_Switch:OFF:abc
383         cmd10 = cmdTags.get(10).getCommand();
384         assertNotNull(cmd10);
385         assertEquals(OnOffType.class, cmd10.getClass());
386
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());
394
395         // BEGIN:Calendar_Test_Color:240,100,100:abc
396         cmd0 = cmdTags.get(0).getCommand();
397         assertNotNull(cmd0);
398         assertEquals(HSBType.class, cmd0.getClass());
399
400         // BEGIN:Calendar_Test_Contact:OPEN:abc
401         cmd1 = cmdTags.get(1).getCommand();
402         assertNotNull(cmd1);
403         assertEquals(OpenClosedType.class, cmd1.getClass());
404
405         // BEGIN:Calendar_Test_Dimmer:50%:abc
406         cmd2 = cmdTags.get(2).getCommand();
407         assertNotNull(cmd2);
408         assertEquals(PercentType.class, cmd2.getClass());
409
410         // BEGIN:Calendar_Test_Number:-0:abc
411         cmd3 = cmdTags.get(3).getCommand();
412         assertNotNull(cmd3);
413         assertEquals(QuantityType.class, cmd3.getClass());
414
415         // BEGIN:Calendar_Test_Temperature:0K:abc
416         cmd4 = cmdTags.get(4).getCommand();
417         assertNotNull(cmd4);
418         assertEquals(QuantityType.class, cmd4.getClass());
419
420         // BEGIN:Calendar_Test_Pressure:12.3hPa:abc
421         cmd5 = cmdTags.get(5).getCommand();
422         assertNotNull(cmd5);
423         assertEquals(QuantityType.class, cmd5.getClass());
424
425         // BEGIN:Calendar_Test_Speed:12.3km/h:abc
426         cmd6 = cmdTags.get(6).getCommand();
427         assertNotNull(cmd6);
428         assertEquals(QuantityType.class, cmd6.getClass());
429
430         // BEGIN:Calendar_Test_Player:PLAY:abc
431         cmd7 = cmdTags.get(7).getCommand();
432         assertNotNull(cmd7);
433         assertEquals(PlayPauseType.class, cmd7.getClass());
434
435         // BEGIN:Calendar_Test_RollerShutter:50%:abc
436         cmd8 = cmdTags.get(8).getCommand();
437         assertNotNull(cmd8);
438         assertEquals(PercentType.class, cmd8.getClass());
439
440         // BEGIN:Calendar_Test_String:Test Series #5:abc
441         cmd9 = cmdTags.get(9).getCommand();
442         assertNotNull(cmd9);
443         assertEquals(StringType.class, cmd9.getClass());
444
445         // BEGIN:Calendar_Test_Switch:ON:abc
446         cmd10 = cmdTags.get(10).getCommand();
447         assertNotNull(cmd10);
448         assertEquals(OnOffType.class, cmd10.getClass());
449
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..
457
458         // tags with wrong case prefix..
459         // begin
460         // Begin
461         // BEGIn
462
463         // tags that are missing ":" field delimiters..
464         // BEGIN
465
466         // tags with too few field delimiters..
467         // BEGIN:www
468
469         // tags with too many field delimiters..
470         // BEGIN:www:xxx:yyy:zzz
471
472         // tags with an invalid prefix..
473         // BEGINX:xxx:yyy:zzz
474         // ENDX:xxx:yyy:zzz
475         // BEGIN :xxx:yyy:zzz
476         // BEGIN :xxx:yyy:zzz
477
478         // tags with an empty Item Name
479         // BEGIN::yyy:zzz
480         // BEGIN: :yyy:zzz
481         // BEGIN: :yyy:zzz
482
483         // tags with bad Item Name
484         // BEGIN:!:yyy:zzz
485         // BEGIN:@:yyy:zzz
486         // BEGIN:£:yyy:zzz
487
488         // tags with an empty Target State value
489         // BEGIN:xxx::zzz
490         // BEGIN:xxx: :zzz
491         // BEGIN:xxx: :zzz
492
493         // Note: All of the above tags must be rejected! => Assert cmdTags.size() == 0 !
494
495         assertEquals(0, cmdTags.size());
496
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());
504
505         // <p>BEGIN:Calendar_Test_Temperature:12.3°C:abc</p>
506         cmd0 = cmdTags.get(0).getCommand();
507         assertNotNull(cmd0);
508         assertEquals(QuantityType.class, cmd0.getClass());
509
510         // <p>END:Calendar_Test_Temperature:23.4°C:abc</p>
511         cmd1 = cmdTags.get(1).getCommand();
512         assertNotNull(cmd1);
513         assertEquals(QuantityType.class, cmd1.getClass());
514
515         // <p>BEGIN:Calendar_Test_Switch:ON:abc</p>
516         cmd2 = cmdTags.get(2).getCommand();
517         assertNotNull(cmd2);
518         assertEquals(OnOffType.class, cmd2.getClass());
519
520         // <p>END:Calendar_Test_Switch:OFF:abc</p>
521         cmd3 = cmdTags.get(3).getCommand();
522         assertNotNull(cmd3);
523         assertEquals(OnOffType.class, cmd3.getClass());
524
525         // <p>BEGIN:Calendar_Test_String:the quick:abc</p>
526         cmd4 = cmdTags.get(4).getCommand();
527         assertNotNull(cmd4);
528         assertEquals(StringType.class, cmd4.getClass());
529
530         // <p>END:Calendar_Test_String:brown fox:abc</p>
531         cmd5 = cmdTags.get(5).getCommand();
532         assertNotNull(cmd5);
533         assertEquals(StringType.class, cmd5.getClass());
534
535         // </p><p>BEGIN:Calendar_Test_Number:12.3:abc</p>
536         cmd6 = cmdTags.get(6).getCommand();
537         assertNotNull(cmd6);
538         assertEquals(QuantityType.class, cmd6.getClass());
539
540         // <p>END:Calendar_Test_Number:23.4:abc</p>
541         cmd7 = cmdTags.get(7).getCommand();
542         assertNotNull(cmd7);
543         assertEquals(QuantityType.class, cmd7.getClass());
544     }
545 }