]> git.basschouten.com Git - openhab-addons.git/blob
f10f7b57b8d18caf5ba8bbdd353703cadf2624dc
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.siemensrds.test;
14
15 import static org.junit.jupiter.api.Assertions.*;
16 import static org.openhab.binding.siemensrds.internal.RdsBindingConstants.*;
17
18 import java.io.BufferedReader;
19 import java.io.FileReader;
20 import java.io.IOException;
21 import java.nio.charset.StandardCharsets;
22 import java.util.List;
23 import java.util.Map;
24 import java.util.Map.Entry;
25
26 import javax.measure.quantity.ElectricCurrent;
27
28 import org.eclipse.jdt.annotation.NonNullByDefault;
29 import org.eclipse.jdt.annotation.Nullable;
30 import org.junit.jupiter.api.Test;
31 import org.openhab.binding.siemensrds.internal.RdsAccessToken;
32 import org.openhab.binding.siemensrds.internal.RdsCloudException;
33 import org.openhab.binding.siemensrds.internal.RdsDataPoints;
34 import org.openhab.binding.siemensrds.internal.RdsPlants;
35 import org.openhab.binding.siemensrds.internal.RdsPlants.PlantInfo;
36 import org.openhab.binding.siemensrds.points.BasePoint;
37 import org.openhab.core.library.types.DecimalType;
38 import org.openhab.core.library.types.QuantityType;
39 import org.openhab.core.library.types.StringType;
40 import org.openhab.core.library.unit.ImperialUnits;
41 import org.openhab.core.library.unit.SIUnits;
42 import org.openhab.core.library.unit.Units;
43 import org.openhab.core.types.State;
44 import org.openhab.core.types.UnDefType;
45
46 /**
47  * test suite
48  *
49  * @author Andrew Fiddian-Green - Initial contribution
50  *
51  */
52 @NonNullByDefault
53 public class TestRdsData {
54
55     private String load(String fileName) {
56         try (FileReader file = new FileReader(String.format("src/test/resources/%s.json", fileName),
57                 StandardCharsets.UTF_8); BufferedReader reader = new BufferedReader(file)) {
58             StringBuilder builder = new StringBuilder();
59             String line;
60             while ((line = reader.readLine()) != null) {
61                 builder.append(line).append("\n");
62             }
63             return builder.toString();
64         } catch (IOException e) {
65             fail(e.getMessage());
66         }
67         return "";
68     }
69
70     @Test
71     public void testRdsDataPointsFullNew() {
72         RdsDataPoints dataPoints = RdsDataPoints.createFromJson(load("datapoints_full_set_new"));
73         assertNotNull(dataPoints);
74         try {
75             assertEquals("Downstairs", dataPoints.getDescription());
76         } catch (RdsCloudException e) {
77             fail(e.getMessage());
78         }
79         @Nullable
80         Map<String, @Nullable BasePoint> points = dataPoints.points;
81         assertNotNull(points);
82         assertEquals(70, points.size());
83     }
84
85     @Test
86     public void confirmDegreeSymbolCodingNotTrashed() {
87         /*
88          * note: temperature symbols with a degree sign: the MVN Spotless trashes the
89          * "degree" (looks like *) symbol, so we must escape these symbols as octal \260
90          * or unicode \u00B00 - the following test will indicate is all is ok
91          */
92         assertTrue("\260C".equals(BasePoint.DEGREES_CELSIUS));
93         assertTrue("\u00B0C".equals(BasePoint.DEGREES_CELSIUS));
94         assertTrue("\260F".equals(BasePoint.DEGREES_FAHRENHEIT));
95         assertTrue("\u00B0F".equals(BasePoint.DEGREES_FAHRENHEIT));
96         assertTrue(BasePoint.DEGREES_FAHRENHEIT.startsWith(BasePoint.DEGREES_CELSIUS.substring(0, 1)));
97     }
98
99     @Test
100     public void testRdsDataPointsRefresh() {
101         RdsDataPoints refreshPoints = RdsDataPoints.createFromJson(load("datapoints_refresh_set"));
102         assertNotNull(refreshPoints);
103
104         assertNotNull(refreshPoints.points);
105         Map<String, @Nullable BasePoint> refreshMap = refreshPoints.points;
106         assertNotNull(refreshMap);
107
108         @Nullable
109         BasePoint point;
110         State state;
111
112         // check the parsed values
113         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;0!Online");
114         assertTrue(point instanceof BasePoint);
115         state = point.getState();
116         assertEquals(state.getClass(), DecimalType.class);
117         assertEquals(1, ((DecimalType) state).intValue());
118
119         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!00000000E000055");
120         assertTrue(point instanceof BasePoint);
121         state = point.getState();
122         assertEquals(state.getClass(), QuantityType.class);
123         assertEquals(12.60, ((QuantityType<?>) state).floatValue(), 0.01);
124
125         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!002000083000055");
126         assertTrue(point instanceof BasePoint);
127         state = point.getState();
128         assertEquals(state.getClass(), QuantityType.class);
129         assertEquals(16.0, ((QuantityType<?>) state).floatValue(), 0.01);
130
131         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!002000085000055");
132         assertTrue(point instanceof BasePoint);
133         state = point.getState();
134         assertEquals(state.getClass(), QuantityType.class);
135         assertEquals(39.13, ((QuantityType<?>) state).floatValue(), 0.01);
136
137         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!002000086000055");
138         assertTrue(point instanceof BasePoint);
139         state = point.getState();
140         assertEquals(state.getClass(), QuantityType.class);
141         assertEquals(21.51, ((QuantityType<?>) state).floatValue(), 0.01);
142
143         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!013000051000055");
144         assertTrue(point instanceof BasePoint);
145         state = point.getState();
146         assertEquals(state.getClass(), QuantityType.class);
147         assertEquals(2, ((QuantityType<?>) state).intValue());
148
149         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!013000052000055");
150         assertTrue(point instanceof BasePoint);
151         state = point.getState();
152         assertEquals(state.getClass(), QuantityType.class);
153         assertEquals(5, ((QuantityType<?>) state).intValue());
154
155         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!013000053000055");
156         assertTrue(point instanceof BasePoint);
157         state = point.getState();
158         assertEquals(state.getClass(), QuantityType.class);
159         assertEquals(2, ((QuantityType<?>) state).intValue());
160
161         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!013000056000055");
162         assertTrue(point instanceof BasePoint);
163         state = point.getState();
164         assertEquals(state.getClass(), QuantityType.class);
165         assertEquals(1, ((QuantityType<?>) state).intValue());
166
167         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!01300005A000055");
168         assertTrue(point instanceof BasePoint);
169         state = point.getState();
170         assertEquals(state.getClass(), QuantityType.class);
171         assertEquals(2, ((QuantityType<?>) state).intValue());
172
173         point = refreshMap.get("Pd1774247-7de7-4896-ac76-b7e0dd943c40;1!013000074000055");
174         assertTrue(point instanceof BasePoint);
175         state = point.getState();
176         assertEquals(state.getClass(), QuantityType.class);
177         assertEquals(4, ((QuantityType<?>) state).intValue());
178
179         RdsDataPoints originalPoints = RdsDataPoints.createFromJson(load("datapoints_full_set"));
180         assertNotNull(originalPoints);
181         assertNotNull(originalPoints.points);
182
183         // check that the refresh point types match the originals
184         Map<String, @Nullable BasePoint> originalMap = originalPoints.points;
185         assertNotNull(originalMap);
186         @Nullable
187         BasePoint refreshPoint;
188         @Nullable
189         BasePoint originalPoint;
190         for (String key : refreshMap.keySet()) {
191             refreshPoint = refreshMap.get(key);
192             assertTrue(refreshPoint instanceof BasePoint);
193             originalPoint = originalMap.get(key);
194             assertTrue(originalPoint instanceof BasePoint);
195             assertEquals(refreshPoint.getState().getClass(), originalPoint.getState().getClass());
196         }
197     }
198
199     @Test
200     public void testAccessToken() {
201         RdsAccessToken accessToken = RdsAccessToken.createFromJson(load("access_token"));
202         assertNotNull(accessToken);
203         try {
204             assertEquals("this-is-not-a-valid-access_token", accessToken.getToken());
205         } catch (RdsCloudException e) {
206             fail(e.getMessage());
207         }
208         assertTrue(accessToken.isExpired());
209     }
210
211     @Test
212     public void testRdsDataPointsFull() {
213         RdsDataPoints dataPoints = RdsDataPoints.createFromJson(load("datapoints_full_set"));
214         assertNotNull(dataPoints);
215         try {
216             assertEquals("Upstairs", dataPoints.getDescription());
217         } catch (RdsCloudException e) {
218             fail(e.getMessage());
219         }
220
221         @Nullable
222         Map<String, @Nullable BasePoint> points = dataPoints.points;
223         assertNotNull(points);
224         assertEquals(67, points.size());
225
226         try {
227             assertEquals("AAS-20:SU=SiUn;APT=HvacFnct18z_A;APTV=2.003;APS=1;",
228                     dataPoints.getPointByClass("ApplicationSoftwareVersion").getState().toString());
229             assertEquals("Device object", dataPoints.getPointByClass("Device Description").getState().toString());
230             assertEquals("FW=02.32.02.27;SVS-300.1:SBC=13.22;I",
231                     dataPoints.getPointByClass("FirmwareRevision").getState().toString());
232             assertEquals("RDS110", dataPoints.getPointByClass("ModelName").getState().toString());
233             assertEquals(0, dataPoints.getPointByClass("SystemStatus").asInt());
234             assertEquals(0, dataPoints.getPointByClass("UtcOffset").asInt());
235             assertEquals(19, dataPoints.getPointByClass("DatabaseRevision").asInt());
236             assertEquals(0, dataPoints.getPointByClass("LastRestartReason").asInt());
237             assertEquals("MDL:ASN= RDS110;HW=0.2.0;",
238                     dataPoints.getPointByClass("ModelInformation").getState().toString());
239             assertEquals(1, dataPoints.getPointByClass("Active SystemLanguge").asInt());
240             assertEquals(26, dataPoints.getPointByClass("TimeZone").asInt());
241             assertEquals("160100096D", dataPoints.getPointByClass("SerialNumber").getState().toString());
242             assertEquals("'10010'B", dataPoints.getPointByClass("Device Features").getState().toString());
243             assertEquals("Upstairs", dataPoints.getPointByClass("'Description").getState().toString());
244             assertEquals("192.168.1.1", dataPoints.getPointByClass("'IP gefault gateway").getState().toString());
245             assertEquals("255.255.255.0", dataPoints.getPointByClass("'IP subnet mask").getState().toString());
246             assertEquals("192.168.1.42", dataPoints.getPointByClass("'IP address").getState().toString());
247             assertEquals(47808, dataPoints.getPointByClass("'UDP Port").asInt());
248             assertEquals("'F0C77F6C1895'H", dataPoints.getPointByClass("'BACnet MAC address").getState().toString());
249             assertEquals("sth.connectivity.ccl-siemens.com",
250                     dataPoints.getPointByClass("'Connection URI").getState().toString());
251             assertEquals("this-is-not-a-valid-activation-key",
252                     dataPoints.getPointByClass("'Activation Key").getState().toString());
253             assertEquals(60, dataPoints.getPointByClass("'Reconection delay").asInt());
254             assertEquals(0, dataPoints.getPointByClass("#Item Updates per Minute").asInt());
255             assertEquals(286849, dataPoints.getPointByClass("#Item Updates Total").asInt());
256             assertEquals("-;en", dataPoints.getPointByClass("#Languages").getState().toString());
257             assertEquals(1, dataPoints.getPointByClass("#Online").asInt());
258             assertEquals(1473, dataPoints.getPointByClass("#Traffic Inbound per Minute").asInt());
259             assertEquals(178130801, dataPoints.getPointByClass("#Traffic Inbound Total").asInt());
260             assertEquals(616, dataPoints.getPointByClass("#Traffic Outbound per Minute").asInt());
261             assertEquals(60624666, dataPoints.getPointByClass("#Traffic Outbound Total").asInt());
262             assertEquals(0, dataPoints.getPointByClass("#Item Updates per Minute").asInt());
263
264             State state;
265             QuantityType<?> celsius;
266             state = dataPoints.getPointByClass("'TOa").getState();
267             assertTrue(state instanceof QuantityType<?>);
268             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
269             assertNotNull(celsius);
270             assertEquals(18.55, celsius.floatValue(), 0.01);
271
272             assertEquals(new QuantityType<ElectricCurrent>(0, Units.AMPERE),
273                     dataPoints.getPointByClass("'HDevElLd").getState());
274
275             state = dataPoints.getPointByClass("'SpHPcf").getState();
276             assertTrue(state instanceof QuantityType<?>);
277             QuantityType<?> fahrenheit = ((QuantityType<?>) state).toUnit(ImperialUnits.FAHRENHEIT);
278             assertNotNull(fahrenheit);
279             assertEquals(24.00, fahrenheit.floatValue(), 0.01);
280
281             state = dataPoints.getPointByClass("'SpHEco").getState();
282             assertTrue(state instanceof QuantityType<?>);
283             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
284             assertNotNull(celsius);
285             assertEquals(16.00, celsius.floatValue(), 0.01);
286
287             state = dataPoints.getPointByClass("'SpHPrt").getState();
288             assertTrue(state instanceof QuantityType<?>);
289             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
290             assertNotNull(celsius);
291             assertEquals(6.00, celsius.floatValue(), 0.01);
292
293             state = dataPoints.getPointByClass("'SpTR").getState();
294             assertTrue(state instanceof QuantityType<?>);
295             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
296             assertNotNull(celsius);
297             assertEquals(24.00, celsius.floatValue(), 0.01);
298
299             state = dataPoints.getPointByClass("'SpTRShft").getState();
300             assertTrue(state instanceof QuantityType<?>);
301             QuantityType<?> kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
302             assertNotNull(kelvin);
303             assertEquals(0, kelvin.floatValue(), 0.01);
304
305             state = dataPoints.getPointByClass("'RHuRel").getState();
306             assertTrue(state instanceof QuantityType<?>);
307             QuantityType<?> relativeHumidity = ((QuantityType<?>) state).toUnit(Units.PERCENT);
308             assertNotNull(relativeHumidity);
309             assertEquals(46.86865, relativeHumidity.floatValue(), 0.1);
310
311             state = dataPoints.getPointByClass("'RTemp").getState();
312             assertTrue(state instanceof QuantityType<?>);
313             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
314             assertNotNull(celsius);
315             assertEquals(23.76, celsius.floatValue(), 0.01);
316
317             state = dataPoints.getPointByClass("'SpTRMaxHCmf").getState();
318             assertTrue(state instanceof QuantityType<?>);
319             celsius = ((QuantityType<?>) state).toUnit(SIUnits.CELSIUS);
320             assertNotNull(celsius);
321             assertEquals(35.00, celsius.floatValue(), 0.01);
322
323             assertEquals(new QuantityType<>(30, Units.ONE), dataPoints.getPointByClass("'WarmUpGrdnt").getState());
324
325             state = dataPoints.getPointByClass("'TRBltnMsvAdj").getState();
326             assertTrue(state instanceof QuantityType<?>);
327             kelvin = ((QuantityType<?>) state).toUnit(Units.KELVIN);
328             assertNotNull(kelvin);
329             assertEquals(35.0, celsius.floatValue(), 0.01);
330
331             assertEquals(new QuantityType<>(0, Units.AMPERE), dataPoints.getPointByClass("'Q22Q24ElLd").getState());
332             assertEquals(new QuantityType<>(713, Units.PARTS_PER_MILLION),
333                     dataPoints.getPointByClass("'RAQual").getState());
334
335             assertEquals(new QuantityType<>(0, Units.ONE), dataPoints.getPointByClass("'TmpCmfBtn").getState());
336             assertEquals(new QuantityType<>(0, Units.ONE), dataPoints.getPointByClass("'CmfBtn").getState());
337             assertEquals(new QuantityType<>(0, Units.ONE), dataPoints.getPointByClass("'RPscDet").getState());
338             assertEquals(new QuantityType<>(1, Units.ONE), dataPoints.getPointByClass("'EnHCtl").getState());
339             assertEquals(new QuantityType<>(0, Units.ONE), dataPoints.getPointByClass("'EnRPscDet").getState());
340             assertEquals(new QuantityType<>(2, Units.ONE), dataPoints.getPointByClass("'OffPrtCnf").getState());
341             assertEquals(new QuantityType<>(3, Units.ONE), dataPoints.getPointByClass("'OccMod").getState());
342             assertEquals(new QuantityType<>(5, Units.ONE), dataPoints.getPointByClass("'REei").getState());
343             assertEquals(new QuantityType<>(2, Units.ONE), dataPoints.getPointByClass("'DhwMod").getState());
344             assertEquals(new QuantityType<>(2, Units.ONE), dataPoints.getPointByClass("'HCSta").getState());
345             assertEquals(new QuantityType<>(4, Units.ONE), dataPoints.getPointByClass("'PrOpModRsn").getState());
346             assertEquals(new QuantityType<>(6, Units.ONE), dataPoints.getPointByClass("'HCtrSet").getState());
347             assertEquals(new QuantityType<>(2, Units.ONE), dataPoints.getPointByClass("'OsscSet").getState());
348             assertEquals(new QuantityType<>(4, Units.ONE), dataPoints.getPointByClass("'RAQualInd").getState());
349
350             assertEquals(new QuantityType<>(500, Units.HOUR), dataPoints.getPointByClass("'KickCyc").getState());
351             assertEquals(new QuantityType<>(3, Units.MINUTE), dataPoints.getPointByClass("'BoDhwTiOnMin").getState());
352             assertEquals(new QuantityType<>(3, Units.MINUTE), dataPoints.getPointByClass("'BoDhwTiOffMin").getState());
353
354             assertEquals(UnDefType.UNDEF, dataPoints.getPointByClass("'ROpModSched").getState());
355             assertEquals(UnDefType.UNDEF, dataPoints.getPointByClass("'DhwSched").getState());
356             assertEquals(UnDefType.UNDEF, dataPoints.getPointByClass("'ROpModSched").getState());
357             assertEquals(UnDefType.UNDEF, dataPoints.getPointByClass("'DhwSched").getState());
358
359             assertEquals(new QuantityType<>(253140, Units.MINUTE), dataPoints.getPointByClass("'OphH").getState());
360         } catch (RdsCloudException e) {
361             fail(e.getMessage());
362         }
363
364         // test for a missing element
365         State test = null;
366         try {
367             test = dataPoints.getPointByClass("missing-element").getState();
368             fail("expected exception did not occur");
369         } catch (RdsCloudException e) {
370             assertEquals(null, test);
371         }
372
373         try {
374             // test the all-the-way-round lookup loop
375             assertNotNull(dataPoints.points);
376             Map<String, @Nullable BasePoint> pointsMap = dataPoints.points;
377             assertNotNull(pointsMap);
378             @Nullable
379             BasePoint point;
380             for (Entry<String, @Nullable BasePoint> entry : pointsMap.entrySet()) {
381                 point = entry.getValue();
382                 assertTrue(point instanceof BasePoint);
383                 // ignore UNDEF points where all-the-way-round lookup fails
384                 if (!"UNDEF".equals(point.getState().toString())) {
385                     @Nullable
386                     String x = entry.getKey();
387                     assertNotNull(x);
388                     String y = point.getPointClass();
389                     String z = dataPoints.pointClassToId(y);
390                     assertEquals(x, z);
391                 }
392             }
393
394             State state = null;
395
396             // test the specific points that we use
397             state = dataPoints.getPointByClass(HIE_DESCRIPTION).getState();
398             assertEquals("Upstairs", state.toString());
399
400             state = dataPoints.getPointByClass(HIE_ROOM_TEMP).getState();
401             assertEquals(state.getClass(), QuantityType.class);
402             assertEquals(23.761879, ((QuantityType<?>) state).floatValue(), 0.01);
403
404             state = dataPoints.getPointByClass(HIE_OUTSIDE_TEMP).getState();
405             assertEquals(state.getClass(), QuantityType.class);
406             assertEquals(18.55, ((QuantityType<?>) state).floatValue(), 0.01);
407
408             state = dataPoints.getPointByClass(HIE_TARGET_TEMP).getState();
409             assertEquals(state.getClass(), QuantityType.class);
410             assertEquals(24, ((QuantityType<?>) state).floatValue(), 0.01);
411
412             state = dataPoints.getPointByClass(HIE_ROOM_HUMIDITY).getState();
413             assertEquals(state.getClass(), QuantityType.class);
414             assertEquals(46.86, ((QuantityType<?>) state).floatValue(), 0.01);
415
416             state = dataPoints.getPointByClass(HIE_ROOM_AIR_QUALITY).getEnum();
417             assertEquals(state.getClass(), StringType.class);
418             assertEquals("Good", state.toString());
419             assertEquals("Good", dataPoints.getPointByClass(HIE_ROOM_AIR_QUALITY).getEnum().toString());
420
421             state = dataPoints.getPointByClass(HIE_ENERGY_SAVINGS_LEVEL).getEnum();
422             assertEquals(state.getClass(), StringType.class);
423             assertEquals("Excellent", state.toString());
424             assertEquals("Excellent", dataPoints.getPointByClass(HIE_ENERGY_SAVINGS_LEVEL).getEnum().toString());
425
426             state = dataPoints.getPointByClass(HIE_OUTPUT_STATE).getEnum();
427             assertEquals(state.getClass(), StringType.class);
428             assertEquals("Heating", state.toString());
429             assertEquals("Heating", dataPoints.getPointByClass(HIE_OUTPUT_STATE).getEnum().toString());
430
431             state = dataPoints.getPointByClass(HIE_STAT_OCC_MODE_PRESENT).getState();
432             assertEquals(state.getClass(), QuantityType.class);
433             assertEquals(3, ((QuantityType<?>) state).intValue());
434             assertEquals(3, dataPoints.getPointByClass(HIE_STAT_OCC_MODE_PRESENT).asInt());
435
436             state = dataPoints.getPointByClass(HIE_STAT_OCC_MODE_PRESENT).getEnum();
437             assertEquals(state.getClass(), StringType.class);
438             assertEquals("Present", state.toString());
439             assertEquals("Present", dataPoints.getPointByClass(HIE_STAT_OCC_MODE_PRESENT).getEnum().toString());
440
441             state = dataPoints.getPointByClass(HIE_DHW_OUTPUT_STATE).getState();
442             assertEquals(state.getClass(), QuantityType.class);
443             assertEquals(2, ((QuantityType<?>) state).intValue());
444             assertEquals(2, dataPoints.getPointByClass(HIE_DHW_OUTPUT_STATE).asInt());
445
446             state = dataPoints.getPointByClass(HIE_DHW_OUTPUT_STATE).getEnum();
447             assertEquals(state.getClass(), StringType.class);
448             assertEquals("On", state.toString());
449             assertEquals("On", dataPoints.getPointByClass(HIE_DHW_OUTPUT_STATE).getEnum().toString());
450
451             state = dataPoints.getPointByClass(HIE_PR_OP_MOD_RSN).getState();
452             assertEquals(state.getClass(), QuantityType.class);
453             assertEquals(4, ((QuantityType<?>) state).intValue());
454             assertEquals(4, dataPoints.getPointByClass(HIE_PR_OP_MOD_RSN).asInt());
455
456             state = dataPoints.getPointByClass(HIE_PR_OP_MOD_RSN).getEnum();
457             assertEquals(state.getClass(), StringType.class);
458             assertEquals("Comfort", state.toString());
459             assertEquals("Comfort", dataPoints.getPointByClass(HIE_PR_OP_MOD_RSN).getEnum().toString());
460
461             state = dataPoints.getPointByClass(HIE_STAT_CMF_BTN).getState();
462             assertEquals(state.getClass(), QuantityType.class);
463             assertEquals(0, ((QuantityType<?>) state).intValue());
464             assertEquals(0, dataPoints.getPointByClass(HIE_STAT_CMF_BTN).asInt());
465
466             state = dataPoints.getPointByClass(HIE_STAT_CMF_BTN).getEnum();
467             assertEquals(state.getClass(), StringType.class);
468             assertEquals("Inactive", state.toString());
469             assertEquals("Inactive", dataPoints.getPointByClass(HIE_STAT_CMF_BTN).getEnum().toString());
470
471             // test online code
472             assertTrue(dataPoints.isOnline());
473
474             // test present priority code
475             assertEquals(15, dataPoints.getPointByClass(HIE_TARGET_TEMP).getPresentPriority());
476
477             // test temperature units code (C)
478             BasePoint tempPoint = dataPoints.getPointByClass("'SpTR");
479             assertTrue(tempPoint instanceof BasePoint);
480             assertEquals(SIUnits.CELSIUS, tempPoint.getUnit());
481
482             // test temperature units code (F)
483             tempPoint = dataPoints.getPointByClass("'SpHPcf");
484             assertTrue(tempPoint instanceof BasePoint);
485             assertEquals(ImperialUnits.FAHRENHEIT, tempPoint.getUnit());
486
487             // test temperature units code (K)
488             tempPoint = dataPoints.getPointByClass("'SpHPcf");
489             assertTrue(tempPoint instanceof BasePoint);
490             assertEquals(ImperialUnits.FAHRENHEIT, tempPoint.getUnit());
491
492             tempPoint = dataPoints.getPointByClass("'SpTRShft");
493             assertTrue(tempPoint instanceof BasePoint);
494             assertEquals(Units.KELVIN, tempPoint.getUnit());
495         } catch (RdsCloudException e) {
496             fail(e.getMessage());
497         }
498     }
499
500     @Test
501     public void testRdsPlants() {
502         try {
503             RdsPlants plants = RdsPlants.createFromJson(load("plants"));
504             assertNotNull(plants);
505
506             @Nullable
507             List<PlantInfo> plantList = plants.getPlants();
508             assertNotNull(plantList);
509
510             @Nullable
511             PlantInfo plant;
512             plant = plantList.get(0);
513             assertTrue(plant instanceof PlantInfo);
514             assertEquals("Pd1774247-7de7-4896-ac76-b7e0dd943c40", plant.getId());
515             assertTrue(plant.isOnline());
516
517             plant = plantList.get(1);
518             assertTrue(plant instanceof PlantInfo);
519             assertEquals("Pfaf770c8-abeb-4742-ad65-ead39030d369", plant.getId());
520             assertTrue(plant.isOnline());
521         } catch (RdsCloudException e) {
522             fail(e.getMessage());
523         }
524     }
525 }