1
1
/**
2
- * Copyright 2009-2018 the original author or authors.
2
+ * Copyright 2009-2019 the original author or authors.
3
3
*
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.
18
18
import static org .junit .jupiter .api .Assertions .*;
19
19
import static org .mockito .Mockito .*;
20
20
21
- import java .sql .Timestamp ;
22
21
import java .time .ZonedDateTime ;
23
22
24
23
import org .junit .jupiter .api .Test ;
@@ -27,59 +26,58 @@ public class ZonedDateTimeTypeHandlerTest extends BaseTypeHandlerTest {
27
26
28
27
private static final TypeHandler <ZonedDateTime > TYPE_HANDLER = new ZonedDateTimeTypeHandler ();
29
28
private static final ZonedDateTime ZONED_DATE_TIME = ZonedDateTime .now ();
30
- private static final Timestamp TIMESTAMP = Timestamp .from (ZONED_DATE_TIME .toInstant ());
31
29
32
30
@ Override
33
31
@ Test
34
32
public void shouldSetParameter () throws Exception {
35
33
TYPE_HANDLER .setParameter (ps , 1 , ZONED_DATE_TIME , null );
36
- verify (ps ).setTimestamp (1 , TIMESTAMP );
34
+ verify (ps ).setObject (1 , ZONED_DATE_TIME );
37
35
}
38
36
39
37
@ Override
40
38
@ Test
41
39
public void shouldGetResultFromResultSetByName () throws Exception {
42
- when (rs .getTimestamp ("column" )).thenReturn (TIMESTAMP );
40
+ when (rs .getObject ("column" , ZonedDateTime . class )).thenReturn (ZONED_DATE_TIME );
43
41
assertEquals (ZONED_DATE_TIME , TYPE_HANDLER .getResult (rs , "column" ));
44
42
verify (rs , never ()).wasNull ();
45
43
}
46
44
47
45
@ Override
48
46
@ Test
49
47
public void shouldGetResultNullFromResultSetByName () throws Exception {
50
- when (rs .getTimestamp ("column" )).thenReturn (null );
48
+ when (rs .getObject ("column" , ZonedDateTime . class )).thenReturn (null );
51
49
assertNull (TYPE_HANDLER .getResult (rs , "column" ));
52
50
verify (rs , never ()).wasNull ();
53
51
}
54
52
55
53
@ Override
56
54
@ Test
57
55
public void shouldGetResultFromResultSetByPosition () throws Exception {
58
- when (rs .getTimestamp ( 1 )).thenReturn (TIMESTAMP );
56
+ when (rs .getObject ( 1 , ZonedDateTime . class )).thenReturn (ZONED_DATE_TIME );
59
57
assertEquals (ZONED_DATE_TIME , TYPE_HANDLER .getResult (rs , 1 ));
60
58
verify (rs , never ()).wasNull ();
61
59
}
62
60
63
61
@ Override
64
62
@ Test
65
63
public void shouldGetResultNullFromResultSetByPosition () throws Exception {
66
- when (rs .getTimestamp ( 1 )).thenReturn (null );
64
+ when (rs .getObject ( 1 , ZonedDateTime . class )).thenReturn (null );
67
65
assertNull (TYPE_HANDLER .getResult (rs , 1 ));
68
66
verify (rs , never ()).wasNull ();
69
67
}
70
68
71
69
@ Override
72
70
@ Test
73
71
public void shouldGetResultFromCallableStatement () throws Exception {
74
- when (cs .getTimestamp ( 1 )).thenReturn (TIMESTAMP );
72
+ when (cs .getObject ( 1 , ZonedDateTime . class )).thenReturn (ZONED_DATE_TIME );
75
73
assertEquals (ZONED_DATE_TIME , TYPE_HANDLER .getResult (cs , 1 ));
76
74
verify (cs , never ()).wasNull ();
77
75
}
78
76
79
77
@ Override
80
78
@ Test
81
79
public void shouldGetResultNullFromCallableStatement () throws Exception {
82
- when (cs .getTimestamp ( 1 )).thenReturn (null );
80
+ when (cs .getObject ( 1 , ZonedDateTime . class )).thenReturn (null );
83
81
assertNull (TYPE_HANDLER .getResult (cs , 1 ));
84
82
verify (cs , never ()).wasNull ();
85
83
}
0 commit comments