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.boschshc.internal.devices.bridge;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
22 * Unit tests for {@link JsonRpcRequest}.
24 * @author David Pace - Initial contribution
28 public class JsonRpcRequestTest {
30 private @NonNullByDefault({}) JsonRpcRequest fixture;
33 protected void setUp() throws Exception {
34 fixture = new JsonRpcRequest("2.0", "RE/longPoll", new String[] { "subscriptionId", "20" });
38 public void testConstructor() {
39 assertEquals("2.0", fixture.getJsonrpc());
40 assertEquals("RE/longPoll", fixture.getMethod());
41 assertArrayEquals(new String[] { "subscriptionId", "20" }, fixture.getParams());
45 public void testNoArgConstructor() {
46 fixture = new JsonRpcRequest();
47 assertEquals("", fixture.getJsonrpc());
48 assertEquals("", fixture.getMethod());
49 assertArrayEquals(new String[0], fixture.getParams());
53 public void testSetJsonrpc() {
54 fixture.setJsonrpc("test");
55 assertEquals("test", fixture.getJsonrpc());
59 public void testSetMethod() {
60 fixture.setMethod("RE/subscribe");
61 assertEquals("RE/subscribe", fixture.getMethod());
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());