Search in sources :

Example 1 with TestCaseStepActionExecution

use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.

the class TestCaseStepActionExecutionDAO method readByVarious1.

@Override
public AnswerList readByVarious1(long executionId, String test, String testCase, int step, int index) {
    MessageEvent msg;
    AnswerList answer = new AnswerList();
    List<TestCaseStepActionExecution> list = new ArrayList<TestCaseStepActionExecution>();
    StringBuilder query = new StringBuilder();
    query.append("SELECT * FROM testcasestepactionexecution exa ");
    query.append("where exa.id = ? and exa.test = ? and exa.testcase = ? and exa.step = ? and exa.index = ? ");
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query.toString());
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setLong(1, executionId);
            preStat.setString(2, test);
            preStat.setString(3, testCase);
            preStat.setInt(4, step);
            preStat.setInt(5, index);
            ResultSet resultSet = preStat.executeQuery();
            try {
                while (resultSet.next()) {
                    list.add(this.loadFromResultset(resultSet));
                }
                if (list.isEmpty()) {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                }
            } catch (SQLException exception) {
                LOG.error("Unable to execute query : " + exception.toString());
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
                msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
                list.clear();
            } finally {
                if (resultSet != null) {
                    resultSet.close();
                }
            }
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            if (preStat != null) {
                preStat.close();
            }
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    answer.setTotalRows(list.size());
    answer.setDataList(list);
    answer.setResultMessage(msg);
    return answer;
}
Also used : AnswerList(org.cerberus.util.answer.AnswerList) SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) ArrayList(java.util.ArrayList) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStepActionExecution(org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) PreparedStatement(java.sql.PreparedStatement)

Example 2 with TestCaseStepActionExecution

use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.

the class TestCaseStepActionExecutionDAO method readByKey.

@Override
public AnswerItem readByKey(long executionId, String test, String testCase, int step, int index, int sequence) {
    MessageEvent msg;
    AnswerItem answer = new AnswerItem();
    TestCaseStepActionExecution tcsa = null;
    StringBuilder query = new StringBuilder();
    query.append("SELECT * FROM testcasestepactionexecution exa ");
    query.append("where exa.id = ? and exa.test = ? and exa.testcase = ? and exa.step = ? and exa.index = ? and exa.sequence = .");
    // Debug message on SQL.
    if (LOG.isDebugEnabled()) {
        LOG.debug("SQL : " + query.toString());
    }
    Connection connection = this.databaseSpring.connect();
    try {
        PreparedStatement preStat = connection.prepareStatement(query.toString());
        try {
            preStat.setLong(1, executionId);
            preStat.setString(2, test);
            preStat.setString(3, testCase);
            preStat.setInt(4, step);
            preStat.setInt(5, index);
            preStat.setInt(6, sequence);
            ResultSet resultSet = preStat.executeQuery();
            try {
                while (resultSet.next()) {
                    tcsa = this.loadFromResultset(resultSet);
                }
                if (tcsa == null) {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_NO_DATA_FOUND);
                } else {
                    msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_OK);
                }
            } catch (SQLException exception) {
                LOG.error("Unable to execute query : " + exception.toString());
                msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
                msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
            } finally {
                if (resultSet != null) {
                    resultSet.close();
                }
            }
        } catch (SQLException exception) {
            LOG.error("Unable to execute query : " + exception.toString());
            msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
            msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
        } finally {
            if (preStat != null) {
                preStat.close();
            }
        }
    } catch (SQLException exception) {
        LOG.error("Unable to execute query : " + exception.toString());
        msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);
        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", exception.toString()));
    } finally {
        try {
            if (connection != null) {
                connection.close();
            }
        } catch (SQLException exception) {
            LOG.warn("Unable to close connection : " + exception.toString());
        }
    }
    answer.setItem(tcsa);
    answer.setResultMessage(msg);
    return answer;
}
Also used : SQLException(java.sql.SQLException) MessageEvent(org.cerberus.engine.entity.MessageEvent) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) IFactoryTestCaseStepActionExecution(org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) PreparedStatement(java.sql.PreparedStatement) AnswerItem(org.cerberus.util.answer.AnswerItem)

Example 3 with TestCaseStepActionExecution

use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.

the class UpdateTestCaseExecution method createTestCaseStepActionExecution.

