SelectQuery { String fetchSQL(StringBuilder where, String sort, Integer skip, Integer limit) { var builder = new StringBuilder("SELECT ").append(columns).append(" FROM ").append(table); if (where.length() > 0) builder.append(" WHERE ").append(where); if (sort != null) builder.append(" ORDER BY ").append(sort); if (skip != null || limit != null) builder.append(" LIMIT ?,?"); return builder.toString(); } SelectQuery(Class<T> entityClass);   }
@Test void fetchSQL() { String sql = selectQuery.fetchSQL(new StringBuilder("string_field = ?"), "int_field ASC", 4, 10); assertThat(sql).isEqualTo("SELECT id, string_field, int_field, big_decimal_field, date_field FROM assigned_id_entity WHERE string_field = ? ORDER BY int_field ASC LIMIT ?,?"); }