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.nanoleaf.internal.model;
15 import static org.hamcrest.CoreMatchers.*;
16 import static org.hamcrest.MatcherAssert.assertThat;
18 import java.util.Arrays;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.junit.jupiter.api.BeforeEach;
23 import org.junit.jupiter.api.Test;
26 * Test for global orientation
28 * @author Jørgen Austvik - Initial contribution
31 public class PanelLayoutTest {
34 private PanelLayout pl1;
37 private PanelLayout pl2; // Different from pl1
40 private PanelLayout pl3; // Equal to pl1
44 PositionDatum pd1 = new PositionDatum(100, 200, 270, 123, 12);
45 PositionDatum pd2 = new PositionDatum(100, 220, 240, 123, 2);
46 PositionDatum pd3 = new PositionDatum(100, 200, 270, 123, 12);
48 Layout l1 = new Layout(Arrays.asList(pd1, pd3));
49 Layout l2 = new Layout(Arrays.asList(pd1, pd2));
50 Layout l3 = new Layout(Arrays.asList(pd1, pd3));
52 GlobalOrientation go1 = new GlobalOrientation(0, 360, 180);
54 pl1 = new PanelLayout(go1, l1);
55 pl2 = new PanelLayout(go1, l2);
56 pl3 = new PanelLayout(go1, l3);
60 public void testHashCode() {
64 if (p1 != null && p2 != null && p3 != null) {
65 assertThat(p1.hashCode(), is(equalTo(p3.hashCode())));
66 assertThat(p2.hashCode(), is(not(equalTo(p3.hashCode()))));
68 assertThat("Should be initialized", false);
73 public void testEquals() {
74 assertThat(pl1, is(equalTo(pl3)));
75 assertThat(pl2, is(not(equalTo(pl3))));
76 assertThat(pl3, is(not(equalTo(null))));