]> git.basschouten.com Git - openhab-addons.git/blob
4bad02d5308372441836b7a2a7137068b26e7c4e
[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 package org.openhab.binding.nobohub.internal.model;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19
20 /**
21  * Unit tests for ZoneRegister model object.
22  *
23  * @author Jørgen Austvik - Initial contribution
24  */
25 @NonNullByDefault
26 public class ZoneRegisterTest {
27
28     @Test
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();
32         sut.put(z);
33         assertEquals(z, sut.get(z.getId()));
34     }
35
36     @Test
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();
41         sut.put(z1);
42         sut.put(z2);
43         assertEquals(z2, sut.get(z2.getId()));
44     }
45
46     @Test
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();
50         sut.put(z);
51         Zone res = sut.remove(z.getId());
52         assertEquals(z, res);
53     }
54
55     @Test
56     public void testRemoveUnknown() {
57         ZoneRegister sut = new ZoneRegister();
58         Zone res = sut.remove(666);
59         assertEquals(null, res);
60     }
61
62     @Test
63     public void testGetUnknown() {
64         ZoneRegister sut = new ZoneRegister();
65         Zone z = sut.get(666);
66         assertEquals(null, z);
67     }
68
69     @Test
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();
74         sut.put(z1);
75         sut.put(z2);
76         assertEquals(2, sut.values().size());
77         assertEquals(true, sut.values().contains(z1));
78         assertEquals(true, sut.values().contains(z2));
79     }
80 }