]> git.basschouten.com Git - openhab-addons.git/blob
82b4d1ad8a5281efc84afdb5cadabc029a328655
[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.nanoleaf.internal.model;
14
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.junit.jupiter.api.BeforeEach;
21 import org.junit.jupiter.api.Test;
22
23 /**
24  * Test for global orientation
25  *
26  * @author Jørgen Austvik - Initial contribution
27  */
28 @NonNullByDefault
29 public class GlobalOrientationTest {
30
31     @Nullable
32     GlobalOrientation go1;
33
34     @Nullable
35     GlobalOrientation go2; // Different from go1
36
37     @Nullable
38     GlobalOrientation go3; // Same as go1
39
40     @BeforeEach
41     public void setUp() {
42         go1 = new GlobalOrientation(0, 360, 180);
43         go2 = new GlobalOrientation(0, 360, 267);
44         go3 = new GlobalOrientation(0, 360, 180);
45     }
46
47     @Test
48     public void testHashCode() {
49         GlobalOrientation g1 = go1;
50         GlobalOrientation g2 = go2;
51         GlobalOrientation g3 = go3;
52         if (g1 != null && g2 != null && g3 != null) {
53             assertThat(g1.hashCode(), is(equalTo(g3.hashCode())));
54             assertThat(g2.hashCode(), is(not(equalTo(g3.hashCode()))));
55         } else {
56             assertThat("Should be initialized", false);
57         }
58     }
59
60     @Test
61     public void testEquals() {
62         assertThat(go1, is(equalTo(go3)));
63         assertThat(go2, is(not(equalTo(go3))));
64         assertThat(go3, is(not(equalTo(null))));
65     }
66 }