]> git.basschouten.com Git - openhab-addons.git/blob
66640da2d3673b1f8361a991a66780a2a25b7ed3
[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     {\
34     'BHA': {\
35     'RETURNCODE': '1',\
36     'SIP': [{\
37     'ENABLE': '10',\
38     'PRIORITIZE_APP': '1',\
39     'REGISTER_URL': '192.168.178.1',\
40     'REGISTER_USER': 'xxxxx',\
41     'REGISTER_PASSWORD': 'yyyyy',\
42     'AUTOCALL_MOTIONSENSOR_URL': 'motion-url',\
43     'AUTOCALL_DOORBELL_URL': 'doorbell-url',\
44     'SPK_VOLUME': '70',\
45     'MIC_VOLUME': '33',\
46     'DTMF': '1',\
47     'relais:1': '0',\
48     'relais:2': '1',\
49     'LIGHT_PASSCODE': 'light-passcode',\
50     'INCOMING_CALL_ENABLE': '0',\
51     'INCOMING_CALL_USER': 'abcde',\
52     'ANC': '1',\
53     'LASTERRORCODE': '901',\
54     'LASTERRORTEXT': 'OK',\
55     'RING_TIME_LIMIT': '60',\
56     'CALL_TIME_LIMIT': '180'\
57     }]\
58     }\
59     }\
60     """;
61     //@formatter:on
62
63     @Test
64     public void testParsing() {
65         SipStatus sipStatus = new SipStatus(sipStatusJson);
66         assertEquals("70", sipStatus.getSpeakerVolume());
67         assertEquals("33", sipStatus.getMicrophoneVolume());
68         assertEquals("901", sipStatus.getLastErrorCode());
69         assertEquals("OK", sipStatus.getLastErrorText());
70         assertEquals("60", sipStatus.getRingTimeLimit());
71         assertEquals("180", sipStatus.getCallTimeLimit());
72     }
73 }