DBMessageResourceDAOImpl extends JdbcDaoSupport implements
        DBMessageResourceDAO { protected String makeSql() { checkRequiredColumnName(codeColumn, "codeColumn"); checkNotRequiredColumnName(languageColumn, "languageColumn"); checkNotRequiredColumnName(countryColumn, "countryColumn"); checkNotRequiredColumnName(variantColumn, "variantColumn"); checkRequiredColumnName(messageColumn, "messageColumn"); checkRequiredColumnName(tableName, "tableName"); StringBuilder sql = null; if (findMessageSql != null) { sql = new StringBuilder(findMessageSql); } else { sql = new StringBuilder("SELECT "); sql.append(codeColumn); sql.append(","); if (languageColumn != null) { sql.append(languageColumn); sql.append(","); } if (countryColumn != null) { sql.append(countryColumn); sql.append(","); } if (variantColumn != null) { sql.append(variantColumn); sql.append(","); } sql.append(messageColumn); sql.append(" FROM "); sql.append(tableName); } if (log.isDebugEnabled()) { log.debug("sql=[" + sql + "]"); } return sql.toString(); } protected  DBMessageResourceDAOImpl(); void setTableName(String tableName); void setCodeColumn(String codeColumn); void setLanguageColumn(String languageColumn); void setCountryColumn(String countryColumn); void setVariantColumn(String variantColumn); void setMessageColumn(String messageColumn); void setFindMessageSql(String findMessageSql); @SuppressWarnings("unchecked") @Override List<DBMessage> findDBMessages();  }
@Test public void testMakeSql01() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = "LANGUAGE"; dbmr.countryColumn = "COUNTRY"; dbmr.variantColumn = "VARIANT"; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; String sql = dbmr.makeSql(); assertEquals( "SELECT CODE,LANGUAGE,COUNTRY,VARIANT,MESSAGE FROM MESSAGES", sql); }
@Test public void testMakeSql02() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = ""; dbmr.languageColumn = "LANGUAGE"; dbmr.countryColumn = "COUNTRY"; dbmr.variantColumn = "VARIANT"; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: codeColumn is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: codeColumn is null or empty.")))); } }
@Test public void testMakeSql03() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = null; dbmr.languageColumn = "LANGUAGE"; dbmr.countryColumn = "COUNTRY"; dbmr.variantColumn = "VARIANT"; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: codeColumn is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: codeColumn is null or empty.")))); } }
@Test public void testMakeSql04() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = ""; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = null; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: languageColumn is empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: languageColumn is empty.")))); } }
@Test public void testMakeSql05() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = ""; dbmr.variantColumn = null; dbmr.messageColumn = null; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: countryColumn is empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: countryColumn is empty.")))); } }
@Test public void testMakeSql06() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = ""; dbmr.messageColumn = null; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: variantColumn is empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: variantColumn is empty.")))); } }
@Test public void testMakeSql07() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = ""; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: messageColumn is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: messageColumn is null or empty.")))); } }
@Test public void testMakeSql08() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = null; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: messageColumn is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: messageColumn is null or empty.")))); } }
@Test public void testMakeSql09() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = ""; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: tableName is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: tableName is null or empty.")))); } }
@Test public void testMakeSql10() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = null; dbmr.findMessageSql = null; try { logger.clear(); dbmr.makeSql(); fail(); } catch (IllegalArgumentException e) { assertEquals("illegalArgument: tableName is null or empty.", e .getMessage()); assertThat(logger.getLoggingEvents(), is(asList(error( "illegalArgument: tableName is null or empty.")))); } }
@Test public void testMakeSql11() throws Exception { DBMessageResourceDAOImpl dbmr = new DBMessageResourceDAOImpl(); String sql = "SELECT CODE,LANGUAGE,COUNTRY,VARIANT,MESSAGE FROM MESSAGES"; dbmr.codeColumn = "CODE"; dbmr.languageColumn = null; dbmr.countryColumn = null; dbmr.variantColumn = null; dbmr.messageColumn = "MESSAGE"; dbmr.tableName = "MESSAGES"; dbmr.findMessageSql = sql; String sqlReturn = dbmr.makeSql(); assertEquals(sql, sqlReturn); }