Search in sources :

Example 1 with TestCaseStep

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;
}
Also used : SQLException(java.sql.SQLException) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStep(org.cerberus.crud.factory.IFactoryTestCaseStep) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) PreparedStatement(java.sql.PreparedStatement)

Example 2 with TestCaseStep

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;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStep(org.cerberus.crud.factory.IFactoryTestCaseStep) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) PreparedStatement(java.sql.PreparedStatement)

Example 3 with TestCaseStep

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;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStep(org.cerberus.crud.factory.IFactoryTestCaseStep) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) PreparedStatement(java.sql.PreparedStatement)

Example 4 with TestCaseStep

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;
}
Also used : TestCase(org.cerberus.crud.entity.TestCase) IFactoryTestCase(org.cerberus.crud.factory.IFactoryTestCase) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStep(org.cerberus.crud.factory.IFactoryTestCaseStep) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) PreparedStatement(java.sql.PreparedStatement)

Example 5 with TestCaseStep

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;
}
Also used : SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStep(org.cerberus.crud.factory.IFactoryTestCaseStep) TestCaseStep(org.cerberus.crud.entity.TestCaseStep) PreparedStatement(java.sql.PreparedStatement)

Aggregations

TestCaseStep (org.cerberus.crud.entity.TestCaseStep)41 ArrayList (java.util.ArrayList)20 IFactoryTestCaseStep (org.cerberus.crud.factory.IFactoryTestCaseStep)19 ITestCaseStepService (org.cerberus.crud.service.ITestCaseStepService)16 TestCase (org.cerberus.crud.entity.TestCase)15 TestCaseStepAction (org.cerberus.crud.entity.TestCaseStepAction)13 JSONObject (org.json.JSONObject)13 ApplicationContext (org.springframework.context.ApplicationContext)12 SQLException (java.sql.SQLException)11 TestCaseCountryProperties (org.cerberus.crud.entity.TestCaseCountryProperties)11 TestCaseStepActionControl (org.cerberus.crud.entity.TestCaseStepActionControl)11 Connection (java.sql.Connection)10 PreparedStatement (java.sql.PreparedStatement)10 ResultSet (java.sql.ResultSet)10 ITestCaseService (org.cerberus.crud.service.ITestCaseService)10 JSONArray (org.json.JSONArray)10 PolicyFactory (org.owasp.html.PolicyFactory)10 ITestCaseStepActionService (org.cerberus.crud.service.ITestCaseStepActionService)9 MessageEvent (org.cerberus.engine.entity.MessageEvent)9 TestCaseCountry (org.cerberus.crud.entity.TestCaseCountry)8