]> git.basschouten.com Git - openhab-addons.git/blob
0a6c5d9cf55305def7ca7186d714f60afda4835d
[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.nest.internal.sdm.dto;
14
15 import static org.hamcrest.CoreMatchers.notNullValue;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
18 import static org.hamcrest.core.Is.is;
19 import static org.openhab.binding.nest.internal.sdm.dto.SDMDataUtil.fromJson;
20
21 import java.io.IOException;
22 import java.util.List;
23
24 import org.eclipse.jdt.annotation.NonNullByDefault;
25 import org.junit.jupiter.api.BeforeEach;
26
27 /**
28  * Tests deserialization of {@link
29  * org.openhab.binding.nest.internal.sdm.dto.SDMListDevicesResponse}s from JSON.
30  *
31  * @author Wouter Born - Initial contribution
32  */
33 @NonNullByDefault
34 public class SDMListDevicesResponseTest extends SDMDeviceTest {
35
36     private List<SDMDevice> devices = List.of();
37
38     @BeforeEach
39     public void deserializeListDevicesResponse() throws IOException {
40         SDMListDevicesResponse response = fromJson("list-devices-response.json", SDMListDevicesResponse.class);
41         assertThat(response, is(notNullValue()));
42
43         devices = response.devices;
44         assertThat(devices, is(notNullValue()));
45         assertThat(devices, hasSize(4));
46     }
47
48     @Override
49     protected SDMDevice getThermostatDevice() throws IOException {
50         return devices.get(0);
51     }
52
53     @Override
54     protected SDMDevice getCameraDevice() throws IOException {
55         return devices.get(1);
56     }
57
58     @Override
59     protected SDMDevice getDisplayDevice() throws IOException {
60         return devices.get(2);
61     }
62
63     @Override
64     protected SDMDevice getDoorbellDevice() throws IOException {
65         return devices.get(3);
66     }
67 }