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.Test;
26 import org.openhab.binding.nest.internal.sdm.dto.SDMTraits.SDMRoomInfoTrait;
29 * Tests deserialization of {@link org.openhab.binding.nest.internal.sdm.dto.SDMListRoomsResponse}s
32 * @author Wouter Born - Initial contribution
35 public class SDMListRoomsResponseTest {
38 public void deserializeListDevicesResponse() throws IOException {
39 SDMListRoomsResponse response = fromJson("list-rooms-response.json", SDMListRoomsResponse.class);
40 assertThat(response, is(notNullValue()));
42 List<SDMRoom> rooms = response.rooms;
43 assertThat(rooms, is(notNullValue()));
44 assertThat(rooms, hasSize(2));
46 SDMRoom room = rooms.get(0);
47 assertThat(room, is(notNullValue()));
48 assertThat(room.name.name, is("enterprises/project-id/structures/structure-id/rooms/kitchen-room-id"));
49 SDMTraits traits = room.traits;
50 assertThat(traits.traitList(), hasSize(1));
51 SDMRoomInfoTrait roomInfo = room.traits.roomInfo;
52 assertThat(roomInfo, is(notNullValue()));
53 assertThat(roomInfo.customName, is("Kitchen"));
56 assertThat(room, is(notNullValue()));
57 assertThat(room.name.name, is("enterprises/project-id/structures/structure-id/rooms/living-room-id"));
59 assertThat(traits.traitList(), hasSize(1));
60 roomInfo = room.traits.roomInfo;
61 assertThat(roomInfo, is(notNullValue()));
62 assertThat(roomInfo.customName, is("Living"));