// create a TestCaseStepActionExecution with the parameters
private TestCaseStepActionExecution createTestCaseStepActionExecution(long id, String test, String testCase, int step, int index, int sequence, int sort, String returnCode, String returnMessage, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String action, String value1Init, String value2Init, String value1, String value2, String forceExeStatus, long start, long end, long startLong, long endLong, MessageEvent resultMessage, String description, TestCaseStepAction testCaseStepAction, TestCaseStepExecution testCaseStepExecution) {
    TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();
    testCaseStepActionExecution.setAction(action);
    testCaseStepActionExecution.setEnd(end);
    testCaseStepActionExecution.setEndLong(endLong);
    testCaseStepActionExecution.setId(id);
    testCaseStepActionExecution.setConditionOper(conditionOper);
    testCaseStepActionExecution.setConditionVal1Init(conditionVal1Init);
    testCaseStepActionExecution.setConditionVal2Init(conditionVal2Init);
    testCaseStepActionExecution.setConditionVal1(conditionVal1);
    testCaseStepActionExecution.setConditionVal2(conditionVal2);
    testCaseStepActionExecution.setValue1(value1);
    testCaseStepActionExecution.setValue2(value2);
    testCaseStepActionExecution.setValue1Init(value1Init);
    testCaseStepActionExecution.setValue2Init(value2Init);
    testCaseStepActionExecution.setForceExeStatus(forceExeStatus);
    testCaseStepActionExecution.setReturnCode(returnCode);
    testCaseStepActionExecution.setReturnMessage(returnMessage);
    testCaseStepActionExecution.setSequence(sequence);
    testCaseStepActionExecution.setSort(sort);
    testCaseStepActionExecution.setStart(start);
    testCaseStepActionExecution.setStartLong(startLong);
    testCaseStepActionExecution.setStep(step);
    testCaseStepActionExecution.setIndex(index);
    testCaseStepActionExecution.setTest(test);
    testCaseStepActionExecution.setTestCase(testCase);
    testCaseStepActionExecution.setActionResultMessage(resultMessage);
    testCaseStepActionExecution.setTestCaseStepAction(testCaseStepAction);
    testCaseStepActionExecution.setTestCaseStepExecution(testCaseStepExecution);
    testCaseStepActionExecution.setDescription(description);
    return testCaseStepActionExecution;
}
Also used : TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution)

Example 4 with TestCaseStepActionExecution

use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.

the class CreateUpdateTestCaseExecutionFile method createTestCaseStepActionExecution.

// create a TestCaseStepActionExecution with the parameters
private TestCaseStepActionExecution createTestCaseStepActionExecution(long id, String test, String testCase, int step, int index, int sequence, int sort, String returnCode, String returnMessage, String conditionOper, String conditionVal1Init, String conditionVal2Init, String conditionVal1, String conditionVal2, String action, String value1Init, String value2Init, String value1, String value2, String forceExeStatus, long start, long end, long startLong, long endLong, MessageEvent resultMessage, String description, TestCaseStepAction testCaseStepAction, TestCaseStepExecution testCaseStepExecution) {
    TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();
    testCaseStepActionExecution.setAction(action);
    testCaseStepActionExecution.setEnd(end);
    testCaseStepActionExecution.setEndLong(endLong);
    testCaseStepActionExecution.setId(id);
    testCaseStepActionExecution.setConditionOper(conditionOper);
    testCaseStepActionExecution.setConditionVal1Init(conditionVal1Init);
    testCaseStepActionExecution.setConditionVal2Init(conditionVal2Init);
    testCaseStepActionExecution.setConditionVal1(conditionVal1);
    testCaseStepActionExecution.setConditionVal2(conditionVal2);
    testCaseStepActionExecution.setValue1(value1);
    testCaseStepActionExecution.setValue2(value2);
    testCaseStepActionExecution.setValue1Init(value1Init);
    testCaseStepActionExecution.setValue2Init(value2Init);
    testCaseStepActionExecution.setForceExeStatus(forceExeStatus);
    testCaseStepActionExecution.setReturnCode(returnCode);
    testCaseStepActionExecution.setReturnMessage(returnMessage);
    testCaseStepActionExecution.setSequence(sequence);
    testCaseStepActionExecution.setSort(sort);
    testCaseStepActionExecution.setStart(start);
    testCaseStepActionExecution.setStartLong(startLong);
    testCaseStepActionExecution.setStep(step);
    testCaseStepActionExecution.setIndex(index);
    testCaseStepActionExecution.setTest(test);
    testCaseStepActionExecution.setTestCase(testCase);
    testCaseStepActionExecution.setActionResultMessage(resultMessage);
    testCaseStepActionExecution.setTestCaseStepAction(testCaseStepAction);
    testCaseStepActionExecution.setTestCaseStepExecution(testCaseStepExecution);
    testCaseStepActionExecution.setDescription(description);
    return testCaseStepActionExecution;
}
Also used : TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution)

