SelectBuilder { @VisibleForTesting static String getSql(Class<?> entityClass, String clause) { String prefix = "select e from " + entityClass.getSimpleName() + " e"; String sql; if (clause.length() > 0) sql = prefix + " where " + clause; else sql = prefix; return sql; } SelectBuilder(BooleanExpression<T> e); static SelectBuilder<R> builder(BooleanExpression<R> e); SelectBuilder<T> select(BooleanExpression<T> exp); SelectBuilder<T> entityClass(Class<T> cls); SelectBuilder<T> info(Info info); Optional<T> one(); Optional<T> one(EntityManager em); Optional<T> any(EntityManager em); Optional<T> any(); List<T> many(); List<T> many(EntityManager em);  }
@Test public void testSqlGivenNonEmptyClause() { assertEquals("select e from Ent e where (e.field=1)", SelectBuilder.getSql(Ent.class, "(e.field=1)")); }
@Test public void testSqlGivenEmptyClause() { assertEquals("select e from Ent e", SelectBuilder.getSql(Ent.class, "")); }