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 WeekProfileRegister model object.
23 * @author Jørgen Austvik - Initial contribution
26 public class WeekProfileRegisterTest {
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();
34 assertEquals(p1, sut.get(p1.getId()));
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();
46 assertEquals(p2, sut.get(p2.getId()));
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();
55 WeekProfile res = sut.remove(p1.getId());
56 assertEquals(p1, res);
60 public void testRemoveUnknown() {
61 WeekProfileRegister sut = new WeekProfileRegister();
62 WeekProfile res = sut.remove(666);
63 assertEquals(null, res);
67 public void testGetUnknown() {
68 WeekProfileRegister sut = new WeekProfileRegister();
69 WeekProfile o = sut.get(666);
70 assertEquals(null, o);
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());
80 assertEquals(false, sut.isEmpty());