### Question:
CompactSlf4jJdbcEventLogger extends Slf4jJdbcEventLogger { protected String trimSqlSelectColumns(String sql) { String str = sql.toUpperCase(); int selectIndex = str.indexOf(SELECT); if (selectIndex == -1) { return sql; } selectIndex += SELECT.length(); int fromIndex = str.indexOf(FROM); String columns = sql.substring(selectIndex, fromIndex); String[] columnsArray = columns.split(","); if (columnsArray.length <= 3) { return sql; } columns = "(" + columnsArray.length + " columns)"; return new StringBuilder(sql.substring(0, selectIndex)) .append(SPACE) .append(columns) .append(SPACE) .append(sql, fromIndex, sql.length()) .toString(); } CompactSlf4jJdbcEventLogger(@Inject RuntimeProperties runtimeProperties); @Override void logQuery(String sql, ParameterBinding[] bindings); @Override void logBeginTransaction(String transactionLabel); @Override void logCommitTransaction(String transactionLabel);  }### Answer:
@Test public void compactSimpleSql() { String processesSelectSql = logger.trimSqlSelectColumns( "SELECT t0.NAME AS ec0_0, t0.F_KEY1 AS ec0_1, t0.F_KEY2 AS ec0_2," + " t0.PKEY AS ec0_3 FROM COMPOUND_FK_TEST t0 INNER JOIN COMPOUND_PK_TEST " + "t1 ON (t0.F_KEY1 = t1.KEY1 AND t0.F_KEY2 = t1.KEY2) WHERE t1.NAME LIKE ?"); assertEquals(processesSelectSql, "SELECT (4 columns) FROM COMPOUND_FK_TEST t0 " + "INNER JOIN COMPOUND_PK_TEST t1 ON (t0.F_KEY1 = t1.KEY1 AND t0.F_KEY2 = t1.KEY2) " + "WHERE t1.NAME LIKE ?"); }
@Test public void compactNotSelect() { String processedSql = logger.trimSqlSelectColumns( "UPDATE test SET name = 'abc', value = 123 WHERE id = 321"); assertEquals("UPDATE test SET name = 'abc', value = 123 WHERE id = 321", processedSql); }
@Test public void compactSubSelect() { String processedSql = logger.trimSqlSelectColumns( "INSERT INTO test1 SELECT column1, column2, column3, column4, column5, column6 FROM test2 WHERE id = 321"); assertEquals("INSERT INTO test1 SELECT (6 columns) FROM test2 WHERE id = 321", processedSql); }