]> git.basschouten.com Git - openhab-addons.git/blob
36c1862d4245352dee88553a85860fcd3f8aa444
[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.rfxcom.internal.config;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.junit.jupiter.api.BeforeEach;
18 import org.junit.jupiter.api.Test;
19 import org.junit.jupiter.api.extension.ExtendWith;
20 import org.mockito.junit.jupiter.MockitoExtension;
21 import org.openhab.binding.rfxcom.internal.exceptions.RFXComInvalidParameterException;
22
23 /**
24  * Configuration class for generic devices.
25  *
26  * @author James Hewitt-Thomas - Initial contribution
27  */
28 @ExtendWith(MockitoExtension.class)
29 public class RFXComGenericDeviceConfigurationTest {
30
31     private RFXComGenericDeviceConfiguration config;
32
33     @BeforeEach
34     public void before() {
35         config = new RFXComGenericDeviceConfiguration();
36     }
37
38     @Test
39     public void testNoDeviceId() {
40         config.subType = "PT2262";
41         assertThrows(RFXComInvalidParameterException.class, () -> config.parseAndValidate());
42     }
43
44     @Test
45     public void testNoSubType() {
46         config.deviceId = "90000";
47         assertThrows(RFXComInvalidParameterException.class, () -> config.parseAndValidate());
48     }
49
50     @Test
51     public void testValidConfig() {
52         config.deviceId = "90000";
53         config.subType = "PT2262";
54         assertDoesNotThrow(() -> config.parseAndValidate());
55     }
56 }