]> git.basschouten.com Git - openhab-addons.git/blob
e28519c851c15426907be7d9785e765adf6bca08
[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.max.internal.command;
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  * Tests cases for {@link FCommand}.
22  *
23  * @author Marcel Verpaalen - Initial contribution
24  */
25 @NonNullByDefault
26 public class FCommandTest {
27
28     @Test
29     public void prefixTest() {
30         FCommand scmd = new FCommand();
31
32         String commandStr = scmd.getCommandString();
33         String prefix = commandStr.substring(0, 2);
34
35         assertEquals("f:", prefix);
36         assertEquals("f:" + '\r' + '\n', commandStr);
37     }
38
39     @Test
40     public void baseCommandTest() {
41         FCommand scmd = new FCommand("ntp.homematic.com", "nl.ntp.pool.org");
42         String commandStr = scmd.getCommandString();
43         assertEquals("f:ntp.homematic.com,nl.ntp.pool.org" + '\r' + '\n', commandStr);
44     }
45
46     @Test
47     public void fCommandNullTest() {
48         FCommand scmd = new FCommand("ntp.homematic.com", null);
49         String commandStr = scmd.getCommandString();
50         assertEquals("f:ntp.homematic.com" + '\r' + '\n', commandStr);
51
52         scmd = new FCommand(null, "nl.ntp.pool.org");
53         commandStr = scmd.getCommandString();
54         assertEquals("f:nl.ntp.pool.org" + '\r' + '\n', commandStr);
55
56         scmd = new FCommand(null, null);
57         commandStr = scmd.getCommandString();
58         assertEquals("f:" + '\r' + '\n', commandStr);
59     }
60 }