BoltNeo4jPreparedStatement extends Neo4jPreparedStatement implements Loggable { public static PreparedStatement newInstance(boolean debug, BoltNeo4jConnectionImpl connection, String rawStatement, int... rsParams) { PreparedStatement ps = new BoltNeo4jPreparedStatement(connection, rawStatement, rsParams); ((Neo4jPreparedStatement) ps).setDebug(debug); return (PreparedStatement) Proxy.newProxyInstance(BoltNeo4jPreparedStatement.class.getClassLoader(), new Class[] { PreparedStatement.class }, new Neo4jInvocationHandler(ps, debug)); } private  BoltNeo4jPreparedStatement(BoltNeo4jConnectionImpl connection, String rawStatement, int... rsParams); static PreparedStatement newInstance(boolean debug, BoltNeo4jConnectionImpl connection, String rawStatement, int... rsParams); @Override ResultSet executeQuery(); @Override int executeUpdate(); @Override boolean execute(); @Override Neo4jParameterMetaData getParameterMetaData(); @Override Neo4jResultSetMetaData getMetaData(); @Override int[] executeBatch();  }
@Test public void closeShouldNotCallCloseOnAnyResultSet() throws Exception { PreparedStatement prStatement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionOpenWithTransactionThatReturns(null), ""); prStatement.close(); verify(this.mockedRS, never()).close(); }
@Test public void isClosedShouldReturnFalseWhenCreated() throws SQLException { PreparedStatement prStatement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionOpen(), ""); assertFalse(prStatement.isClosed()); }
@Test public void getResultSetConcurrencyShouldThrowExceptionWhenCalledOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement statement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionClosed(), ""); statement.close(); statement.getResultSetConcurrency(); }
@Test public void getResultSetHoldabilityShouldThrowExceptionWhenCalledOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement statement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionClosed(), ""); statement.close(); statement.getResultSetHoldability(); }
@Test public void getResultSetTypeShouldThrowExceptionWhenCalledOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement statement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionClosed(), ""); statement.close(); statement.getResultSetType(); }
@Test public void getUpdateCountShouldThrowExceptionOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement statement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionOpen(), StatementData.STATEMENT_MATCH_ALL); statement.close(); statement.getUpdateCount(); }
@Test public void getResultSetShouldThrowExceptionOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement statement = BoltNeo4jPreparedStatement.newInstance(false, mockConnectionOpen(), StatementData.STATEMENT_MATCH_ALL); statement.close(); statement.getResultSet(); }
@Test public void addBatchShouldThrowExceptionIfClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement stmt = BoltNeo4jPreparedStatement.newInstance(false, Mocker.mockConnectionOpen(), "?"); stmt.setInt(1, 1); stmt.close(); stmt.addBatch(); }
@Test public void clearBatchShouldThrowExceptionIfClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement stmt = BoltNeo4jPreparedStatement.newInstance(false, Mocker.mockConnectionOpen(), "?"); stmt.close(); stmt.clearBatch(); }
@Test public void getConnectionShouldWork() throws SQLException { PreparedStatement stmt = BoltNeo4jPreparedStatement.newInstance(false, Mocker.mockConnectionOpen(), "?"); assertNotNull(stmt.getConnection()); assertEquals(Mocker.mockConnectionOpen().getClass(), stmt.getConnection().getClass()); }
@Test public void getConnectionShouldThrowExceptionOnClosedStatement() throws SQLException { expectedEx.expect(SQLException.class); PreparedStatement stmt = BoltNeo4jPreparedStatement.newInstance(false, Mocker.mockConnectionClosed(), "?"); stmt.close(); stmt.getConnection(); }