|
|
|
@ -118,25 +118,24 @@ public class JdbcTestUtilsTests {
@@ -118,25 +118,24 @@ public class JdbcTestUtilsTests {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testDeleteNoWhere() throws Exception { |
|
|
|
|
public void deleteWithoutWhereClause() throws Exception { |
|
|
|
|
given(jdbcTemplate.update("DELETE FROM person")).willReturn(10); |
|
|
|
|
int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", null); |
|
|
|
|
assertThat(deleted, equalTo(10)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void testDeleteWhere() throws Exception { |
|
|
|
|
public void deleteWithWhereClause() throws Exception { |
|
|
|
|
given(jdbcTemplate.update("DELETE FROM person WHERE name = 'Bob' and age > 25")).willReturn(10); |
|
|
|
|
int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = 'Bob' and age > 25"); |
|
|
|
|
assertThat(deleted, equalTo(10)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
public void deleteWhereAndArguments() throws Exception { |
|
|
|
|
public void deleteWithWhereClauseAndArguments() throws Exception { |
|
|
|
|
given(jdbcTemplate.update("DELETE FROM person WHERE name = ? and age > ?", "Bob", 25)).willReturn(10); |
|
|
|
|
int deleted = JdbcTestUtils.deleteFromTableWhere(jdbcTemplate, "person", "name = ? and age > ?", "Bob", 25); |
|
|
|
|
assertThat(deleted, equalTo(10)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|