### Question:
OracleERPUtil { static String whereAnd(String sqlSelect, String whereAnd) { if (sqlSelect == null) { throw new IllegalArgumentException("sqlSelect can not be null"); } String add = trimWhere(whereAnd).trim(); if (add.length() == 0) { return sqlSelect; } int iofw = sqlSelect.toUpperCase().indexOf("WHERE"); return (iofw == -1) ? sqlSelect + " WHERE " + add : sqlSelect.substring(0, iofw).trim() + " WHERE ( " + sqlSelect.substring(iofw + 5).trim() + " ) AND ( " + add + " )"; } private  OracleERPUtil();  static final ObjectClass RESP_OC; static final ObjectClass DIRECT_RESP_OC; static final ObjectClass INDIRECT_RESP_OC; static final ObjectClass RESP_NAMES_OC; static final ObjectClass APPS_OC; static final ObjectClass SEC_GROUPS_OC; static final ObjectClass SEC_ATTRS_OC; static final ObjectClass AUDITOR_RESPS_OC; }### Answer:
@Test public void testWhereAnd() { final String baseSelect = "SELECT 1 FROM x"; final String empty = ""; final String where1 = " WHERE a=1"; final String where2 = " where b=2"; final String where3 = " c=3"; AssertJUnit.assertEquals("BASE_SELECT, WHERE2", "SELECT 1 FROM x WHERE b=2", OracleERPUtil .whereAnd(baseSelect, where2)); AssertJUnit.assertEquals("BASE_SELECT + WHERE1, WHERE2", "SELECT 1 FROM x WHERE ( a=1 ) AND ( b=2 )", OracleERPUtil.whereAnd(baseSelect + where1, where2)); AssertJUnit.assertEquals("BASE_SELECT + WHERE1, EMPTY", "SELECT 1 FROM x WHERE a=1", OracleERPUtil.whereAnd(baseSelect + where1, empty)); AssertJUnit.assertEquals("BASE_SELECT, EMPTY", "SELECT 1 FROM x", OracleERPUtil.whereAnd( baseSelect, empty)); AssertJUnit.assertEquals("BASE_SELECT + WHERE1, WHERE3", "SELECT 1 FROM x WHERE ( a=1 ) AND ( c=3 )", OracleERPUtil.whereAnd(baseSelect + where1, where3)); AssertJUnit.assertEquals("BASE_SELECT, WHERE3", "SELECT 1 FROM x WHERE c=3", OracleERPUtil .whereAnd(baseSelect, where3)); }