]> git.basschouten.com Git - openhab-addons.git/blob
4838839b03e6fd71995e0fb807f4abe173eb127e
[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 PositionDatumTest {
30
31     @Nullable
32     private PositionDatum pd1;
33
34     @Nullable
35     private PositionDatum pd2; // different from pd1
36
37     @Nullable
38     private PositionDatum pd3; // same as pd1
39
40     @BeforeEach
41     public void setUp() {
42         pd1 = new PositionDatum(100, 200, 270, 123, 12);
43         pd2 = new PositionDatum(100, 220, 240, 123, 2);
44         pd3 = new PositionDatum(100, 200, 270, 123, 12);
45     }
46
47     @Test
48     public void testHashCode() {
49         PositionDatum p1 = pd1;
50         PositionDatum p2 = pd2;
51         PositionDatum p3 = pd3;
52         if (p1 != null && p2 != null && p3 != null) {
53             assertThat(p1.hashCode(), is(equalTo(p3.hashCode())));
54             assertThat(p2.hashCode(), is(not(equalTo(p3.hashCode()))));
55         } else {
56             assertThat("Should be initialized", false);
57         }
58     }
59
60     @Test
61     public void testEquals() {
62         assertThat(pd1, is(equalTo(pd3)));
63         assertThat(pd2, is(not(equalTo(pd3))));
64         assertThat(pd3, is(not(equalTo(null))));
65     }
66 }