]> git.basschouten.com Git - openhab-addons.git/blob
125158a749b209d51330f0daca1241b5b48c7cf1
[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.boschshc.internal.devices.bridge.dto;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.util.Collections;
18 import java.util.List;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23
24 /**
25  * Unit tests for {@link Device}.
26  *
27  * @author David Pace - Initial contribution
28  *
29  */
30 @NonNullByDefault
31 public class DeviceTest {
32
33     public static Device createTestDevice() {
34         Device device = new Device();
35         device.type = "device";
36         device.rootDeviceId = "64-da-a0-02-14-9b";
37         device.id = "hdm:HomeMaticIP:3014F711A00004953859F31B";
38         device.deviceServiceIds = Collections
39                 .unmodifiableList(List.of("PowerMeter", "PowerSwitch", "PowerSwitchProgram", "Routing"));
40         device.manufacturer = "BOSCH";
41         device.roomId = "hz_3";
42         device.deviceModel = "PSM";
43         device.serial = "3014F711A00004953859F31B";
44         device.profile = "GENERIC";
45         device.name = "Coffee Machine";
46         device.status = "AVAILABLE";
47         return device;
48     }
49
50     private @NonNullByDefault({}) Device fixture;
51
52     @BeforeEach
53     void beforeEach() {
54         fixture = createTestDevice();
55     }
56
57     @Test
58     void testIsValid() {
59         assertTrue(Device.isValid(fixture));
60     }
61
62     @Test
63     void testToString() {
64         assertEquals(
65                 "Type device; RootDeviceId: 64-da-a0-02-14-9b; Id: hdm:HomeMaticIP:3014F711A00004953859F31B; Device Service Ids: PowerMeter, PowerSwitch, PowerSwitchProgram, Routing; Manufacturer: BOSCH; Room Id: hz_3; Device Model: PSM; Serial: 3014F711A00004953859F31B; Profile: GENERIC; Name: Coffee Machine; Status: AVAILABLE; Child Device Ids: null ",
66                 fixture.toString());
67     }
68 }