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.luxom.internal.protocol;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
22 * @author Kris Jespers - Initial contribution
25 class LuxomCommandTest {
28 void parsePulseCommand() {
29 LuxomCommand command = new LuxomCommand("*P,0,1,04");
31 assertEquals(LuxomAction.PING, command.getAction());
32 assertEquals("1,04", command.getAddress());
33 assertNull(command.getData());
37 void parsePasswordRequest() {
38 LuxomCommand command = new LuxomCommand(LuxomAction.PASSWORD_REQUEST.getCommand());
40 assertEquals(LuxomAction.PASSWORD_REQUEST, command.getAction());
41 assertNull(command.getData());
45 void parseClearCommand() {
46 LuxomCommand command = new LuxomCommand("*C,0,1,04");
48 assertEquals(LuxomAction.CLEAR, command.getAction());
49 assertEquals("1,04", command.getAddress());
50 assertNull(command.getData());
54 void parseClearResponse() {
55 LuxomCommand command = new LuxomCommand("@1*C,0,1,04");
57 assertEquals(LuxomAction.CLEAR_RESPONSE, command.getAction());
58 assertEquals("1,04", command.getAddress());
59 assertNull(command.getData());
63 void parseClearResponse2() {
64 LuxomCommand command = new LuxomCommand("@1*C,0,1,04");
66 assertEquals(LuxomAction.CLEAR_RESPONSE, command.getAction());
67 assertEquals("1,04", command.getAddress());
68 assertNull(command.getData());
72 void parseSetCommand() {
73 LuxomCommand command = new LuxomCommand("*S,0,1,04");
75 assertEquals(LuxomAction.SET, command.getAction());
76 assertEquals("1,04", command.getAddress());
77 assertNull(command.getData());
81 void parseSetResponse() {
82 LuxomCommand command = new LuxomCommand("@1*S,0,1,04");
84 assertEquals(LuxomAction.SET_RESPONSE, command.getAction());
85 assertEquals("1,04", command.getAddress());
86 assertNull(command.getData());
90 void parseDimCommand() {
91 LuxomCommand command = new LuxomCommand("*A,0,1,04");
93 assertEquals(LuxomAction.DATA, command.getAction());
94 assertEquals("1,04", command.getAddress());
95 assertNull(command.getData());
99 void parseDataCommand() {
100 LuxomCommand command = new LuxomCommand("*Z,048");
102 assertEquals(LuxomAction.DATA_BYTE, command.getAction());
103 assertEquals("048", command.getData());
104 assertNull(command.getAddress());
108 void parseDataResponseCommand() {
109 LuxomCommand command = new LuxomCommand("@1*Z,048");
111 assertEquals(LuxomAction.DATA_BYTE_RESPONSE, command.getAction());
112 assertEquals("048", command.getData());
113 assertNull(command.getAddress());