Skip to content

Commit 9931f44

Browse files
committed
Polishing
(cherry picked from commit 2aae0a4)
1 parent fc085e8 commit 9931f44

File tree

2 files changed

+26
-31
lines changed

2 files changed

+26
-31
lines changed

spring-jdbc/src/test/java/org/springframework/jdbc/core/BeanPropertyRowMapperTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
5050
void overridingDifferentClassDefinedForMapping() {
5151
BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
5252
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
53-
.isThrownBy(() -> mapper.setMappedClass(Long.class));
53+
.isThrownBy(() -> mapper.setMappedClass(Long.class));
5454
}
5555

5656
@Test
@@ -104,15 +104,15 @@ void mappingWithUnpopulatedFieldsNotAccepted() throws Exception {
104104
BeanPropertyRowMapper<ExtendedPerson> mapper = new BeanPropertyRowMapper<>(ExtendedPerson.class, true);
105105
Mock mock = new Mock();
106106
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
107-
.isThrownBy(() -> mock.getJdbcTemplate().query("select name, age, birth_date, balance from people", mapper));
107+
.isThrownBy(() -> mock.getJdbcTemplate().query("select name, age, birth_date, balance from people", mapper));
108108
}
109109

110110
@Test
111111
void mappingNullValue() throws Exception {
112112
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
113113
Mock mock = new Mock(MockType.TWO);
114114
assertThatExceptionOfType(TypeMismatchException.class)
115-
.isThrownBy(() -> mock.getJdbcTemplate().query(SELECT_NULL_AS_AGE, mapper));
115+
.isThrownBy(() -> mock.getJdbcTemplate().query(SELECT_NULL_AS_AGE, mapper));
116116
}
117117

118118
@Test

spring-jdbc/src/test/java/org/springframework/jdbc/core/support/LobSupportTests.java

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2019 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,7 +23,6 @@
2323

2424
import org.junit.jupiter.api.Test;
2525

26-
import org.springframework.dao.DataAccessException;
2726
import org.springframework.dao.IncorrectResultSizeDataAccessException;
2827
import org.springframework.jdbc.LobRetrievalFailureException;
2928
import org.springframework.jdbc.support.lob.LobCreator;
@@ -55,11 +54,9 @@ class SetValuesCalled {
5554

5655
final SetValuesCalled svc = new SetValuesCalled();
5756

58-
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(
59-
handler) {
57+
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(handler) {
6058
@Override
61-
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
62-
throws SQLException, DataAccessException {
59+
protected void setValues(PreparedStatement ps, LobCreator lobCreator) {
6360
svc.b = true;
6461
}
6562
};
@@ -73,46 +70,43 @@ protected void setValues(PreparedStatement ps, LobCreator lobCreator)
7370

7471
@Test
7572
public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
76-
ResultSet rset = mock(ResultSet.class);
73+
ResultSet rs = mock(ResultSet.class);
7774
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
78-
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
79-
lobRse.extractData(rset));
80-
verify(rset).next();
75+
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
76+
.isThrownBy(() -> lobRse.extractData(rs));
77+
verify(rs).next();
8178
}
8279

8380
@Test
8481
public void testAbstractLobStreamingResultSetExtractorOneRow() throws SQLException {
85-
ResultSet rset = mock(ResultSet.class);
86-
given(rset.next()).willReturn(true, false);
82+
ResultSet rs = mock(ResultSet.class);
83+
given(rs.next()).willReturn(true, false);
8784
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
88-
lobRse.extractData(rset);
89-
verify(rset).clearWarnings();
85+
lobRse.extractData(rs);
86+
verify(rs).clearWarnings();
9087
}
9188

9289
@Test
93-
public void testAbstractLobStreamingResultSetExtractorMultipleRows()
94-
throws SQLException {
95-
ResultSet rset = mock(ResultSet.class);
96-
given(rset.next()).willReturn(true, true, false);
90+
public void testAbstractLobStreamingResultSetExtractorMultipleRows() throws SQLException {
91+
ResultSet rs = mock(ResultSet.class);
92+
given(rs.next()).willReturn(true, true, false);
9793
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
98-
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
99-
lobRse.extractData(rset));
100-
verify(rset).clearWarnings();
94+
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
95+
.isThrownBy(() -> lobRse.extractData(rs));
96+
verify(rs).clearWarnings();
10197
}
10298

10399
@Test
104-
public void testAbstractLobStreamingResultSetExtractorCorrectException()
105-
throws SQLException {
106-
ResultSet rset = mock(ResultSet.class);
107-
given(rset.next()).willReturn(true);
100+
public void testAbstractLobStreamingResultSetExtractorCorrectException() throws SQLException {
101+
ResultSet rs = mock(ResultSet.class);
102+
given(rs.next()).willReturn(true);
108103
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
109-
assertThatExceptionOfType(LobRetrievalFailureException.class).isThrownBy(() ->
110-
lobRse.extractData(rset));
104+
assertThatExceptionOfType(LobRetrievalFailureException.class)
105+
.isThrownBy(() -> lobRse.extractData(rs));
111106
}
112107

113108
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
114109
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<Void>() {
115-
116110
@Override
117111
protected void streamData(ResultSet rs) throws SQLException, IOException {
118112
if (ex) {
@@ -125,4 +119,5 @@ protected void streamData(ResultSet rs) throws SQLException, IOException {
125119
};
126120
return lobRse;
127121
}
122+
128123
}

0 commit comments

Comments
 (0)