Example 5 with TestCaseStepActionExecution

use of org.cerberus.crud.entity.TestCaseStepActionExecution in project cerberus-source by cerberustesting.

the class CreateUpdateTestCaseExecutionFile method updateTestCaseStepActionExecutionFromJsonArray.

/**
 * update action execution with testCaseStepActionJson and all the parameter belonging to it (control)
 * @param JSONObject testCaseJson
 * @param ApplicationContext appContext
 * @throws JSONException
 * @throws IOException
 */
TestCaseStepActionExecution updateTestCaseStepActionExecutionFromJsonArray(JSONArray testCaseStepActionJson, ApplicationContext appContext) throws JSONException, IOException {
    JSONObject currentAction = testCaseStepActionJson.getJSONObject(0);
    long id = currentAction.getLong("id");
    String test = currentAction.getString("test");
    String testCase = currentAction.getString("testcase");
    int step = currentAction.getInt("step");
    int index = currentAction.getInt("index");
    int sort = currentAction.getInt("sort");
    int sequence = currentAction.getInt("sequence");
    String conditionOper = currentAction.getString("conditionOper");
    String conditionVal1Init = currentAction.getString("conditionVal1Init");
    String conditionVal2Init = currentAction.getString("conditionVal2Init");
    String conditionVal1 = currentAction.getString("conditionVal1");
    String conditionVal2 = currentAction.getString("conditionVal2");
    String action = currentAction.getString("action");
    String value1Init = currentAction.getString("value1init");
    String value2Init = currentAction.getString("value2init");
    String value1 = currentAction.getString("value1");
    String value2 = currentAction.getString("value2");
    String forceExeStatus = currentAction.getString("forceExeStatus");
    String description = currentAction.getString("description");
    String returnCode = currentAction.getString("returnCode");
    // String wrote by the user
    String returnMessage = StringUtil.sanitize(currentAction.getString("returnMessage"));
    // default message unchanged
    if (returnMessage.equals("Action not executed"))
        returnMessage = "Action executed manually";
    long start = currentAction.getLong("start");
    long end = currentAction.getLong("end");
    // currentAction.getLong("fullStart");
    long fullStart = 0;
    // currentAction.getLong("fullEnd");
    long fullEnd = 0;
    // create this testCaseStepActionExecution and update the bdd with it
    TestCaseStepActionExecution currentTestCaseStepActionExecution = createTestCaseStepActionExecution(id, test, testCase, step, index, sequence, sort, returnCode, returnMessage, conditionOper, conditionVal1Init, conditionVal2Init, conditionVal1, conditionVal2, action, value1Init, value2Init, value1, value2, forceExeStatus, start, end, fullStart, fullEnd, null, description, null, null);
    return currentTestCaseStepActionExecution;
}
Also used : JSONObject(org.json.JSONObject) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution)

Aggregations

TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)40 TestCaseStepActionControlExecution (org.cerberus.crud.entity.TestCaseStepActionControlExecution)29 TestCaseStepExecution (org.cerberus.crud.entity.TestCaseStepExecution)28 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)6 IFactoryTestCaseStepActionExecution (org.cerberus.crud.factory.IFactoryTestCaseStepActionExecution)5 TestCaseExecutionFile (org.cerberus.crud.entity.TestCaseExecutionFile)4 MessageEvent (org.cerberus.engine.entity.MessageEvent)4 Connection (java.sql.Connection)3 PreparedStatement (java.sql.PreparedStatement)3 ResultSet (java.sql.ResultSet)3 SQLException (java.sql.SQLException)3 AnswerList (org.cerberus.util.answer.AnswerList)3 JSONObject (org.json.JSONObject)3 FileItem (org.apache.commons.fileupload.FileItem)2 FileUploadException (org.apache.commons.fileupload.FileUploadException)2 DiskFileItemFactory (org.apache.commons.fileupload.disk.DiskFileItemFactory)2 ServletFileUpload (org.apache.commons.fileupload.servlet.ServletFileUpload)2 IRecorderService (org.cerberus.engine.execution.IRecorderService)2 AnswerItem (org.cerberus.util.answer.AnswerItem)2