Search in sources :

Example 1 with ITestCaseStepExecutionService

use of org.cerberus.crud.service.ITestCaseStepExecutionService in project cerberus-source by cerberustesting.

the class UpdateTestCaseExecution method updateTestCaseStepExecutionFromJsonArray.

/**
 * update Step execution with stepArray and all the parameter belonging to it (action, control)
 * @param JSONObject testCaseJson
 * @param ApplicationContext appContext
 * @throws JSONException
 * @throws IOException
 */
String updateTestCaseStepExecutionFromJsonArray(JSONArray stepArray, ApplicationContext appContext) throws JSONException, IOException {
    String returnCodeOfTestCase = "OK";
    for (int i = 0; i < stepArray.length(); i++) {
        JSONObject currentStep = stepArray.getJSONObject(i);
        long id = currentStep.getLong("id");
        String test = currentStep.getString("test");
        String testCase = currentStep.getString("testcase");
        int step = currentStep.getInt("step");
        int index = currentStep.getInt("index");
        int sort = 0;
        String loop = currentStep.getString("loop");
        String conditionOper = currentStep.getString("conditionOper");
        String conditionVal1Init = currentStep.getString("conditionVal1Init");
        String conditionVal2Init = currentStep.getString("conditionVal2Init");
        String conditionVal1 = currentStep.getString("conditionVal1");
        String conditionVal2 = currentStep.getString("conditionVal2");
        String batNumExe = "NULL";
        long start = currentStep.getLong("start");
        long end = currentStep.getLong("end");
        long fullStart = currentStep.getLong("fullStart");
        long fullEnd = currentStep.getLong("fullEnd");
        // to change
        BigDecimal timeElapsed = new BigDecimal(0);
        String returnCode = currentStep.getString("returnCode");
        // update return code if needed
        if (returnCode.equals("KO"))
            returnCodeOfTestCase = "KO";
        else if (returnCode.equals("FA") && !returnCodeOfTestCase.equals("KO"))
            returnCodeOfTestCase = "FA";
        String description = currentStep.getString("description");
        // String possibly wrote by the user
        String returnMessage = StringUtil.sanitize(currentStep.getString("returnMessage"));
        if (// default message unchanged
        returnMessage == "Step not executed")
            returnMessage = "Step executed manually";
        // create this testCaseStepExecution and update the bdd with it
        TestCaseStepExecution currentTestCaseStepExecution = createTestCaseStepExecution(id, test, testCase, step, index, sort, loop, conditionOper, conditionVal1Init, conditionVal2Init, conditionVal1, conditionVal2, batNumExe, start, end, fullStart, fullEnd, timeElapsed, returnCode, returnMessage, description);
        ITestCaseStepExecutionService testCaseStepExecutionService = appContext.getBean(ITestCaseStepExecutionService.class);
        testCaseStepExecutionService.updateTestCaseStepExecution(currentTestCaseStepExecution);
        // update action list belonging to the current Step
        updateTestCaseStepActionFromJsonArray(currentStep.getJSONArray("actionArr"), appContext);
    }
    return returnCodeOfTestCase;
}
Also used : TestCaseStepExecution(org.cerberus.crud.entity.TestCaseStepExecution) JSONObject(org.json.JSONObject) BigDecimal(java.math.BigDecimal) ITestCaseStepExecutionService(org.cerberus.crud.service.ITestCaseStepExecutionService)

Aggregations

BigDecimal (java.math.BigDecimal)1 TestCaseStepExecution (org.cerberus.crud.entity.TestCaseStepExecution)1 ITestCaseStepExecutionService (org.cerberus.crud.service.ITestCaseStepExecutionService)1 JSONObject (org.json.JSONObject)1