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.max.internal.command;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
21 * Tests cases for {@link ZCommand}.
23 * @author Marcel Verpaalen - Initial contribution
26 public class ZCommandTest {
29 public void prefixTest() {
30 ZCommand scmd = new ZCommand(ZCommand.WakeUpType.DEVICE, "0b0da3", 30);
32 String commandStr = scmd.getCommandString();
33 String prefix = commandStr.substring(0, 2);
35 assertEquals("z:", prefix);
39 public void baseCommandTest() {
40 ZCommand scmd = new ZCommand(ZCommand.WakeUpType.DEVICE, "0b0da3", 30);
41 String commandStr = scmd.getCommandString();
42 assertEquals("z:1E,D,0b0da3" + '\r' + '\n', commandStr);
46 public void wakeAllTest() {
47 ZCommand scmd = new ZCommand(ZCommand.WakeUpType.ALL, "0b0da3", 60);
48 String commandStr = scmd.getCommandString();
49 assertEquals("z:3C,A" + '\r' + '\n', commandStr);
51 scmd = ZCommand.wakeupAllDevices();
52 commandStr = scmd.getCommandString();
53 assertEquals("z:1E,A" + '\r' + '\n', commandStr);
55 scmd = ZCommand.wakeupAllDevices(60);
56 commandStr = scmd.getCommandString();
57 assertEquals("z:3C,A" + '\r' + '\n', commandStr);
61 public void wakeRoomTest() {
62 ZCommand scmd = new ZCommand(ZCommand.WakeUpType.ROOM, "01", 30);
63 String commandStr = scmd.getCommandString();
64 assertEquals("z:1E,G,01" + '\r' + '\n', commandStr);
66 scmd = ZCommand.wakeupRoom(1);
67 commandStr = scmd.getCommandString();
68 assertEquals("z:1E,G,01" + '\r' + '\n', commandStr);
70 scmd = ZCommand.wakeupRoom(2, 60);
71 commandStr = scmd.getCommandString();
72 assertEquals("z:3C,G,02" + '\r' + '\n', commandStr);
76 public void wakeDeviceTest() {
77 ZCommand scmd = ZCommand.wakeupDevice("0b0da3");
78 String commandStr = scmd.getCommandString();
79 assertEquals("z:1E,D,0b0da3" + '\r' + '\n', commandStr);
81 scmd = ZCommand.wakeupDevice("0b0da3", 60);
82 commandStr = scmd.getCommandString();
83 assertEquals("z:3C,D,0b0da3" + '\r' + '\n', commandStr);