Rely on automatic boxing/unboxing in tests

Closes gh-29414
This commit is contained in:
Kulwant Singh
2022-11-02 01:11:28 +01:00
committed by Sam Brannen
parent 7d68d0625c
commit b2c8546013
35 changed files with 214 additions and 214 deletions

View File

@@ -238,7 +238,7 @@ public class JdbcTemplateQueryTests {
String sql = "SELECT AGE FROM CUSTMR WHERE ID = 3";
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getInt(1)).willReturn(22);
int i = this.template.queryForObject(sql, Integer.class).intValue();
int i = this.template.queryForObject(sql, Integer.class);
assertThat(i).as("Return of an int").isEqualTo(22);
verify(this.resultSet).close();
verify(this.statement).close();
@@ -260,7 +260,7 @@ public class JdbcTemplateQueryTests {
String sql = "SELECT AGE FROM CUSTMR WHERE ID = 3";
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getLong(1)).willReturn(87L);
long l = this.template.queryForObject(sql, Long.class).longValue();
long l = this.template.queryForObject(sql, Long.class);
assertThat(l).as("Return of a long").isEqualTo(87);
verify(this.resultSet).close();
verify(this.statement).close();
@@ -395,7 +395,7 @@ public class JdbcTemplateQueryTests {
String sql = "SELECT AGE FROM CUSTMR WHERE ID = ?";
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getInt(1)).willReturn(22);
int i = this.template.queryForObject(sql, Integer.class, 3).intValue();
int i = this.template.queryForObject(sql, Integer.class, 3);
assertThat(i).as("Return of an int").isEqualTo(22);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();
@@ -407,7 +407,7 @@ public class JdbcTemplateQueryTests {
String sql = "SELECT AGE FROM CUSTMR WHERE ID = ?";
given(this.resultSet.next()).willReturn(true, false);
given(this.resultSet.getLong(1)).willReturn(87L);
long l = this.template.queryForObject(sql, Long.class, 3).longValue();
long l = this.template.queryForObject(sql, Long.class, 3);
assertThat(l).as("Return of a long").isEqualTo(87);
verify(this.preparedStatement).setObject(1, 3);
verify(this.resultSet).close();

View File

@@ -214,13 +214,13 @@ public class JdbcTemplateTests {
JdbcTemplate template = new JdbcTemplate();
template.setDataSource(this.dataSource);
if (fetchSize != null) {
template.setFetchSize(fetchSize.intValue());
template.setFetchSize(fetchSize);
}
if (maxRows != null) {
template.setMaxRows(maxRows.intValue());
template.setMaxRows(maxRows);
}
if (queryTimeout != null) {
template.setQueryTimeout(queryTimeout.intValue());
template.setQueryTimeout(queryTimeout);
}
jdbcTemplateCallback.doInJdbcTemplate(template, sql, sh);
@@ -232,13 +232,13 @@ public class JdbcTemplateTests {
}
if (fetchSize != null) {
verify(this.preparedStatement).setFetchSize(fetchSize.intValue());
verify(this.preparedStatement).setFetchSize(fetchSize);
}
if (maxRows != null) {
verify(this.preparedStatement).setMaxRows(maxRows.intValue());
verify(this.preparedStatement).setMaxRows(maxRows);
}
if (queryTimeout != null) {
verify(this.preparedStatement).setQueryTimeout(queryTimeout.intValue());
verify(this.preparedStatement).setQueryTimeout(queryTimeout);
}
if (argument != null) {
verify(this.preparedStatement).setObject(1, argument);
@@ -362,10 +362,10 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeUpdate()).willReturn(rowsAffected);
int actualRowsAffected = this.template.update(sql,
4, new SqlParameterValue(Types.NUMERIC, 2, Float.valueOf(1.4142f)));
4, new SqlParameterValue(Types.NUMERIC, 2, 1.4142f));
assertThat(actualRowsAffected == rowsAffected).as("Actual rows affected is correct").isTrue();
verify(this.preparedStatement).setObject(1, 4);
verify(this.preparedStatement).setObject(2, Float.valueOf(1.4142f), Types.NUMERIC, 2);
verify(this.preparedStatement).setObject(2, 1.4142f, Types.NUMERIC, 2);
verify(this.preparedStatement).close();
verify(this.connection).close();
}
@@ -759,7 +759,7 @@ public class JdbcTemplateTests {
given(this.preparedStatement.executeBatch()).willReturn(rowsAffected1, rowsAffected2);
mockDatabaseMetaData(true);
ParameterizedPreparedStatementSetter<Integer> setter = (ps, argument) -> ps.setInt(1, argument.intValue());
ParameterizedPreparedStatementSetter<Integer> setter = (ps, argument) -> ps.setInt(1, argument);
JdbcTemplate template = new JdbcTemplate(this.dataSource, false);
int[][] actualRowsAffected = template.batchUpdate(sql, ids, 2, setter);

View File

@@ -265,7 +265,7 @@ public class NamedParameterQueryTests {
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("id", 3);
int i = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id", params, Integer.class).intValue();
int i = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id", params, Integer.class);
assertThat(i).as("Return of an int").isEqualTo(22);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID = ?");
@@ -279,7 +279,7 @@ public class NamedParameterQueryTests {
given(resultSet.getLong(1)).willReturn(87L);
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(new ParameterBean(3));
long l = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id", params, Long.class).longValue();
long l = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id", params, Long.class);
assertThat(l).as("Return of a long").isEqualTo(87);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID = ?");
@@ -293,7 +293,7 @@ public class NamedParameterQueryTests {
given(resultSet.getLong(1)).willReturn(87L);
BeanPropertySqlParameterSource params = new BeanPropertySqlParameterSource(new ParameterCollectionBean(3, 5));
long l = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID IN (:ids)", params, Long.class).longValue();
long l = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID IN (:ids)", params, Long.class);
assertThat(l).as("Return of a long").isEqualTo(87);
verify(connection).prepareStatement("SELECT AGE FROM CUSTMR WHERE ID IN (?, ?)");