]> git.basschouten.com Git - openhab-addons.git/blob
b0394564f0e9d2e03e396c2da5b72be29e571655
[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
14 package org.openhab.binding.nobohub.internal.model;
15
16 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import static org.junit.jupiter.api.Assertions.assertFalse;
18 import static org.junit.jupiter.api.Assertions.assertTrue;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22
23 /**
24  * Unit tests for serial number model object.
25  *
26  * @author Jørgen Austvik - Initial contribution
27  */
28 @NonNullByDefault
29 public class SerialNumberTest {
30
31     @Test
32     public void testIsWellFormed() {
33         assertTrue(new SerialNumber("123123123123").isWellFormed());
34         assertFalse(new SerialNumber("123123123").isWellFormed());
35         assertFalse(new SerialNumber("123 123 123 123").isWellFormed());
36         assertFalse(new SerialNumber("123123123xyz").isWellFormed());
37         assertFalse(new SerialNumber("123123123987").isWellFormed());
38     }
39
40     @Test
41     public void testGetTypeIdentifier() {
42         assertEquals("123", new SerialNumber("123123123123").getTypeIdentifier());
43         assertEquals("Unknown", new SerialNumber("xyz").getTypeIdentifier());
44     }
45
46     @Test
47     public void testGetComponentType() {
48         assertEquals("NTD-4R/DCU-1R", new SerialNumber("186170024143").getComponentType());
49         assertEquals("Nobø Eco Switch", new SerialNumber("234001021010").getComponentType());
50         assertEquals("Unknown, please contact maintainer to add a new type for 123123123123",
51                 new SerialNumber("123123123123").getComponentType());
52         assertEquals("Unknown, please contact maintainer to add a new type for foobar",
53                 new SerialNumber("foobar").getComponentType());
54     }
55 }