]> git.basschouten.com Git - openhab-addons.git/blob
8ce92da6451c8ab264aa39bfc51c2de364935401
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.mielecloud.internal.util;
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
20 /**
21  * @author Björn Lange - Initial Contribution
22  */
23 @NonNullByDefault
24 public class LocaleValidatorTest {
25     @Test
26     public void enIsAValidLanguage() {
27         // given:
28         String language = "en";
29
30         // when:
31         boolean valid = LocaleValidator.isValidLanguage(language);
32
33         // then:
34         assertTrue(valid);
35     }
36
37     @Test
38     public void deIsAValidLanguage() {
39         // given:
40         String language = "de";
41
42         // when:
43         boolean valid = LocaleValidator.isValidLanguage(language);
44
45         // then:
46         assertTrue(valid);
47     }
48
49     @Test
50     public void aFullLocaleIsNotAValidLanguage() {
51         // given:
52         String language = "en_us";
53
54         // when:
55         boolean valid = LocaleValidator.isValidLanguage(language);
56
57         // then:
58         assertFalse(valid);
59     }
60
61     @Test
62     public void textIsNotAValidLanguage() {
63         // given:
64         String language = "Hello World!";
65
66         // when:
67         boolean valid = LocaleValidator.isValidLanguage(language);
68
69         // then:
70         assertFalse(valid);
71     }
72 }