]> git.basschouten.com Git - openhab-addons.git/blob
7d3b43b39b7b4198ad5208ebcc49e205dcea34a4
[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;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
20
21 /**
22  * Unit tests for {@link JsonRpcRequest}.
23  *
24  * @author David Pace - Initial contribution
25  *
26  */
27 @NonNullByDefault
28 public class JsonRpcRequestTest {
29
30     private @NonNullByDefault({}) JsonRpcRequest fixture;
31
32     @BeforeEach
33     protected void setUp() throws Exception {
34         fixture = new JsonRpcRequest("2.0", "RE/longPoll", new String[] { "subscriptionId", "20" });
35     }
36
37     @Test
38     public void testConstructor() {
39         assertEquals("2.0", fixture.getJsonrpc());
40         assertEquals("RE/longPoll", fixture.getMethod());
41         assertArrayEquals(new String[] { "subscriptionId", "20" }, fixture.getParams());
42     }
43
44     @Test
45     public void testNoArgConstructor() {
46         fixture = new JsonRpcRequest();
47         assertEquals("", fixture.getJsonrpc());
48         assertEquals("", fixture.getMethod());
49         assertArrayEquals(new String[0], fixture.getParams());
50     }
51
52     @Test
53     public void testSetJsonrpc() {
54         fixture.setJsonrpc("test");
55         assertEquals("test", fixture.getJsonrpc());
56     }
57
58     @Test
59     public void testSetMethod() {
60         fixture.setMethod("RE/subscribe");
61         assertEquals("RE/subscribe", fixture.getMethod());
62     }
63
64     @Test
65     public void testSetParams() {
66         fixture.setParams(new String[] { "com/bosch/sh/remote/*", null });
67         assertArrayEquals(new String[] { "com/bosch/sh/remote/*", null }, fixture.getParams());
68     }
69 }