1
1
/*
2
- * Copyright 2002-2013 the original author or authors.
2
+ * Copyright 2002-2016 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.
@@ -49,28 +49,39 @@ public class SqlUpdateTests {
49
49
50
50
private static final String UPDATE =
51
51
"update seat_status set booking_id = null" ;
52
+
52
53
private static final String UPDATE_INT =
53
54
"update seat_status set booking_id = null where performance_id = ?" ;
55
+
54
56
private static final String UPDATE_INT_INT =
55
57
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ?" ;
58
+
56
59
private static final String UPDATE_NAMED_PARAMETERS =
57
60
"update seat_status set booking_id = null where performance_id = :perfId and price_band_id = :priceId" ;
61
+
58
62
private static final String UPDATE_STRING =
59
63
"update seat_status set booking_id = null where name = ?" ;
64
+
60
65
private static final String UPDATE_OBJECTS =
61
66
"update seat_status set booking_id = null where performance_id = ? and price_band_id = ? and name = ? and confirmed = ?" ;
67
+
62
68
private static final String INSERT_GENERATE_KEYS =
63
69
"insert into show (name) values(?)" ;
64
70
65
71
@ Rule
66
72
public ExpectedException thrown = ExpectedException .none ();
67
73
68
74
private DataSource dataSource ;
75
+
69
76
private Connection connection ;
77
+
70
78
private PreparedStatement preparedStatement ;
79
+
71
80
private ResultSet resultSet ;
81
+
72
82
private ResultSetMetaData resultSetMetaData ;
73
83
84
+
74
85
@ Before
75
86
public void setUp () throws Exception {
76
87
dataSource = mock (DataSource .class );
@@ -87,6 +98,7 @@ public void verifyClosed() throws Exception {
87
98
verify (connection ).close ();
88
99
}
89
100
101
+
90
102
@ Test
91
103
public void testUpdate () throws SQLException {
92
104
given (preparedStatement .executeUpdate ()).willReturn (1 );
@@ -192,7 +204,7 @@ public void testUpdateMixed() throws SQLException {
192
204
verify (preparedStatement ).setObject (1 , 1 , Types .NUMERIC );
193
205
verify (preparedStatement ).setObject (2 , 1 , Types .NUMERIC , 2 );
194
206
verify (preparedStatement ).setString (3 , "rod" );
195
- verify (preparedStatement ).setObject (4 , Boolean .TRUE , Types . BOOLEAN );
207
+ verify (preparedStatement ).setBoolean (4 , Boolean .TRUE );
196
208
}
197
209
198
210
@ Test
@@ -231,7 +243,7 @@ public void testUpdateConstructor() throws SQLException {
231
243
verify (preparedStatement ).setObject (1 , 1 , Types .NUMERIC );
232
244
verify (preparedStatement ).setObject (2 , 1 , Types .NUMERIC );
233
245
verify (preparedStatement ).setString (3 , "rod" );
234
- verify (preparedStatement ).setObject (4 , Boolean .TRUE , Types . BOOLEAN );
246
+ verify (preparedStatement ).setBoolean (4 , Boolean .TRUE );
235
247
}
236
248
237
249
@ Test
@@ -360,10 +372,7 @@ public MixedUpdater() {
360
372
}
361
373
362
374
public int run (int performanceId , int type , String name , boolean confirmed ) {
363
- Object [] params =
364
- new Object [] {performanceId , type , name ,
365
- new Boolean (confirmed )};
366
- return update (params );
375
+ return update (performanceId , type , name , confirmed );
367
376
}
368
377
}
369
378
@@ -379,8 +388,7 @@ public GeneratedKeysUpdater() {
379
388
}
380
389
381
390
public int run (String name , KeyHolder generatedKeyHolder ) {
382
- Object [] params = new Object [] {name };
383
- return update (params , generatedKeyHolder );
391
+ return update (new Object [] {name }, generatedKeyHolder );
384
392
}
385
393
}
386
394
@@ -394,10 +402,7 @@ public ConstructorUpdater() {
394
402
}
395
403
396
404
public int run (int performanceId , int type , String name , boolean confirmed ) {
397
- Object [] params =
398
- new Object [] {
399
- performanceId , type , name , new Boolean (confirmed )};
400
- return update (params );
405
+ return update (performanceId , type , name , confirmed );
401
406
}
402
407
}
403
408
0 commit comments