use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method deleteTestCaseStep.
@Override
public void deleteTestCaseStep(TestCaseStep tcs) throws CerberusException {
boolean throwExcep = false;
final String query = "DELETE FROM testcasestep WHERE test = ? and testcase = ? and step = ?";
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
preStat.setString(1, tcs.getTest());
preStat.setString(2, tcs.getTestCase());
preStat.setInt(3, tcs.getStep());
throwExcep = preStat.executeUpdate() == 0;
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn("Exception Closing the connection : " + e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.
the class ParameterDAO method findAllParameter.
@Override
public List<Parameter> findAllParameter() throws CerberusException {
boolean throwExep = true;
List<Parameter> result = null;
Parameter paramet;
final String query = "SELECT * FROM parameter p ";
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
try {
ResultSet resultSet = preStat.executeQuery();
try {
result = new ArrayList<Parameter>();
while (resultSet.next()) {
String system = resultSet.getString("system");
String param = resultSet.getString("param");
String value = resultSet.getString("value");
String desc = resultSet.getString("description");
paramet = factoryParameter.create(system, param, value, desc);
result.add(paramet);
throwExep = false;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExep) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND);
mes.setDescription(mes.getDescription() + " Parameter table empty.");
throw new CerberusException(mes);
}
return result;
}
use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.
the class ParameterDAO method findAllParameterWithSystem1.
@Override
public List<Parameter> findAllParameterWithSystem1(String mySystem, String mySystem1) throws CerberusException {
boolean throwExep = true;
List<Parameter> result = null;
Parameter paramet;
StringBuilder mySQL = new StringBuilder();
mySQL.append("SELECT par.param param, par.`value` valC, par2.`value` valS, par2.description FROM parameter par ");
mySQL.append("LEFT OUTER JOIN ( SELECT * from parameter par2 WHERE par2.system= ? ) as par2 ON par.param = par.param ");
mySQL.append(" WHERE par.system= ?; ");
final String query = mySQL.toString();
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query);
preStat.setString(1, mySystem1);
preStat.setString(1, mySystem);
try {
ResultSet resultSet = preStat.executeQuery();
try {
result = new ArrayList<Parameter>();
while (resultSet.next()) {
String param = resultSet.getString("param");
String valueC = resultSet.getString("valC");
String valueS = resultSet.getString("valS");
String desc = resultSet.getString("description");
paramet = factoryParameter.create(param, "", valueC, desc, mySystem, valueS);
result.add(paramet);
throwExep = false;
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExep) {
MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND);
mes.setDescription(mes.getDescription() + " Parameter table empty.");
throw new CerberusException(mes);
}
return result;
}
use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.
the class SqlLibraryDAO method createSqlLibrary.
@Override
public void createSqlLibrary(SqlLibrary sqlLibrary) throws CerberusException {
boolean throwExcep = false;
StringBuilder query = new StringBuilder();
query.append("INSERT INTO sqllibrary (`type`, `name`, `script`, `description`, `database`) ");
query.append("VALUES (?,?,?,?,?)");
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, sqlLibrary.getType());
preStat.setString(2, sqlLibrary.getName());
preStat.setString(3, sqlLibrary.getScript());
preStat.setString(4, sqlLibrary.getDescription());
preStat.setString(5, sqlLibrary.getDatabase());
preStat.executeUpdate();
throwExcep = false;
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
preStat.close();
}
} catch (SQLException exception) {
LOG.warn("Unable to execute query : " + exception.toString());
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (SQLException e) {
LOG.warn(e.toString());
}
}
if (throwExcep) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.CANNOT_UPDATE_TABLE));
}
}
use of org.cerberus.exception.CerberusException in project cerberus-source by cerberustesting.
the class TestCaseExecutionDAO method findExecutionbyCriteria1.
@Override
public List<TestCaseExecution> findExecutionbyCriteria1(String dateLimit, String test, String testCase, String application, String country, String environment, String controlStatus, String status) throws CerberusException {
List<TestCaseExecution> myTestCaseExecutions = null;
TestCaseExecution Execution;
boolean throwException = false;
final String query = new StringBuffer("SELECT exe.*, tec.*, app.* FROM testcaseexecution exe ").append("LEFT JOIN testcase tec ON exe.test = tec.test AND exe.testcase = tec.testcase ").append("LEFT JOIN application app ON exe.application = app.application ").append("WHERE exe.start > ? AND exe.test LIKE ? AND exe.testcase LIKE ? AND exe.environment LIKE ? ").append("AND exe.country LIKE ? AND exe.application LIKE ? AND exe.controlstatus LIKE ? ").append("AND exe.status LIKE ?").toString();
try (Connection connection = this.databaseSpring.connect();
PreparedStatement preStat = connection.prepareStatement(query)) {
preStat.setString(1, dateLimit);
preStat.setString(2, test);
preStat.setString(3, testCase);
preStat.setString(4, environment);
preStat.setString(5, country);
preStat.setString(6, application);
preStat.setString(7, controlStatus);
preStat.setString(8, status);
try (ResultSet resultSet = preStat.executeQuery()) {
if (!(resultSet.first())) {
throwException = true;
} else {
myTestCaseExecutions = new ArrayList<TestCaseExecution>();
do {
Execution = this.loadWithDependenciesFromResultSet(resultSet);
myTestCaseExecutions.add(Execution);
} while (resultSet.next());
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
}
} catch (Exception exception) {
LOG.error("Unable to execute query : " + exception.toString());
}
if (throwException) {
throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA));
}
return myTestCaseExecutions;
}
Aggregations