1 package org.olsr.v1.info.api.dto;
2 
3 import static org.hamcrest.core.IsEqual.equalTo;
4 import static org.hamcrest.core.IsNull.notNullValue;
5 import static org.junit.Assert.assertThat;
6 
7 import org.junit.After;
8 import org.junit.Before;
9 import org.junit.Test;
10 
11 public class TestJsonInfoPudPosition {
12   private JsonInfoPudPosition impl = null;
13 
14   @Before
setUp()15   public void setUp() {
16     this.impl = new JsonInfoPudPosition();
17   }
18 
19   @After
tearDown()20   public void tearDown() {
21     this.impl = null;
22   }
23 
24   @Test(timeout = 8000)
testGettersAndSetters()25   public void testGettersAndSetters() {
26     /* initial */
27     assertThat(this.impl.getPudPosition(), equalTo(new JsonInfoPudPositionEntry()));
28 
29     /* set */
30     final JsonInfoPudPositionEntry entry = new JsonInfoPudPositionEntry();
31     entry.setFix("dummy");
32     this.impl.setPudPosition(entry);
33 
34     /* get */
35     assertThat(this.impl.getPudPosition(), equalTo(entry));
36 
37     this.impl.setPudPosition(null);
38 
39     assertThat(this.impl.getPudPosition(), equalTo(new JsonInfoPudPositionEntry()));
40   }
41 
42   @Test(timeout = 8000)
testEquals()43   public void testEquals() {
44     boolean r;
45     JsonInfoPudPosition other;
46 
47     /* self */
48 
49     r = this.impl.equals(this.impl);
50     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
51 
52     /* null */
53 
54     other = null;
55     r = this.impl.equals(other);
56     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
57 
58     /* wrong object */
59 
60     final Object otherObj = new Object();
61     r = this.impl.equals(otherObj);
62     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
63 
64     /* same */
65 
66     other = new JsonInfoPudPosition();
67     r = this.impl.equals(other);
68     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
69 
70     /* pudPosition */
71 
72     other = new JsonInfoPudPosition();
73     final JsonInfoPudPositionEntry entry = new JsonInfoPudPositionEntry();
74     entry.setFix("dummy");
75     other.setPudPosition(entry);
76     r = this.impl.equals(other);
77     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
78   }
79 
80   @Test(timeout = 8000)
testHashCode()81   public void testHashCode() {
82     int r = this.impl.hashCode();
83     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1805278597)));
84 
85     /* set */
86     final JsonInfoPudPositionEntry entry = new JsonInfoPudPositionEntry();
87     entry.setFix("dummy");
88     this.impl.setPudPosition(entry);
89 
90     r = this.impl.hashCode();
91     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(2056706658)));
92   }
93 
94   @Test(timeout = 8000)
testToString()95   public void testToString() {
96     final String r = this.impl.toString();
97     assertThat(r, notNullValue());
98   }
99 }