SelectQuery { private String getSQL(List<Field> fields) { var builder = new StringBuilder("SELECT ").append(columns).append(" FROM ").append(table).append(" WHERE "); for (Field field : fields) { if (field.isAnnotationPresent(PrimaryKey.class)) { Column column = field.getDeclaredAnnotation(Column.class); if (primaryKeyColumns > 0) builder.append(" AND "); builder.append(column.name()).append(" = ?"); primaryKeyColumns++; } } return builder.toString(); } SelectQuery(Class<T> entityClass);   }
@Test void getSQL() { assertThat(selectQuery.getSQL).isEqualTo("SELECT id, string_field, int_field, big_decimal_field, date_field FROM assigned_id_entity WHERE id = ?"); }