1
1
/**
2
2
* Copyright (C) 2024 Patrice Brend'amour <[email protected] >
3
- *
3
+ * <p>
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
6
6
* You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
7
+ * <p>
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ * <p>
10
10
* Unless required by applicable law or agreed to in writing, software
11
11
* distributed under the License is distributed on an "AS IS" BASIS,
12
12
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
15
*/
16
16
package de .brendamour .jpasskit ;
17
17
18
- import static de .brendamour .jpasskit .passes .PKGenericPassTest .SOME ;
19
- import static de .brendamour .jpasskit .passes .PKGenericPassTest .field ;
20
- import java .time .Instant ;
21
- import static org .assertj .core .api .Assertions .assertThat ;
22
- import static org .mockito .Mockito .mock ;
23
- import static org .mockito .Mockito .when ;
18
+ import com .google .common .collect .ImmutableMap ;
19
+ import de .brendamour .jpasskit .enums .PKBarcodeFormat ;
20
+ import de .brendamour .jpasskit .enums .PKTransitType ;
21
+ import de .brendamour .jpasskit .passes .*;
22
+ import org .testng .Assert ;
23
+ import org .testng .annotations .BeforeMethod ;
24
+ import org .testng .annotations .Test ;
24
25
25
- import java .awt .Color ;
26
+ import java .awt .* ;
26
27
import java .net .MalformedURLException ;
27
28
import java .net .URL ;
29
+ import java .time .Instant ;
28
30
import java .util .ArrayList ;
29
31
import java .util .Arrays ;
30
32
import java .util .List ;
31
33
import java .util .Map ;
32
34
33
- import de .brendamour .jpasskit .enums .PKTransitType ;
34
- import de .brendamour .jpasskit .passes .PKBoardingPass ;
35
- import de .brendamour .jpasskit .passes .PKCoupon ;
36
- import de .brendamour .jpasskit .passes .PKEventTicket ;
37
- import de .brendamour .jpasskit .passes .PKGenericPass ;
38
- import de .brendamour .jpasskit .passes .PKGenericPassBuilder ;
39
- import de .brendamour .jpasskit .passes .PKStoreCard ;
40
- import org .testng .Assert ;
41
- import org .testng .annotations .BeforeMethod ;
42
- import org .testng .annotations .Test ;
43
-
44
- import com .google .common .collect .ImmutableMap ;
45
-
46
- import de .brendamour .jpasskit .enums .PKBarcodeFormat ;
35
+ import static de .brendamour .jpasskit .passes .PKGenericPassTest .SOME ;
36
+ import static de .brendamour .jpasskit .passes .PKGenericPassTest .field ;
37
+ import static org .assertj .core .api .Assertions .assertThat ;
38
+ import static org .mockito .Mockito .mock ;
39
+ import static org .mockito .Mockito .when ;
47
40
48
41
public class PKPassTest {
49
42
@@ -67,6 +60,11 @@ public class PKPassTest {
67
60
private static final Map <String , Object > USER_INFO = ImmutableMap .<String , Object > of ("name" , "John Doe" );
68
61
private static final Instant EXPIRATION_DATE = Instant .now ();
69
62
private static final long ASSOCIATED_STORE_IDENTIFIER = 1L ;
63
+ private static final PKRelevantDates RELEVANT_DATES = PKRelevantDates .builder ()
64
+ .date (Instant .now ())
65
+ .startDate (Instant .now ().minusSeconds (3600 ))
66
+ .endDate (Instant .now ().plusSeconds (7200 ))
67
+ .build ();
70
68
71
69
private PKPassBuilder builder ;
72
70
@@ -145,6 +143,7 @@ public void test_gettersBasic() {
145
143
assertThat (pass .getUserInfo ()).isNull ();
146
144
assertThat (pass .getExpirationDate ()).isNull ();
147
145
assertThat (pass .getBarcodes ()).isNotNull ().isEmpty ();
146
+ assertThat (pass .getRelevantDates ()).isNull ();
148
147
}
149
148
150
149
@ Test
@@ -180,6 +179,19 @@ public void test_getters() {
180
179
assertThat (this .builder .isValid ()).isFalse ();
181
180
}
182
181
182
+ @ Test
183
+ public void test_getRelevantDates () {
184
+ assertThat (this .builder
185
+ .relevantDates (RELEVANT_DATES )
186
+ .build ()
187
+ .getRelevantDates ()).isEqualTo (RELEVANT_DATES );
188
+
189
+ assertThat (this .builder
190
+ .relevantDates ((PKRelevantDates ) null )
191
+ .build ()
192
+ .getRelevantDates ()).isNull ();
193
+ }
194
+
183
195
@ Test
184
196
public void test_getBackgroundColor () {
185
197
assertThat (this .builder
@@ -275,8 +287,7 @@ public void test_getGeneric() {
275
287
276
288
PKPass clone = PKPass .builder (pass ).build ();
277
289
278
- assertThat (clone )
279
- .isEqualToComparingFieldByFieldRecursively (pass );
290
+ assertThat (clone ).usingRecursiveComparison ().isEqualTo (pass );
280
291
}
281
292
282
293
@ Test
@@ -293,8 +304,7 @@ public void test_getEventTicket() {
293
304
294
305
PKPass clone = PKPass .builder (pass ).build ();
295
306
296
- assertThat (clone )
297
- .isEqualToComparingFieldByFieldRecursively (pass );
307
+ assertThat (clone ).usingRecursiveComparison ().isEqualTo (pass );
298
308
}
299
309
300
310
@ Test
@@ -311,8 +321,7 @@ public void test_getCoupon() {
311
321
312
322
PKPass clone = PKPass .builder (pass ).build ();
313
323
314
- assertThat (clone )
315
- .isEqualToComparingFieldByFieldRecursively (pass );
324
+ assertThat (clone ).usingRecursiveComparison ().isEqualTo (pass );
316
325
}
317
326
318
327
@ Test
@@ -329,8 +338,7 @@ public void test_getStoreCard() {
329
338
330
339
PKPass clone = PKPass .builder (pass ).build ();
331
340
332
- assertThat (clone )
333
- .isEqualToComparingFieldByFieldRecursively (pass );
341
+ assertThat (clone ).usingRecursiveComparison ().isEqualTo (pass );
334
342
}
335
343
336
344
@ Test
@@ -347,8 +355,7 @@ public void test_getBoardingPass() {
347
355
348
356
PKPass clone = PKPass .builder (pass ).build ();
349
357
350
- assertThat (clone )
351
- .isEqualToComparingFieldByFieldRecursively (pass );
358
+ assertThat (clone ).usingRecursiveComparison ().isEqualTo (pass );
352
359
}
353
360
354
361
private static URL asUrl (String value ) {
0 commit comments