Class SQLRequester
- java.lang.Object
-
- org.silverpeas.core.test.integration.SQLRequester
-
public class SQLRequester extends Object
A SQL requester for integration tests. It uses theDataSourceProvider
to get a connection to the database used by the integration tests.- Author:
- mmoquillon
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SQLRequester.ResultLine
Represents a line of a SQL result execution.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Map<String,Object>
findOne(String query, Object... parameters)
Finds one and only one entity by executing the specified SQL query with the given parameters.static List<SQLRequester.ResultLine>
list(JdbcSqlQuery jdbcSqlQuery)
Lists entities by executing the specified SQL query with the given parameters.
-
-
-
Method Detail
-
findOne
public static Map<String,Object> findOne(String query, Object... parameters) throws SQLException
Finds one and only one entity by executing the specified SQL query with the given parameters. If there is more than one entity found then anIllegalArgumentException
is thrown.- Parameters:
query
- the query to use to find one entity.parameters
- the parameters to apply with the query.- Returns:
- a
Map
with the persisted attributes of the asked entity. The name of the attributes are all in uppercase. - Throws:
SQLException
- if an error occurs while executing the given SQL query.
-
list
public static List<SQLRequester.ResultLine> list(JdbcSqlQuery jdbcSqlQuery) throws SQLException
Lists entities by executing the specified SQL query with the given parameters.- Parameters:
jdbcSqlQuery
- theJdbcSqlQuery
instance.- Returns:
- a
List
ofSQLRequester.ResultLine
instances. - Throws:
SQLException
- if an error occurs while executing the givenJdbcSqlQuery
.
-
-