DatabaseOperator { public <T> T query(final String baseQuery, final ResultSetHandler<T> resultHandler, final Object... params) throws SQLException { try { return this.queryRunner.query(baseQuery, resultHandler, params); } catch (final SQLException ex) { logger.error("query failed", ex); if (this.dbMetrics != null) { this.dbMetrics.markDBFailQuery(); } throw ex; } } @Inject  DatabaseOperator(final QueryRunner queryRunner); T query(final String baseQuery, final ResultSetHandler<T> resultHandler,
      final Object... params); T transaction(final SQLTransaction<T> operations); int update(final String updateClause, final Object... params); int[] batch(final String sqlCommand, final Object[]... params); AzkabanDataSource getDataSource();  }
@Test public void testValidQuery() throws Exception { final int res = this.dbOperator.query("select * from blah where ? = ?", this.handler, "id", 2); Assert.assertEquals(15, res); verify(this.queryRunner).query("select * from blah where ? = ?", this.handler, "id", 2); }
@Test public void testInvalidQuery() throws Exception { final int res = this.dbOperator.query("select * from blah where ? = ?", this.handler, "id", 3); Assert.assertEquals(0, res); }
@Test(expected = SQLException.class) public void testTypoSqlStatement() throws Exception { System.out.println("testTypoSqlStatement"); this.dbOperator.query("sele * from blah where ? = ?", this.handler, "id", 2); }