|
|
|
@ -55,7 +55,6 @@ import static org.mockito.Mockito.verify; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class SqlQueryTests { |
|
|
|
class SqlQueryTests { |
|
|
|
|
|
|
|
|
|
|
|
// FIXME inline?
|
|
|
|
|
|
|
|
private static final String SELECT_ID = |
|
|
|
private static final String SELECT_ID = |
|
|
|
"select id from custmr"; |
|
|
|
"select id from custmr"; |
|
|
|
private static final String SELECT_ID_WHERE = |
|
|
|
private static final String SELECT_ID_WHERE = |
|
|
|
@ -163,13 +162,11 @@ class SqlQueryTests { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
@SuppressWarnings("removal") |
|
|
|
|
|
|
|
void testStringQueryWithResults() throws Exception { |
|
|
|
void testStringQueryWithResults() throws Exception { |
|
|
|
String[] dbResults = new String[] { "alpha", "beta", "charlie" }; |
|
|
|
String[] dbResults = new String[] { "alpha", "beta", "charlie" }; |
|
|
|
given(resultSet.next()).willReturn(true, true, true, false); |
|
|
|
given(resultSet.next()).willReturn(true, true, true, false); |
|
|
|
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]); |
|
|
|
given(resultSet.getString(1)).willReturn(dbResults[0], dbResults[1], dbResults[2]); |
|
|
|
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME); |
|
|
|
StringQuery query = new StringQuery(dataSource, SELECT_FORENAME); |
|
|
|
query.setRowsExpected(3); |
|
|
|
|
|
|
|
String[] results = query.run(); |
|
|
|
String[] results = query.run(); |
|
|
|
assertThat(results).isEqualTo(dbResults); |
|
|
|
assertThat(results).isEqualTo(dbResults); |
|
|
|
verify(connection).prepareStatement(SELECT_FORENAME); |
|
|
|
verify(connection).prepareStatement(SELECT_FORENAME); |
|
|
|
|