2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
14 package org.openhab.binding.nobohub.internal.model;
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;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
24 * Unit tests for serial number model object.
26 * @author Jørgen Austvik - Initial contribution
29 public class SerialNumberTest {
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());
41 public void testGetTypeIdentifier() {
42 assertEquals("123", new SerialNumber("123123123123").getTypeIdentifier());
43 assertEquals("Unknown", new SerialNumber("xyz").getTypeIdentifier());
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());