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 TestJsonInfoPudPositionEntryTime {
12   private JsonInfoPudPositionEntryTime impl = null;
13 
14   @Before
setUp()15   public void setUp() {
16     this.impl = new JsonInfoPudPositionEntryTime();
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(Integer.valueOf(this.impl.getHour()), equalTo(Integer.valueOf(0)));
28     assertThat(Integer.valueOf(this.impl.getMinute()), equalTo(Integer.valueOf(0)));
29     assertThat(Integer.valueOf(this.impl.getSecond()), equalTo(Integer.valueOf(0)));
30     assertThat(Integer.valueOf(this.impl.getHsec()), equalTo(Integer.valueOf(0)));
31 
32     /* set */
33     this.impl.setHour(1);
34     this.impl.setMinute(2);
35     this.impl.setSecond(3);
36     this.impl.setHsec(4);
37 
38     /* get */
39     assertThat(Integer.valueOf(this.impl.getHour()), equalTo(Integer.valueOf(1)));
40     assertThat(Integer.valueOf(this.impl.getMinute()), equalTo(Integer.valueOf(2)));
41     assertThat(Integer.valueOf(this.impl.getSecond()), equalTo(Integer.valueOf(3)));
42     assertThat(Integer.valueOf(this.impl.getHsec()), equalTo(Integer.valueOf(4)));
43   }
44 
45   @Test(timeout = 8000)
testEquals()46   public void testEquals() {
47     boolean r;
48     JsonInfoPudPositionEntryTime other;
49 
50     r = this.impl.equals(this.impl);
51     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
52 
53     other = null;
54     r = this.impl.equals(other);
55     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
56 
57     final Object otherObj = new Object();
58     r = this.impl.equals(otherObj);
59     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
60 
61     other = new JsonInfoPudPositionEntryTime();
62     r = this.impl.equals(other);
63     assertThat(Boolean.valueOf(r), equalTo(Boolean.TRUE));
64 
65     other = new JsonInfoPudPositionEntryTime();
66     other.setHour(1);
67     r = this.impl.equals(other);
68     assertThat(Boolean.valueOf(r), equalTo(Boolean.FALSE));
69   }
70 
71   @Test(timeout = 8000)
testCompareTo()72   public void testCompareTo() {
73     int r;
74     final JsonInfoPudPositionEntryTime other = new JsonInfoPudPositionEntryTime();
75 
76     /* null */
77 
78     r = this.impl.compareTo(null);
79     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
80 
81     /* hour */
82 
83     int intOrg = this.impl.getHour();
84 
85     this.impl.setHour(1);
86     other.setHour(2);
87     r = this.impl.compareTo(other);
88     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
89 
90     this.impl.setHour(2);
91     other.setHour(1);
92     r = this.impl.compareTo(other);
93     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1)));
94 
95     this.impl.setHour(1);
96     other.setHour(1);
97     r = this.impl.compareTo(other);
98     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(0)));
99 
100     this.impl.setHour(intOrg);
101     other.setHour(intOrg);
102 
103     /* minute */
104 
105     intOrg = this.impl.getMinute();
106 
107     this.impl.setMinute(1);
108     other.setMinute(2);
109     r = this.impl.compareTo(other);
110     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
111 
112     this.impl.setMinute(2);
113     other.setMinute(1);
114     r = this.impl.compareTo(other);
115     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1)));
116 
117     this.impl.setMinute(1);
118     other.setMinute(1);
119     r = this.impl.compareTo(other);
120     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(0)));
121 
122     this.impl.setMinute(intOrg);
123     other.setMinute(intOrg);
124 
125     /* second */
126 
127     intOrg = this.impl.getSecond();
128 
129     this.impl.setSecond(1);
130     other.setSecond(2);
131     r = this.impl.compareTo(other);
132     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
133 
134     this.impl.setSecond(2);
135     other.setSecond(1);
136     r = this.impl.compareTo(other);
137     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1)));
138 
139     this.impl.setSecond(1);
140     other.setSecond(1);
141     r = this.impl.compareTo(other);
142     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(0)));
143 
144     this.impl.setSecond(intOrg);
145     other.setSecond(intOrg);
146 
147     /* hsec */
148 
149     intOrg = this.impl.getHsec();
150 
151     this.impl.setHsec(1);
152     other.setHsec(2);
153     r = this.impl.compareTo(other);
154     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(-1)));
155 
156     this.impl.setHsec(2);
157     other.setHsec(1);
158     r = this.impl.compareTo(other);
159     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(1)));
160 
161     this.impl.setHsec(1);
162     other.setHsec(1);
163     r = this.impl.compareTo(other);
164     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(0)));
165 
166     this.impl.setHsec(intOrg);
167     other.setHsec(intOrg);
168   }
169 
170   @Test(timeout = 8000)
testHashCode()171   public void testHashCode() {
172     int r = this.impl.hashCode();
173     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(923521)));
174 
175     /* set */
176     this.impl.setHour(1);
177     this.impl.setMinute(2);
178     this.impl.setSecond(3);
179     this.impl.setHsec(4);
180 
181     r = this.impl.hashCode();
182     assertThat(Integer.valueOf(r), equalTo(Integer.valueOf(955331)));
183   }
184 
185   @Test(timeout = 8000)
testToString()186   public void testToString() {
187     final String r = this.impl.toString();
188     assertThat(r, notNullValue());
189   }
190 }