use of org.cerberus.crud.entity.TestCaseStep in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method getTestCaseStepUsingStepInParamter.
@Override
public List<TestCaseStep> getTestCaseStepUsingStepInParamter(String test, String testCase, int step) throws CerberusException {
List<TestCaseStep> list = new ArrayList<TestCaseStep>();
final String query = "SELECT * FROM testcasestep WHERE usestep='Y' AND usesteptest = ? AND usesteptestcase = ? AND usestepstep = ?";
// 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, test);
preStat.setString(2, testCase);
preStat.setInt(3, step);
ResultSet resultSet = preStat.executeQuery();
try {
while (resultSet.next()) {
list.add(loadFromResultSet(resultSet));
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} 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());
}
}
return list;
}
use of org.cerberus.crud.entity.TestCaseStep in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method findTestCaseStepByTestCase.
@Override
public List<TestCaseStep> findTestCaseStepByTestCase(String test, String testcase) {
List<TestCaseStep> list = null;
final String query = "SELECT * FROM testcasestep WHERE test = ? AND testcase = ? ORDER BY sort";
// 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, test);
preStat.setString(2, testcase);
ResultSet resultSet = preStat.executeQuery();
list = new ArrayList<TestCaseStep>();
try {
while (resultSet.next()) {
list.add(loadFromResultSet(resultSet));
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} 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());
}
}
return list;
}
use of org.cerberus.crud.entity.TestCaseStep in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method getStepUsedAsLibraryInOtherTestCaseByApplication.
@Override
public List<TestCaseStep> getStepUsedAsLibraryInOtherTestCaseByApplication(String application) throws CerberusException {
List<TestCaseStep> list = null;
StringBuilder query = new StringBuilder();
query.append("SELECT tcs.usesteptest, tcs.usesteptestcase,tcs.usestepstep,tcs.sort, tcs2.description FROM testcasestep tcs ");
query.append("join testcase tc on tc.test=tcs.test and tc.testcase=tcs.testcase ");
query.append("join testcasestep tcs2 on tcs.test=tcs2.test and tcs.testcase=tcs2.testcase and tcs.step=tcs2.step ");
query.append("where tcs.usestep = 'Y' and tc.application = ? ");
query.append("group by tcs.usesteptest, tcs.usesteptestcase, tcs.usestepstep ");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
preStat.setString(1, application);
ResultSet resultSet = preStat.executeQuery();
list = new ArrayList<TestCaseStep>();
try {
while (resultSet.next()) {
String t = resultSet.getString("usesteptest");
String tc = resultSet.getString("usesteptestcase");
int s = resultSet.getInt("usestepstep");
int sort = resultSet.getInt("sort");
String description = resultSet.getString("description");
list.add(factoryTestCaseStep.create(t, tc, s, sort, null, null, null, null, description, null, null, null, 0, null));
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} 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());
}
}
return list;
}
use of org.cerberus.crud.entity.TestCaseStep in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method getStepLibraryBySystemTest.
@Override
public List<TestCaseStep> getStepLibraryBySystemTest(String system, String test) throws CerberusException {
List<TestCaseStep> list = null;
StringBuilder query = new StringBuilder();
query.append("SELECT tcs.test, tcs.testcase,tcs.step, tcs.sort, tcs.description, tc.description as tcdesc, tc.application as tcapp FROM testcasestep tcs ");
query.append("join testcase tc on tc.test=tcs.test and tc.testcase=tcs.testcase ");
query.append("join application app on tc.application=app.application ");
query.append("where tcs.inlibrary = 'Y' ");
if (system != null) {
query.append("and app.system = ? ");
}
if (test != null) {
query.append("and tcs.test = ? ");
}
query.append("order by tcs.test, tcs.testcase, tcs.sort");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
LOG.debug("SQL.param.system : " + system);
LOG.debug("SQL.param.test : " + test);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
int i = 1;
if (system != null) {
preStat.setString(i++, system);
}
if (test != null) {
preStat.setString(i++, test);
}
ResultSet resultSet = preStat.executeQuery();
list = new ArrayList<TestCaseStep>();
try {
while (resultSet.next()) {
String t = resultSet.getString("test");
String tc = resultSet.getString("testcase");
int s = resultSet.getInt("step");
int sort = resultSet.getInt("sort");
String description = resultSet.getString("description");
String tcdesc = resultSet.getString("tcdesc");
TestCase tcToAdd = factoryTestCase.create(t, tc, tcdesc);
tcToAdd.setApplication(resultSet.getString("tcapp"));
TestCaseStep tcsToAdd = factoryTestCaseStep.create(t, tc, s, sort, null, null, null, null, description, null, null, null, 0, null);
tcsToAdd.setTestCaseObj(tcToAdd);
list.add(tcsToAdd);
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} 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());
}
}
return list;
}
use of org.cerberus.crud.entity.TestCaseStep in project cerberus-source by cerberustesting.
the class TestCaseStepDAO method getStepLibraryBySystemTestTestCase.
@Override
public List<TestCaseStep> getStepLibraryBySystemTestTestCase(String system, String test, String testCase) throws CerberusException {
List<TestCaseStep> list = null;
StringBuilder query = new StringBuilder();
query.append("SELECT tcs.test, tcs.testcase,tcs.step, tcs.sort, tcs.description FROM testcasestep tcs ");
query.append("join testcase tc on tc.test=tcs.test and tc.testcase=tcs.testcase ");
query.append("join application app on tc.application=app.application ");
query.append("where tcs.inlibrary = 'Y' ");
if (system != null) {
query.append("and app.system = ? ");
}
if (test != null) {
query.append("and tcs.test = ? ");
}
if (testCase != null) {
query.append("and tcs.testcase = ? ");
}
query.append("order by tcs.test, tcs.testcase, tcs.sort");
// Debug message on SQL.
if (LOG.isDebugEnabled()) {
LOG.debug("SQL : " + query.toString());
LOG.debug("SQL.param.system : " + system);
LOG.debug("SQL.param.test : " + test);
LOG.debug("SQL.param.testcase : " + testCase);
}
Connection connection = this.databaseSpring.connect();
try {
PreparedStatement preStat = connection.prepareStatement(query.toString());
try {
int i = 1;
if (system != null) {
preStat.setString(i++, system);
}
if (test != null) {
preStat.setString(i++, test);
}
if (testCase != null) {
preStat.setString(i++, testCase);
}
ResultSet resultSet = preStat.executeQuery();
list = new ArrayList<TestCaseStep>();
try {
while (resultSet.next()) {
String t = resultSet.getString("test");
String tc = resultSet.getString("testcase");
int s = resultSet.getInt("step");
int sort = resultSet.getInt("sort");
String description = resultSet.getString("description");
list.add(factoryTestCaseStep.create(t, tc, s, sort, null, null, null, null, description, null, null, null, 0, null));
}
} catch (SQLException exception) {
LOG.error("Unable to execute query : " + exception.toString());
} finally {
resultSet.close();
}
} 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());
}
}
return list;
}
Aggregations