]> git.basschouten.com Git - openhab-addons.git/blob
06ef3fb8cdd3534fd0e754e549f9116d811fde8e
[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.doorbird.internal;
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 import org.openhab.binding.doorbird.internal.api.SipStatus;
20
21 /**
22  * The {@link SipStatusTest} is responsible for testing the functionality
23  * of Doorbird "sipStatus" message parsing.
24  *
25  * @author Mark Hilbush - Initial contribution
26  */
27 @NonNullByDefault
28 public class SipStatusTest {
29
30     private final String sipStatusJson =
31     //@formatter:off
32     "{" +
33         "'BHA': {" +
34             "'RETURNCODE': '1'," +
35             "'SIP': [{" +
36             "'ENABLE': '10'," +
37             "'PRIORITIZE_APP': '1'," +
38             "'REGISTER_URL': '192.168.178.1'," +
39             "'REGISTER_USER': 'xxxxx'," +
40             "'REGISTER_PASSWORD': 'yyyyy'," +
41             "'AUTOCALL_MOTIONSENSOR_URL': 'motion-url'," +
42             "'AUTOCALL_DOORBELL_URL': 'doorbell-url'," +
43             "'SPK_VOLUME': '70'," +
44             "'MIC_VOLUME': '33'," +
45             "'DTMF': '1'," +
46             "'relais:1': '0'," +
47             "'relais:2': '1'," +
48             "'LIGHT_PASSCODE': 'light-passcode'," +
49             "'INCOMING_CALL_ENABLE': '0'," +
50             "'INCOMING_CALL_USER': 'abcde'," +
51             "'ANC': '1'," +
52             "'LASTERRORCODE': '901'," +
53             "'LASTERRORTEXT': 'OK'," +
54             "'RING_TIME_LIMIT': '60'," +
55             "'CALL_TIME_LIMIT': '180'" +
56             "}]" +
57         "}" +
58     "}";
59     //@formatter:on
60
61     @Test
62     public void testParsing() {
63         SipStatus sipStatus = new SipStatus(sipStatusJson);
64         assertEquals("70", sipStatus.getSpeakerVolume());
65         assertEquals("33", sipStatus.getMicrophoneVolume());
66         assertEquals("901", sipStatus.getLastErrorCode());
67         assertEquals("OK", sipStatus.getLastErrorText());
68         assertEquals("60", sipStatus.getRingTimeLimit());
69         assertEquals("180", sipStatus.getCallTimeLimit());
70     }
71 }