]> git.basschouten.com Git - openhab-addons.git/blob
5119593ff228515d928f3cc0079521e84f775b8d
[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 import static org.junit.jupiter.api.Assertions.assertNull;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.Test;
20
21 /**
22  * Unit tests for OverrideRegister model object.
23  *
24  * @author Jørgen Austvik - Initial contribution
25  */
26 @NonNullByDefault
27 public class OverridePlanRegisterTest {
28
29     @Test
30     public void testPutGet() throws NoboDataException {
31         OverridePlan o = OverridePlan.fromH04("H04 4 0 0 -1 -1 0 -1");
32         OverrideRegister sut = new OverrideRegister();
33         sut.put(o);
34         assertEquals(o, sut.get(o.getId()));
35     }
36
37     @Test
38     public void testPutOverwrite() throws NoboDataException {
39         OverridePlan o1 = OverridePlan.fromH04("H04 4 0 0 -1 -1 0 -1");
40         OverridePlan o2 = OverridePlan.fromH04("H04 4 3 0 -1 -1 0 -1");
41         OverrideRegister sut = new OverrideRegister();
42         sut.put(o1);
43         sut.put(o2);
44         assertEquals(o2, sut.get(o2.getId()));
45     }
46
47     @Test
48     public void testRemove() throws NoboDataException {
49         OverridePlan o = OverridePlan.fromH04("H04 4 0 0 -1 -1 0 -1");
50         OverrideRegister sut = new OverrideRegister();
51         sut.put(o);
52         OverridePlan res = sut.remove(o.getId());
53         assertEquals(o, res);
54     }
55
56     @Test
57     public void testRemoveUnknown() {
58         OverrideRegister sut = new OverrideRegister();
59         OverridePlan res = sut.remove(666);
60         assertNull(res);
61     }
62
63     @Test
64     public void testGetUnknown() {
65         OverrideRegister sut = new OverrideRegister();
66         OverridePlan o = sut.get(666);
67         assertNull(o);
68     }
69 }