SqlStatement { public String getExecutableSqlStatements() { String selectStatement = selectQuery(); String fromClause = fromClause(); String predicates = whereClause(); return selectStatement + " " + fromClause + " " + predicates + ";"; } private  SqlStatement(); String getExecutableSqlStatements();  }
@Test void shouldBuildSqlStatement() { List<String> columns = List.of("name", "address"); List<String> tables = List.of("employees"); String predicatesInString = "(employees.name = 'Joffer' AND employees.address = 'Stockholm')"; SqlStatement target = new SqlStatement.Builder() .select(columns) .from(tables) .where(predicatesInString) .build(); assertThat(target.getExecutableSqlStatements(), is("SELECT name, address FROM employees WHERE (employees.name = 'Joffer' AND employees.address = 'Stockholm');")); }
@Test void shouldSelectFromAllColumns() { List<String> columns = List.of("*"); List<String> tables = List.of("employees"); String predicatesInString = "(employees.name = 'Joffer' AND employees.address = 'Stockholm')"; SqlStatement target = new SqlStatement.Builder() .select(columns) .from(tables) .where(predicatesInString) .build(); assertThat(target.getExecutableSqlStatements(), is("SELECT * FROM employees WHERE (employees.name = 'Joffer' AND employees.address = 'Stockholm');")); }