### Question:
PostgreSQLDialect extends DefaultDialect { @Override public String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset) { StringBuilder fullQuery = new StringBuilder(); appendSelect(fullQuery, tableName, columns, null, subQuery, orderBys); if(limit != -1){ fullQuery.append(" LIMIT ").append(limit); } if(offset != -1){ fullQuery.append(" OFFSET ").append(offset); } return fullQuery.toString(); }  @Override String formSelect(String tableName, String[] columns, String subQuery, List<String> orderBys, long limit, long offset);  }### Answer:
@Test public void testFormSelectWithoutTableName() { final String fullQuery = "SELECT name FROM people"; a(dialect.formSelect(null, new String[]{"name"}, fullQuery, new ArrayList<String>(), -1, -1)).shouldBeEqual(fullQuery); }
@Test public void testFormSelectWithTableName() { a(dialect.formSelect("people", null, null, new ArrayList<String>(), -1, -1)).shouldBeEqual("SELECT * FROM people"); a(dialect.formSelect("people", null, "name = ?", new ArrayList<String>(), -1, -1)).shouldBeEqual("SELECT * FROM people WHERE name = ?"); a(dialect.formSelect("people", null, "name = ?", Arrays.asList("name"), -1, -1)).shouldBeEqual("SELECT * FROM people WHERE name = ? ORDER BY name"); a(dialect.formSelect("people", null, null, Arrays.asList("last_name", "name"), -1, -1)).shouldBeEqual("SELECT * FROM people ORDER BY last_name, name"); }
@Test public void testFormSelectWithLimitOffset() { a(dialect.formSelect("people", null, null, new ArrayList<String>(), 1, -1)).shouldBeEqual("SELECT * FROM people LIMIT 1"); a(dialect.formSelect("people", null, null, new ArrayList<String>(), -1, 1)).shouldBeEqual("SELECT * FROM people OFFSET 1"); a(dialect.formSelect("people", null, null, new ArrayList<String>(), 1, 1)).shouldBeEqual("SELECT * FROM people LIMIT 1 OFFSET 1"); a(dialect.formSelect("people", null, "last_name = ?", new ArrayList<String>(), 1, 10)).shouldBeEqual("SELECT * FROM people WHERE last_name = ? LIMIT 1 OFFSET 10"); a(dialect.formSelect("people", null, "name = ?", Arrays.asList("name"), 10, 10)).shouldBeEqual("SELECT * FROM people WHERE name = ? ORDER BY name LIMIT 10 OFFSET 10"); }