Polishing
This commit is contained in:
@@ -50,7 +50,7 @@ class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
void overridingDifferentClassDefinedForMapping() {
|
||||
BeanPropertyRowMapper mapper = new BeanPropertyRowMapper(Person.class);
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> mapper.setMappedClass(Long.class));
|
||||
.isThrownBy(() -> mapper.setMappedClass(Long.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,7 +104,7 @@ class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
BeanPropertyRowMapper<ExtendedPerson> mapper = new BeanPropertyRowMapper<>(ExtendedPerson.class, true);
|
||||
Mock mock = new Mock();
|
||||
assertThatExceptionOfType(InvalidDataAccessApiUsageException.class)
|
||||
.isThrownBy(() -> mock.getJdbcTemplate().query("select name, age, birth_date, balance from people", mapper));
|
||||
.isThrownBy(() -> mock.getJdbcTemplate().query("select name, age, birth_date, balance from people", mapper));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -112,7 +112,7 @@ class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
|
||||
Mock mock = new Mock(MockType.TWO);
|
||||
assertThatExceptionOfType(TypeMismatchException.class)
|
||||
.isThrownBy(() -> mock.getJdbcTemplate().query(SELECT_NULL_AS_AGE, mapper));
|
||||
.isThrownBy(() -> mock.getJdbcTemplate().query(SELECT_NULL_AS_AGE, mapper));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.sql.SQLException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.dao.IncorrectResultSizeDataAccessException;
|
||||
import org.springframework.jdbc.LobRetrievalFailureException;
|
||||
import org.springframework.jdbc.support.lob.LobCreator;
|
||||
@@ -55,11 +54,9 @@ public class LobSupportTests {
|
||||
|
||||
final SetValuesCalled svc = new SetValuesCalled();
|
||||
|
||||
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(
|
||||
handler) {
|
||||
AbstractLobCreatingPreparedStatementCallback psc = new AbstractLobCreatingPreparedStatementCallback(handler) {
|
||||
@Override
|
||||
protected void setValues(PreparedStatement ps, LobCreator lobCreator)
|
||||
throws SQLException, DataAccessException {
|
||||
protected void setValues(PreparedStatement ps, LobCreator lobCreator) {
|
||||
svc.b = true;
|
||||
}
|
||||
};
|
||||
@@ -73,46 +70,43 @@ public class LobSupportTests {
|
||||
|
||||
@Test
|
||||
public void testAbstractLobStreamingResultSetExtractorNoRows() throws SQLException {
|
||||
ResultSet rset = mock();
|
||||
ResultSet rs = mock();
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
|
||||
lobRse.extractData(rset));
|
||||
verify(rset).next();
|
||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
|
||||
.isThrownBy(() -> lobRse.extractData(rs));
|
||||
verify(rs).next();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbstractLobStreamingResultSetExtractorOneRow() throws SQLException {
|
||||
ResultSet rset = mock();
|
||||
given(rset.next()).willReturn(true, false);
|
||||
ResultSet rs = mock();
|
||||
given(rs.next()).willReturn(true, false);
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||
lobRse.extractData(rset);
|
||||
verify(rset).clearWarnings();
|
||||
lobRse.extractData(rs);
|
||||
verify(rs).clearWarnings();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbstractLobStreamingResultSetExtractorMultipleRows()
|
||||
throws SQLException {
|
||||
ResultSet rset = mock();
|
||||
given(rset.next()).willReturn(true, true, false);
|
||||
public void testAbstractLobStreamingResultSetExtractorMultipleRows() throws SQLException {
|
||||
ResultSet rs = mock();
|
||||
given(rs.next()).willReturn(true, true, false);
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(false);
|
||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class).isThrownBy(() ->
|
||||
lobRse.extractData(rset));
|
||||
verify(rset).clearWarnings();
|
||||
assertThatExceptionOfType(IncorrectResultSizeDataAccessException.class)
|
||||
.isThrownBy(() -> lobRse.extractData(rs));
|
||||
verify(rs).clearWarnings();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAbstractLobStreamingResultSetExtractorCorrectException()
|
||||
throws SQLException {
|
||||
ResultSet rset = mock();
|
||||
given(rset.next()).willReturn(true);
|
||||
public void testAbstractLobStreamingResultSetExtractorCorrectException() throws SQLException {
|
||||
ResultSet rs = mock();
|
||||
given(rs.next()).willReturn(true);
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = getResultSetExtractor(true);
|
||||
assertThatExceptionOfType(LobRetrievalFailureException.class).isThrownBy(() ->
|
||||
lobRse.extractData(rset));
|
||||
assertThatExceptionOfType(LobRetrievalFailureException.class)
|
||||
.isThrownBy(() -> lobRse.extractData(rs));
|
||||
}
|
||||
|
||||
private AbstractLobStreamingResultSetExtractor<Void> getResultSetExtractor(final boolean ex) {
|
||||
AbstractLobStreamingResultSetExtractor<Void> lobRse = new AbstractLobStreamingResultSetExtractor<>() {
|
||||
|
||||
@Override
|
||||
protected void streamData(ResultSet rs) throws SQLException, IOException {
|
||||
if (ex) {
|
||||
@@ -125,4 +119,5 @@ public class LobSupportTests {
|
||||
};
|
||||
return lobRse;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user