### Question:
TableQuery extends AbstractTransactionalQuery implements
        QueryDelegate, QueryDelegate.RowIdChangeNotifier { @Override public boolean containsRowWithKey(Object... keys) throws SQLException { ArrayList<Filter> filtersAndKeys = new ArrayList<Filter>(); if (filters != null) { filtersAndKeys.addAll(filters); } int ix = 0; for (String colName : primaryKeyColumns) { filtersAndKeys.add(new Equal(colName, keys[ix])); ix++; } StatementHelper sh = sqlGenerator.generateSelectQuery( getFullTableName(), filtersAndKeys, orderBys, 0, 0, "*"); boolean shouldCloseTransaction = false; if (!isInTransaction()) { shouldCloseTransaction = true; beginTransaction(); } ResultSet rs = null; try { rs = executeQuery(sh); boolean contains = rs.next(); return contains; } finally { try { if (rs != null) { releaseConnection(null, rs.getStatement(), rs); } } finally { if (shouldCloseTransaction) { commit(); } } } } TableQuery(String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator);  TableQuery(String catalogName, String schemaName, String tableName,
            JDBCConnectionPool connectionPool, SQLGenerator sqlGenerator);  TableQuery(String tableName, JDBCConnectionPool connectionPool); protected  TableQuery(String catalogName, String schemaName,
            String tableName, JDBCConnectionPool connectionPool,
            SQLGenerator sqlGenerator, boolean escapeNames); @Override int getCount(); @Override ResultSet getResults(int offset, int pagelength); @Override boolean implementationRespectsPagingLimits(); @Override int storeRow(RowItem row); RowId storeRowImmediately(RowItem row); @Override void setFilters(List<Filter> filters); @Override void setOrderBy(List<OrderBy> orderBys); @Override void beginTransaction(); @Override void commit(); @Override void rollback(); @Override List<String> getPrimaryKeyColumns(); String getVersionColumn(); void setVersionColumn(String column); String getTableName(); String getCatalogName(); String getSchemaName(); SQLGenerator getSqlGenerator(); @Override boolean removeRow(RowItem row); @Override boolean containsRowWithKey(Object... keys); @Override void addRowIdChangeListener(RowIdChangeListener listener); @Override void removeRowIdChangeListener(RowIdChangeListener listener);  }### Answer:
@Test public void containsRowWithKeys_existingKeys_returnsTrue() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); Assert.assertTrue(tQuery.containsRowWithKey(1)); }
@Test public void containsRowWithKeys_nonexistingKeys_returnsTrue() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); Assert.assertFalse(tQuery.containsRowWithKey(1337)); }
@Test public void containsRowWithKeys_invalidKeys_shouldFail() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); boolean b = true; try { b = tQuery.containsRowWithKey("foo"); } catch (SQLException se) { return; } Assert.assertFalse(b); }
@Test public void containsRowWithKeys_nullKeys_shouldFailAndReleaseConnections() throws SQLException { TableQuery tQuery = new TableQuery("people", connectionPool, SQLTestsConstants.sqlGen); try { tQuery.containsRowWithKey(new Object[] { null }); org.junit.Assert .fail("null should throw an IllegalArgumentException from StatementHelper"); } catch (IllegalArgumentException e) { Connection c1 = connectionPool.reserveConnection(); Connection c2 = connectionPool.reserveConnection(); connectionPool.releaseConnection(c1); connectionPool.releaseConnection(c2); } }