]> git.basschouten.com Git - openhab-addons.git/blob
ddeb795271fdea98c39a23080c9106b74a10e84f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.luxom.internal.protocol;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19
20 /**
21  *
22  * @author Kris Jespers - Initial contribution
23  */
24 @NonNullByDefault
25 class LuxomCommandTest {
26
27     @Test
28     void parsePulseCommand() {
29         LuxomCommand command = new LuxomCommand("*P,0,1,04");
30
31         assertEquals(LuxomAction.PING, command.getAction());
32         assertEquals("1,04", command.getAddress());
33         assertNull(command.getData());
34     }
35
36     @Test
37     void parsePasswordRequest() {
38         LuxomCommand command = new LuxomCommand(LuxomAction.PASSWORD_REQUEST.getCommand());
39
40         assertEquals(LuxomAction.PASSWORD_REQUEST, command.getAction());
41         assertNull(command.getData());
42     }
43
44     @Test
45     void parseClearCommand() {
46         LuxomCommand command = new LuxomCommand("*C,0,1,04");
47
48         assertEquals(LuxomAction.CLEAR, command.getAction());
49         assertEquals("1,04", command.getAddress());
50         assertNull(command.getData());
51     }
52
53     @Test
54     void parseClearResponse() {
55         LuxomCommand command = new LuxomCommand("@1*C,0,1,04");
56
57         assertEquals(LuxomAction.CLEAR_RESPONSE, command.getAction());
58         assertEquals("1,04", command.getAddress());
59         assertNull(command.getData());
60     }
61
62     @Test
63     void parseClearResponse2() {
64         LuxomCommand command = new LuxomCommand("@1*C,0,1,04");
65
66         assertEquals(LuxomAction.CLEAR_RESPONSE, command.getAction());
67         assertEquals("1,04", command.getAddress());
68         assertNull(command.getData());
69     }
70
71     @Test
72     void parseSetCommand() {
73         LuxomCommand command = new LuxomCommand("*S,0,1,04");
74
75         assertEquals(LuxomAction.SET, command.getAction());
76         assertEquals("1,04", command.getAddress());
77         assertNull(command.getData());
78     }
79
80     @Test
81     void parseSetResponse() {
82         LuxomCommand command = new LuxomCommand("@1*S,0,1,04");
83
84         assertEquals(LuxomAction.SET_RESPONSE, command.getAction());
85         assertEquals("1,04", command.getAddress());
86         assertNull(command.getData());
87     }
88
89     @Test
90     void parseDimCommand() {
91         LuxomCommand command = new LuxomCommand("*A,0,1,04");
92
93         assertEquals(LuxomAction.DATA, command.getAction());
94         assertEquals("1,04", command.getAddress());
95         assertNull(command.getData());
96     }
97
98     @Test
99     void parseDataCommand() {
100         LuxomCommand command = new LuxomCommand("*Z,048");
101
102         assertEquals(LuxomAction.DATA_BYTE, command.getAction());
103         assertEquals("048", command.getData());
104         assertNull(command.getAddress());
105     }
106
107     @Test
108     void parseDataResponseCommand() {
109         LuxomCommand command = new LuxomCommand("@1*Z,048");
110
111         assertEquals(LuxomAction.DATA_BYTE_RESPONSE, command.getAction());
112         assertEquals("048", command.getData());
113         assertNull(command.getAddress());
114     }
115 }