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
13 package org.openhab.binding.nobohub.internal.model;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
21 * Unit tests for ZoneRegister model object.
23 * @author Jørgen Austvik - Initial contribution
26 public class ZoneRegisterTest {
29 public void testPutGet() throws NoboDataException {
30 Zone z = Zone.fromH01("H01 1 1. etage 20 22 16 1 -1");
31 ZoneRegister sut = new ZoneRegister();
33 assertEquals(z, sut.get(z.getId()));
37 public void testPutOverwrite() throws NoboDataException {
38 Zone z1 = Zone.fromH01("H01 1 1. etage 20 22 16 1 -1");
39 Zone z2 = Zone.fromH01("H01 1 2. etage 20 22 16 1 -1");
40 ZoneRegister sut = new ZoneRegister();
43 assertEquals(z2, sut.get(z2.getId()));
47 public void testRemove() throws NoboDataException {
48 Zone z = Zone.fromH01("H01 1 1. etage 20 22 16 1 -1");
49 ZoneRegister sut = new ZoneRegister();
51 Zone res = sut.remove(z.getId());
56 public void testRemoveUnknown() {
57 ZoneRegister sut = new ZoneRegister();
58 Zone res = sut.remove(666);
59 assertEquals(null, res);
63 public void testGetUnknown() {
64 ZoneRegister sut = new ZoneRegister();
65 Zone z = sut.get(666);
66 assertEquals(null, z);
70 public void testValues() throws NoboDataException {
71 Zone z1 = Zone.fromH01("H01 1 1. etage 20 22 16 1 -1");
72 Zone z2 = Zone.fromH01("H01 2 2. etage 20 22 16 1 -1");
73 ZoneRegister sut = new ZoneRegister();
76 assertEquals(2, sut.values().size());
77 assertEquals(true, sut.values().contains(z1));
78 assertEquals(true, sut.values().contains(z2));