Search in sources :

Example 1 with IFactoryTestCaseStepActionControl

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

the class UpdateTestCaseWithDependencies method getTestCaseStepActionControlFromParameter.

private List<TestCaseStepActionControl> getTestCaseStepActionControlFromParameter(HttpServletRequest request, ApplicationContext appContext, String test, String testCase, String stepInc, String actionInc) {
    List<TestCaseStepActionControl> testCaseStepActionControl = new ArrayList();
    String[] stepActionControl_increment = getParameterValuesIfExists(request, "control_increment_" + stepInc + "_" + actionInc);
    IFactoryTestCaseStepActionControl testCaseStepActionControlFactory = appContext.getBean(IFactoryTestCaseStepActionControl.class);
    if (stepActionControl_increment != null) {
        for (String inc : stepActionControl_increment) {
            String delete = getParameterIfExists(request, "control_delete_" + stepInc + "_" + actionInc + "_" + inc);
            int controlsequence = getParameterIfExists(request, "control_technical_control_" + stepInc + "_" + actionInc + "_" + inc) == null ? 0 : Integer.parseInt(getParameterIfExists(request, "control_technical_control_" + stepInc + "_" + actionInc + "_" + inc));
            int sort = getParameterIfExists(request, "control_controlsequence_" + stepInc + "_" + actionInc + "_" + inc) == null ? 0 : Integer.parseInt(getParameterIfExists(request, "control_controlsequence_" + stepInc + "_" + actionInc + "_" + inc));
            String conditionOper = getParameterIfExists(request, "control_conditionoper_" + stepInc + "_" + actionInc + "_" + inc);
            String conditionVal1 = getParameterIfExists(request, "control_conditionval1_" + stepInc + "_" + actionInc + "_" + inc);
            conditionVal1 = conditionVal1 != null ? conditionVal1.replaceAll("\"", "\\\"") : null;
            String conditionVal2 = getParameterIfExists(request, "control_conditionval2_" + stepInc + "_" + actionInc + "_" + inc);
            conditionVal2 = conditionVal2 != null ? conditionVal2.replaceAll("\"", "\\\"") : null;
            String control = getParameterIfExists(request, "control_control_" + stepInc + "_" + actionInc + "_" + inc);
            String value1 = getParameterIfExists(request, "control_value1_" + stepInc + "_" + actionInc + "_" + inc);
            value1 = value1 != null ? value1.replaceAll("\"", "\\\"") : null;
            String value2 = getParameterIfExists(request, "control_value2_" + stepInc + "_" + actionInc + "_" + inc);
            value2 = value2 != null ? value2.replaceAll("\"", "\\\"") : null;
            String fatal = getParameterIfExists(request, "control_fatal_" + stepInc + "_" + actionInc + "_" + inc);
            String description = getParameterIfExists(request, "control_description_" + stepInc + "_" + actionInc + "_" + inc);
            String screenshot = getParameterIfExists(request, "control_screenshot_" + stepInc + "_" + actionInc + "_" + inc);
            if (delete == null) {
                testCaseStepActionControl.add(testCaseStepActionControlFactory.create(test, testCase, -1, -1, controlsequence, sort, conditionOper, conditionVal1, conditionVal2, control, value1, value2, fatal, description, screenshot));
            }
        }
    }
    return testCaseStepActionControl;
}
Also used : IFactoryTestCaseStepActionControl(org.cerberus.crud.factory.IFactoryTestCaseStepActionControl) ArrayList(java.util.ArrayList) TestCaseStepActionControl(org.cerberus.crud.entity.TestCaseStepActionControl) IFactoryTestCaseStepActionControl(org.cerberus.crud.factory.IFactoryTestCaseStepActionControl)

Example 2 with IFactoryTestCaseStepActionControl

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

the class UpdateTestCaseWithDependencies1 method getTestCaseStepActionControlFromParameter.

private List<TestCaseStepActionControl> getTestCaseStepActionControlFromParameter(HttpServletRequest request, ApplicationContext appContext, String test, String testCase, JSONArray controlArray) throws JSONException {
    List<TestCaseStepActionControl> testCaseStepActionControl = new ArrayList();
    IFactoryTestCaseStepActionControl testCaseStepActionControlFactory = appContext.getBean(IFactoryTestCaseStepActionControl.class);
    for (int i = 0; i < controlArray.length(); i++) {
        JSONObject controlJson = controlArray.getJSONObject(i);
        boolean delete = controlJson.getBoolean("toDelete");
        int step = controlJson.isNull("step") ? -1 : controlJson.getInt("step");
        int sequence = controlJson.isNull("sequence") ? -1 : controlJson.getInt("sequence");
        int control = controlJson.isNull("controlSequence") ? -1 : controlJson.getInt("controlSequence");
        int sort = controlJson.isNull("sort") ? -1 : controlJson.getInt("sort");
        String conditionOper = controlJson.isNull("conditionOper") ? "always" : controlJson.getString("conditionOper");
        String conditionVal1 = controlJson.isNull("conditionVal1") ? "" : controlJson.getString("conditionVal1");
        String conditionVal2 = controlJson.isNull("conditionVal2") ? "" : controlJson.getString("conditionVal2");
        String type = controlJson.getString("objType");
        String controlValue = controlJson.getString("control");
        String value1 = controlJson.getString("value1");
        String value2 = controlJson.getString("value2");
        String fatal = controlJson.getString("fatal");
        String description = controlJson.getString("description");
        String screenshot = controlJson.getString("screenshotFileName");
        if (!delete) {
            testCaseStepActionControl.add(testCaseStepActionControlFactory.create(test, testCase, step, sequence, control, sort, conditionOper, conditionVal1, conditionVal2, controlValue, value1, value2, fatal, description, screenshot));
        }
    }
    return testCaseStepActionControl;
}
Also used : IFactoryTestCaseStepActionControl(org.cerberus.crud.factory.IFactoryTestCaseStepActionControl) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) TestCaseStepActionControl(org.cerberus.crud.entity.TestCaseStepActionControl) IFactoryTestCaseStepActionControl(org.cerberus.crud.factory.IFactoryTestCaseStepActionControl)

Aggregations

ArrayList (java.util.ArrayList)2 TestCaseStepActionControl (org.cerberus.crud.entity.TestCaseStepActionControl)2 IFactoryTestCaseStepActionControl (org.cerberus.crud.factory.IFactoryTestCaseStepActionControl)2 JSONObject (org.json.JSONObject)1