### Question:
DatabaseQueryBuilder { public String getSQL() { if (StringUtil.isBlank(selectFrom)) { if (StringUtil.isBlank(tableName)) { throw new IllegalArgumentException("the tableName must not be null or empty"); } if (columns != null) { selectFrom = createSelect(columns); } if (StringUtil.isBlank(selectFrom)) { throw new IllegalArgumentException("the selectFrom clause must not be empty"); } } else { if (!selectFrom.toUpperCase().contains("SELECT")) { throw new IllegalArgumentException("the required SELECt clause is missing"); } if (!selectFrom.toUpperCase().contains("FROM")) { throw new IllegalArgumentException("the required FROM clause is missing"); } } String ret = selectFrom; if (where != null) { final String whereSql = where.getWhereClause(); if (!StringUtil.isBlank(whereSql)) { ret = whereAnd(selectFrom, whereSql); } } if (this.orderBy != null) { StringBuilder obld = new StringBuilder(" ORDER BY "); boolean first = true; for (OrderBy ord : orderBy) { if (!first) { obld.append(", "); } first = false; obld.append(ord.getColumnName()); obld.append(ord.isAscendent() ? " ASC" : " DESC"); } if (obld.length() != 0) { ret += obld.toString(); } } return ret; } DatabaseQueryBuilder(String tableName, Set<String> columns);  DatabaseQueryBuilder(final String selectFrom); void setColumns(Set<String> columns); void setSelectFrom(String selectFrom); void setTableName(String tableName); void setWhere(FilterWhereBuilder whereBuilder); void setOrderBy(List<OrderBy> orderBy); String getSQL(); List<SQLParam> getParams();  }### Answer:
@Test(expectedExceptions = IllegalArgumentException.class) public void testFilterQueryBuilderTableMissing() { new DatabaseQueryBuilder("", null).getSQL(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFilterQueryBuilderColumnMissing() { new DatabaseQueryBuilder("table", null).getSQL(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFilterQueryBuilderColumnEmpty() { new DatabaseQueryBuilder("table", new HashSet<String>()).getSQL(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFilterQueryBuilderSelectMissing() { new DatabaseQueryBuilder("").getSQL(); }
@Test(expectedExceptions = IllegalArgumentException.class) public void testFilterQueryBuilderWhereMissing() { new DatabaseQueryBuilder(SELECT.substring(0, 7), null).getSQL(); }
@Test public void testFilterQueryBuilder() { DatabaseQueryBuilder actual = new DatabaseQueryBuilder(SELECT); assertNotNull(actual); assertNotNull(actual.getSQL()); assertEquals(SELECT, actual.getSQL()); }
@Test public void testGetSql() { FilterWhereBuilder where = new FilterWhereBuilder(); final SQLParam param = new SQLParam(NAME, VALUE); where.addBind(param, OPERATOR); DatabaseQueryBuilder actual = new DatabaseQueryBuilder(SELECT); actual.setWhere(where); assertNotNull(actual); assertEquals(SELECT + " WHERE name = ?", actual.getSQL()); assertEquals("not one value for binding", 1, actual.getParams().size()); assertEquals("value for binding", param, actual.getParams().get(0)); }