### Question:
JdbcExecuteInterceptor implements Installable { public static String parseQueryFromStatement(Statement stmt, Object[] params) throws NoSuchMethodException { String query = null; if (params != null && params.length > 0 && params[0] instanceof String) { query = (String) params[0]; } else if (stmt instanceof PreparedStatement && Statement.class.isAssignableFrom(stmt.getClass().getMethod("toString").getDeclaringClass())) { query = stmt.toString(); } return query; }  @Advice.OnMethodEnter static ServiceRequestEvent enter(@Advice.AllArguments final Object[] args,
                                            @Advice.Origin final String origin,
                                            @Advice.This final Statement stmt); @Advice.OnMethodExit(onThrowable = Throwable.class) static void exit(@Advice.Enter final ServiceRequestEvent requestEvent,
                            @Advice.Return final Object response,
                            @Advice.Thrown final Throwable thrown); @Override AgentBuilder install(final AgentBuilder agentBuilder); static String parseQueryFromStatement(Statement stmt, Object[] params); static final Logger log; static final String SQL_ORIGIN; }### Answer:
@Test public void testQueryStringExtractedFromParams() throws NoSuchMethodException { Object[] params = {QUERY}; String parsed = JdbcExecuteInterceptor.parseQueryFromStatement(myStatement, params); assertEquals(QUERY, parsed); }
@Test public void testQueryStringExtractedWithToString() throws NoSuchMethodException { Object[] params = {}; String parsed = JdbcExecuteInterceptor.parseQueryFromStatement(myCallableStatement, params); assertEquals(myCallableStatement.toString(), parsed); }
@Test public void testQueryStringNotExtracted() throws NoSuchMethodException { Object[] params = {}; String parsed = JdbcExecuteInterceptor.parseQueryFromStatement(myPreparedStatement, params); assertNull(parsed); }