1
1
/*
2
- * Copyright 2002-2019 the original author or authors.
2
+ * Copyright 2002-2022 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.
31
31
import org .springframework .jdbc .core .SqlParameter ;
32
32
import org .springframework .jdbc .datasource .DriverManagerDataSource ;
33
33
34
- import static java .util .Map .entry ;
35
34
import static org .assertj .core .api .Assertions .assertThat ;
36
35
import static org .assertj .core .api .Assertions .assertThatExceptionOfType ;
37
36
@@ -51,14 +50,6 @@ public void emptySql() {
51
50
operation ::compile );
52
51
}
53
52
54
- @ Test
55
- public void getSql () {
56
- String sql = "select * from mytable" ;
57
- operation .setDataSource (new DriverManagerDataSource ());
58
- operation .setSql (sql );
59
- String strGotten = operation .getSql ();
60
- assertThat (strGotten .equals (sql ));
61
- }
62
53
@ Test
63
54
public void setTypeAfterCompile () {
64
55
operation .setDataSource (new DriverManagerDataSource ());
@@ -87,38 +78,39 @@ public void tooFewParameters() {
87
78
88
79
@ Test
89
80
public void tooFewMapParameters () {
81
+ operation .setDataSource (new DriverManagerDataSource ());
90
82
operation .setSql ("select * from mytable" );
91
83
operation .setTypes (new int [] { Types .INTEGER });
92
84
assertThatExceptionOfType (InvalidDataAccessApiUsageException .class ).isThrownBy (() ->
93
85
operation .validateNamedParameters ((Map <String , String >) null ));
94
86
}
95
87
96
88
@ Test
97
- public void operationConfiguredViaJdbcTemplateMustGetDataSource () throws Exception {
89
+ public void operationConfiguredViaJdbcTemplateMustGetDataSource () {
98
90
operation .setSql ("foo" );
99
91
assertThatExceptionOfType (InvalidDataAccessApiUsageException .class ).isThrownBy (() ->
100
92
operation .compile ())
101
- .withMessageContaining ("ataSource " );
93
+ .withMessageContaining ("'dataSource' " );
102
94
}
103
95
104
96
@ Test
105
97
public void tooManyParameters () {
98
+ operation .setDataSource (new DriverManagerDataSource ());
106
99
operation .setSql ("select * from mytable" );
107
100
assertThatExceptionOfType (InvalidDataAccessApiUsageException .class ).isThrownBy (() ->
108
101
operation .validateParameters (new Object [] { 1 , 2 }));
109
102
}
110
103
@ Test
111
104
public void tooManyMapParameters () {
105
+ operation .setDataSource (new DriverManagerDataSource ());
112
106
operation .setSql ("select * from mytable" );
113
107
assertThatExceptionOfType (InvalidDataAccessApiUsageException .class ).isThrownBy (() ->
114
- operation .validateNamedParameters (Map .ofEntries (
115
- entry ("a" , "b" ),
116
- entry ("c" , "d" )
117
- ) ));
108
+ operation .validateNamedParameters (Map .of ("a" , "b" , "c" , "d" )));
118
109
}
119
110
120
111
@ Test
121
112
public void unspecifiedMapParameters () {
113
+ operation .setDataSource (new DriverManagerDataSource ());
122
114
operation .setSql ("select * from mytable" );
123
115
Map <String , String > params = new HashMap <>();
124
116
params .put ("col1" , "value" );
0 commit comments