1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package info.mikethomas.jfold.unit;
22
23 import info.mikethomas.jfold.MockConnection;
24 import info.mikethomas.jfold.exceptions.QueueInfoException;
25 import info.mikethomas.jfold.util.DateAdapter;
26
27 import java.io.IOException;
28 import java.net.UnknownHostException;
29 import java.text.ParseException;
30
31 import static org.junit.jupiter.api.Assertions.*;
32 import org.junit.jupiter.api.BeforeAll;
33 import org.junit.jupiter.api.Disabled;
34 import org.junit.jupiter.api.Test;
35
36
37
38
39
40
41
42 public class UnitTest {
43
44
45 private static Unit instance;
46
47
48
49
50
51
52
53 @BeforeAll
54 public static void setUpClass() throws IOException, QueueInfoException {
55 var connection = new MockConnection();
56 instance = connection.queueInfo().get(0);
57 }
58
59
60
61
62 @Test
63 public void testGetId() {
64 System.out.println("getId");
65 var expResult = "00";
66 var result = instance.getId();
67 assertEquals(expResult, result);
68 }
69
70
71
72
73 @Test
74 public void testGetState() {
75 System.out.println("getState");
76 var expResult = "RUNNING";
77 var result = instance.getState();
78 assertEquals(expResult, result);
79 }
80
81
82
83
84 @Test
85 public void testGetProject() {
86 System.out.println("getProject");
87 var expResult = 13812;
88 var result = instance.getProject();
89 assertEquals(expResult, result);
90 }
91
92
93
94
95 @Test
96 public void testGetRun() {
97 System.out.println("getRun");
98 var expResult = 0;
99 var result = instance.getRun();
100 assertEquals(expResult, result);
101 }
102
103
104
105
106 @Test
107 public void testGetClone() {
108 System.out.println("getClone");
109 var expResult = 572;
110 var result = instance.getClone();
111 assertEquals(expResult, result);
112 }
113
114
115
116
117 @Test
118 public void testGetGen() {
119 System.out.println("getGen");
120 var expResult = 323;
121 var result = instance.getGen();
122 assertEquals(expResult, result);
123 }
124
125
126
127
128 @Test
129 public void testGetCore() {
130 System.out.println("getCore");
131 var expResult = "0xa7";
132 var result = instance.getCore();
133 assertEquals(expResult, result);
134 }
135
136
137
138
139 @Test
140 public void testGetUnit() {
141 System.out.println("getUnit");
142 var expResult = "0x0000018c80fccb025a981913b4143b0f";
143 var result = instance.getUnit();
144 assertEquals(expResult, result);
145 }
146
147
148
149
150 @Test
151 public void testGetPercentDone() {
152 System.out.println("getPercentDone");
153 var expResult = "0.50%";
154 var result = instance.getPercentDone();
155 assertEquals(expResult, result);
156 }
157
158
159
160
161 @Test
162 public void testGetTotalFrames() {
163 System.out.println("getTotalFrames");
164 var expResult = 0;
165 var result = instance.getTotalFrames();
166 assertEquals(expResult, result);
167 }
168
169
170
171
172 @Test
173 public void testGetFramesDone() {
174 System.out.println("getFramesDone");
175 var expResult = 0;
176 var result = instance.getFramesDone();
177 assertEquals(expResult, result);
178 }
179
180
181
182
183
184
185 @Test
186 public void testGetAssigned() throws ParseException {
187 System.out.println("getAssigned");
188 var expResult = DateAdapter.DATE_FORMAT.parse("2019-01-02T19:02:49Z");
189 var result = instance.getAssigned();
190 assertEquals(expResult, result);
191 }
192
193
194
195
196
197
198 @Test
199 public void testGetTimeout() throws ParseException {
200 System.out.println("getTimeout");
201 var expResult = DateAdapter.DATE_FORMAT.parse("2019-01-07T19:02:49Z");
202 var result = instance.getTimeout();
203 assertEquals(expResult, result);
204 }
205
206
207
208
209
210
211 @Test
212 public void testGetDeadline() throws ParseException {
213 System.out.println("getDeadline");
214 var expResult = DateAdapter.DATE_FORMAT.parse("2019-01-09T19:02:49Z");
215 var result = instance.getDeadline();
216 assertEquals(expResult, result);
217 }
218
219
220
221
222
223
224 @Test
225 public void testGetWs() throws UnknownHostException {
226 System.out.println("getWs");
227 var expResult = "128.252.203.2";
228 var result = instance.getWs().getHostAddress();
229 assertEquals(expResult, result);
230 }
231
232
233
234
235
236
237 @Test
238 public void testGetCs() throws UnknownHostException {
239 System.out.println("getCs");
240 var expResult = "0.0.0.0";
241 var result = instance.getCs().getHostAddress();
242 assertEquals(expResult, result);
243 }
244
245
246
247
248 @Test
249 public void testGetWaitingOn() {
250 System.out.println("getWaitingOn");
251 var expResult = "";
252 var result = instance.getWaitingOn();
253 assertEquals(expResult, result);
254 }
255
256
257
258
259 @Test
260 public void testGetAttempts() {
261 System.out.println("getAttempts");
262 var expResult = 0;
263 var result = instance.getAttempts();
264 assertEquals(expResult, result);
265 }
266
267
268
269
270 @Test
271 public void testGetNextAttempt() {
272 System.out.println("getNextAttempt");
273 var expResult = "0.00 secs";
274 var result = instance.getNextAttempt();
275 assertEquals(expResult, result);
276 }
277
278
279
280
281 @Test
282 public void testGetSlot() {
283 System.out.println("getSlot");
284 var expResult = "00";
285 var result = instance.getSlot();
286 assertEquals(expResult, result);
287 }
288
289
290
291
292 @Test
293 public void testGetEta() {
294 System.out.println("getEta");
295 var expResult = "4.98 days";
296 var result = instance.getEta();
297 assertEquals(expResult, result);
298 }
299
300
301
302
303 @Test
304 public void testGetPpd() {
305 System.out.println("getPpd");
306 var expResult = 348.0;
307 var result = instance.getPpd();
308 assertEquals(expResult, result, 0.001);
309 }
310
311
312
313
314 @Test
315 public void testGetTpf() {
316 System.out.println("getTpf");
317 var expResult = "1 hours 12 mins";
318 var result = instance.getTpf();
319 assertEquals(expResult, result);
320 }
321
322
323
324
325 @Test
326 public void testGetBaseCredit() {
327 System.out.println("getBaseCredit");
328 var expResult = 1740.0;
329 var result = instance.getBaseCredit();
330 assertEquals(expResult, result, 0.001);
331 }
332
333
334
335
336 @Test
337 public void testGetCreditEstimate() {
338 System.out.println("getCreditEstimate");
339 var expResult = 1740.0;
340 var result = instance.getCreditEstimate();
341 assertEquals(expResult, result, 0.001);
342 }
343
344
345
346
347 @Test
348 public void testGetDescription() {
349 System.out.println("getDescription");
350 assertNull(instance.getDescription());
351 }
352
353
354
355
356 @Disabled
357 @Test
358 public void testToString() {
359 System.out.println("toString");
360 var expResult = "";
361 var result = instance.toString();
362 assertEquals(expResult, result);
363
364 fail("The test case is a prototype.");
365 }
366 }