2 * Copyright (c) 2010-2023 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.nest.internal.sdm.dto;
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;
21 import java.io.IOException;
22 import java.util.List;
24 import org.eclipse.jdt.annotation.NonNullByDefault;
25 import org.junit.jupiter.api.BeforeEach;
28 * Tests deserialization of {@link
29 * org.openhab.binding.nest.internal.sdm.dto.SDMListDevicesResponse}s from JSON.
31 * @author Wouter Born - Initial contribution
34 public class SDMListDevicesResponseTest extends SDMDeviceTest {
36 private List<SDMDevice> devices = List.of();
39 public void deserializeListDevicesResponse() throws IOException {
40 SDMListDevicesResponse response = fromJson("list-devices-response.json", SDMListDevicesResponse.class);
41 assertThat(response, is(notNullValue()));
43 devices = response.devices;
44 assertThat(devices, is(notNullValue()));
45 assertThat(devices, hasSize(4));
49 protected SDMDevice getThermostatDevice() throws IOException {
50 return devices.get(0);
54 protected SDMDevice getCameraDevice() throws IOException {
55 return devices.get(1);
59 protected SDMDevice getDisplayDevice() throws IOException {
60 return devices.get(2);
64 protected SDMDevice getDoorbellDevice() throws IOException {
65 return devices.get(3);