@Test public void testDeleteSavedSearchesByCustomerIds() throws Exception { SavedReviewerSearchDAO dao = new SavedReviewerSearchDAO(); Connection connection = EasyMock.createStrictMock(Connection.class); Statement statement = EasyMock.createStrictMock(Statement.class); int count = 34; List<Integer> customerIds = new LinkedList<Integer>(); customerIds.add(1); customerIds.add(2); customerIds.add(3); String inClause = QueryUtils.literal(customerIds); EasyMock.expect(connection.createStatement()).andReturn(statement); EasyMock.expect( statement.executeUpdate(SavedReviewerSearchDAO.DELETE_BY_CUSTOMER_IDS_SQL + inClause)) .andReturn(count); statement.close(); EasyMock.expectLastCall(); EasyMock.replay(connection, statement); assertEquals( "Wrong count of deleted rows.", count, dao.deleteByCustomerIds(connection, customerIds)); EasyMock.verify(connection, statement); // null customer list EasyMock.reset(connection, statement); EasyMock.replay(connection, statement); assertEquals("Wrong return value.", 0, dao.deleteByCustomerIds(connection, null)); EasyMock.verify(connection, statement); // empty customer list customerIds.clear(); EasyMock.reset(connection, statement); EasyMock.replay(connection, statement); assertEquals("Wrong return value.", 0, dao.deleteByCustomerIds(connection, customerIds)); EasyMock.verify(connection, statement); }