StagemonitorJdbcEventListener extends SimpleJdbcEventListener { static String getMethod(String sql) { if (sql == null) { return null; } sql = sql.trim(); final int indexOfWhitespace = sql.indexOf(' '); if (indexOfWhitespace > 0) { return sql.substring(0, indexOfWhitespace).toUpperCase(); } else { return sql.toUpperCase(); } } StagemonitorJdbcEventListener();  StagemonitorJdbcEventListener(ConfigurationRegistry configuration); @Override void onConnectionWrapped(ConnectionInformation connectionInformation); @Override void onBeforeAnyExecute(StatementInformation statementInformation); @Override void onAfterAnyExecute(StatementInformation statementInformation, long timeElapsedNanos, SQLException e);  }
@Test public void getMethod() throws Exception { assertSoftly(softly -> { softly.assertThat(StagemonitorJdbcEventListener.getMethod("select * from stagemonitor")).isEqualTo("SELECT"); softly.assertThat(StagemonitorJdbcEventListener.getMethod(" update stagemonitor set bug=false")).isEqualTo("UPDATE"); softly.assertThat(StagemonitorJdbcEventListener.getMethod("Commit")).isEqualTo("COMMIT"); softly.assertThat(StagemonitorJdbcEventListener.getMethod("")).isEqualTo(""); softly.assertThat(StagemonitorJdbcEventListener.getMethod(" ")).isEqualTo(""); softly.assertThat(StagemonitorJdbcEventListener.getMethod(null)).isNull(); }); }