Search in sources :

Example 1 with IFactoryTestCaseStepAction

use of org.cerberus.crud.factory.IFactoryTestCaseStepAction in project cerberus-source by cerberustesting.

the class UpdateTestCaseWithDependencies1 method getTestCaseStepActionFromParameter.

private List<TestCaseStepAction> getTestCaseStepActionFromParameter(HttpServletRequest request, ApplicationContext appContext, String test, String testCase, JSONArray testCaseStepActionJson) throws JSONException {
    List<TestCaseStepAction> testCaseStepAction = new ArrayList();
    IFactoryTestCaseStepAction testCaseStepActionFactory = appContext.getBean(IFactoryTestCaseStepAction.class);
    for (int i = 0; i < testCaseStepActionJson.length(); i++) {
        JSONObject tcsaJson = testCaseStepActionJson.getJSONObject(i);
        boolean delete = tcsaJson.getBoolean("toDelete");
        int step = tcsaJson.isNull("step") ? -1 : tcsaJson.getInt("step");
        int sequence = tcsaJson.isNull("sequence") ? -1 : tcsaJson.getInt("sequence");
        int sort = tcsaJson.isNull("sort") ? -1 : tcsaJson.getInt("sort");
        String conditionOper = tcsaJson.getString("conditionOper");
        String conditionVal1 = tcsaJson.getString("conditionVal1");
        String conditionVal2 = tcsaJson.getString("conditionVal2");
        String action = tcsaJson.getString("action");
        String object = tcsaJson.getString("object");
        String property = tcsaJson.getString("property");
        String forceExeStatus = tcsaJson.getString("forceExeStatus");
        String description = tcsaJson.getString("description");
        String screenshot = tcsaJson.getString("screenshotFileName");
        JSONArray controlArray = tcsaJson.getJSONArray("controlArr");
        if (!delete) {
            TestCaseStepAction tcsa = testCaseStepActionFactory.create(test, testCase, step, sequence, sort, conditionOper, conditionVal1, conditionVal2, action, object, property, forceExeStatus, description, screenshot);
            tcsa.setTestCaseStepActionControl(getTestCaseStepActionControlFromParameter(request, appContext, test, testCase, controlArray));
            testCaseStepAction.add(tcsa);
        }
    }
    return testCaseStepAction;
}
Also used : IFactoryTestCaseStepAction(org.cerberus.crud.factory.IFactoryTestCaseStepAction) TestCaseStepAction(org.cerberus.crud.entity.TestCaseStepAction) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) IFactoryTestCaseStepAction(org.cerberus.crud.factory.IFactoryTestCaseStepAction) JSONArray(org.json.JSONArray)

Example 2 with IFactoryTestCaseStepAction

use of org.cerberus.crud.factory.IFactoryTestCaseStepAction in project cerberus-source by cerberustesting.

the class UpdateTestCaseWithDependencies method getTestCaseStepActionFromParameter.

private List<TestCaseStepAction> getTestCaseStepActionFromParameter(HttpServletRequest request, ApplicationContext appContext, String test, String testCase, String stepInc) {
    List<TestCaseStepAction> testCaseStepAction = new ArrayList();
    String[] stepAction_increment = getParameterValuesIfExists(request, "action_increment_" + stepInc);
    IFactoryTestCaseStepAction testCaseStepActionFactory = appContext.getBean(IFactoryTestCaseStepAction.class);
    if (stepAction_increment != null) {
        for (String inc : stepAction_increment) {
            String delete = getParameterIfExists(request, "action_delete_" + stepInc + "_" + inc);
            int sequence = getParameterIfExists(request, "action_technical_sequence_" + stepInc + "_" + inc) == null ? 0 : Integer.parseInt(getParameterIfExists(request, "action_technical_sequence_" + stepInc + "_" + inc));
            int sort = getParameterIfExists(request, "action_sequence_" + stepInc + "_" + inc) == null ? 0 : Integer.parseInt(getParameterIfExists(request, "action_sequence_" + stepInc + "_" + inc));
            String conditionOper = getParameterIfExists(request, "action_conditionoper_" + stepInc + "_" + inc);
            String conditionVal1 = getParameterIfExists(request, "action_conditionval1_" + stepInc + "_" + inc);
            String conditionVal2 = getParameterIfExists(request, "action_conditionval2_" + stepInc + "_" + inc);
            String action = getParameterIfExists(request, "action_action_" + stepInc + "_" + inc);
            String object = getParameterIfExists(request, "action_object_" + stepInc + "_" + inc);
            if (object != null) {
                object = object.replaceAll("\"", "\\\"");
            }
            String property = getParameterIfExists(request, "action_property_" + stepInc + "_" + inc);
            String forceExeStatus = getParameterIfExists(request, "action_forceexestatus_" + stepInc + "_" + inc);
            String description = getParameterIfExists(request, "action_description_" + stepInc + "_" + inc);
            String screenshot = getParameterIfExists(request, "action_screenshot_" + stepInc + "_" + inc);
            if (delete == null) {
                TestCaseStepAction tcsa = testCaseStepActionFactory.create(test, testCase, -1, sequence, sort, conditionOper, conditionVal1, conditionVal2, action, object, property, forceExeStatus, description, screenshot);
                tcsa.setTestCaseStepActionControl(getTestCaseStepActionControlFromParameter(request, appContext, test, testCase, stepInc, inc));
                testCaseStepAction.add(tcsa);
            }
        }
    }
    return testCaseStepAction;
}
Also used : IFactoryTestCaseStepAction(org.cerberus.crud.factory.IFactoryTestCaseStepAction) TestCaseStepAction(org.cerberus.crud.entity.TestCaseStepAction) ArrayList(java.util.ArrayList) IFactoryTestCaseStepAction(org.cerberus.crud.factory.IFactoryTestCaseStepAction)

Aggregations

ArrayList (java.util.ArrayList)2 TestCaseStepAction (org.cerberus.crud.entity.TestCaseStepAction)2 IFactoryTestCaseStepAction (org.cerberus.crud.factory.IFactoryTestCaseStepAction)2 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1