]> git.basschouten.com Git - openhab-addons.git/blob
3698a461527f7e05055d1c884de0de20e89da21b
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.netatmo.internal.api.data;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.BINDING_ID;
17
18 import java.net.URI;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22
23 /**
24  * @author GaĆ«l L'hopital - Initial contribution
25  */
26 @NonNullByDefault
27 public class ModuleTypeTest {
28     public URI getConfigDescription(ModuleType mt) {
29         if (mt == ModuleType.WELCOME || mt == ModuleType.PRESENCE || mt == ModuleType.DOORBELL) {
30             // This did not exist prior to PR #16492
31             return URI.create(BINDING_ID + ":camera");
32         }
33         // This was previous method for calculating configuration URI
34         return URI.create(BINDING_ID + ":"
35                 + (mt == ModuleType.ACCOUNT ? "api_bridge"
36                         : mt == ModuleType.HOME ? "home"
37                                 : (mt.isLogical() ? "virtual"
38                                         : ModuleType.UNKNOWN == mt.getBridge() ? "configurable" : "device")));
39     }
40
41     @Test
42     public void checkConfigDescription() {
43         ModuleType.AS_SET.stream().forEach(mt -> {
44             if (mt != ModuleType.WELCOME) {
45                 URI confDesc = mt.configDescription;
46                 assertEquals(getConfigDescription(mt), confDesc);
47             }
48         });
49     }
50 }