Revise JdbcTestUtils method signatures to accept JdbcOperations

Closes gh-31065
This commit is contained in:
Sam Brannen
2023-08-18 10:41:44 +02:00
parent 1a137c2e61
commit 77067d0e6b
2 changed files with 26 additions and 20 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2019 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -31,25 +31,24 @@ import static org.mockito.BDDMockito.given;
*
* @author Phillip Webb
* @since 2.5.4
* @see JdbcTestUtilsIntegrationTests
*/
@ExtendWith(MockitoExtension.class)
class JdbcTestUtilsTests {
@Mock
private JdbcTemplate jdbcTemplate;
JdbcTemplate jdbcTemplate;
@Test
void deleteWithoutWhereClause() throws Exception {
given(jdbcTemplate.update("DELETE FROM person")).willReturn(10);
given(jdbcTemplate.update("DELETE FROM person", new Object[0])).willReturn(10);
int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", null);
assertThat(deleted).isEqualTo(10);
}
@Test
void deleteWithWhereClause() throws Exception {
given(jdbcTemplate.update("DELETE FROM person WHERE name = 'Bob' and age > 25")).willReturn(10);
given(jdbcTemplate.update("DELETE FROM person WHERE name = 'Bob' and age > 25", new Object[0])).willReturn(10);
int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = 'Bob' and age > 25");
assertThat(deleted).isEqualTo(10);
}