]> git.basschouten.com Git - openhab-addons.git/blob
8faec7a90dbd2475f1ea9e8ba6b2e56003954c3f
[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 WeekProfileRegister model object.
22  *
23  * @author Jørgen Austvik - Initial contribution
24  */
25 @NonNullByDefault
26 public class WeekProfileRegisterTest {
27
28     @Test
29     public void testPutGet() throws NoboDataException {
30         WeekProfile p1 = WeekProfile.fromH03(
31                 "H03 1 Default 00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,00000,07001,00000,07001,23000");
32         WeekProfileRegister sut = new WeekProfileRegister();
33         sut.put(p1);
34         assertEquals(p1, sut.get(p1.getId()));
35     }
36
37     @Test
38     public void testPutOverwrite() throws NoboDataException {
39         WeekProfile p1 = WeekProfile.fromH03(
40                 "H03 1 Default 00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,00000,07001,00000,07001,23000");
41         WeekProfile p2 = WeekProfile.fromH03(
42                 "H03 2 HomeOffice 00000,06001,09000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,00000,07001,00000,07001,23000");
43         WeekProfileRegister sut = new WeekProfileRegister();
44         sut.put(p1);
45         sut.put(p2);
46         assertEquals(p2, sut.get(p2.getId()));
47     }
48
49     @Test
50     public void testRemove() throws NoboDataException {
51         WeekProfile p1 = WeekProfile.fromH03(
52                 "H03 1 Default 00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,00000,07001,00000,07001,23000");
53         WeekProfileRegister sut = new WeekProfileRegister();
54         sut.put(p1);
55         WeekProfile res = sut.remove(p1.getId());
56         assertEquals(p1, res);
57     }
58
59     @Test
60     public void testRemoveUnknown() {
61         WeekProfileRegister sut = new WeekProfileRegister();
62         WeekProfile res = sut.remove(666);
63         assertEquals(null, res);
64     }
65
66     @Test
67     public void testGetUnknown() {
68         WeekProfileRegister sut = new WeekProfileRegister();
69         WeekProfile o = sut.get(666);
70         assertEquals(null, o);
71     }
72
73     @Test
74     public void testIsEmpty() throws NoboDataException {
75         WeekProfile p1 = WeekProfile.fromH03(
76                 "H03 1 Default 00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,23000,00000,06001,08000,15001,00000,07001,00000,07001,23000");
77         WeekProfileRegister sut = new WeekProfileRegister();
78         assertEquals(true, sut.isEmpty());
79         sut.put(p1);
80         assertEquals(false, sut.isEmpty());
81     }
82 }