Search in sources :

Example 1 with ITestCaseStepActionExecutionService

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

the class TestCaseActionExecutionDetail method doPost.

@Override
protected void doPost(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {
    ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());
    ITestCaseStepActionExecutionService testCaseExecutionDetailService = appContext.getBean(ITestCaseStepActionExecutionService.class);
    PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);
    String test = policy.sanitize(httpServletRequest.getParameter("test"));
    String testcase = policy.sanitize(httpServletRequest.getParameter("testcase"));
    String country = policy.sanitize(httpServletRequest.getParameter("country"));
    JSONArray data = testCaseExecutionDetailService.lastActionExecutionDuration(test, testcase, country);
    try {
        httpServletResponse.setContentType("application/json");
        httpServletResponse.getWriter().print(data.toString());
    } catch (Exception e) {
        httpServletResponse.setContentType("text/html");
        httpServletResponse.getWriter().print(e.getMessage());
    }
}
Also used : ApplicationContext(org.springframework.context.ApplicationContext) PolicyFactory(org.owasp.html.PolicyFactory) JSONArray(org.json.JSONArray) ITestCaseStepActionExecutionService(org.cerberus.crud.service.ITestCaseStepActionExecutionService) ServletException(javax.servlet.ServletException) IOException(java.io.IOException)

Example 2 with ITestCaseStepActionExecutionService

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

the class UpdateTestCaseExecution method updateTestCaseStepActionFromJsonArray.

/**
 * update action execution with testCaseStepActionJson and all the parameter belonging to it (control)
 * @param JSONObject testCaseJson
 * @param ApplicationContext appContext
 * @throws JSONException
 * @throws IOException
 */
void updateTestCaseStepActionFromJsonArray(JSONArray testCaseStepActionJson, ApplicationContext appContext) throws JSONException, IOException {
    for (int i = 0; i < testCaseStepActionJson.length(); i++) {
        JSONObject currentAction = testCaseStepActionJson.getJSONObject(i);
        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);
        ITestCaseStepActionExecutionService testCaseStepActionExecutionService = appContext.getBean(ITestCaseStepActionExecutionService.class);
        testCaseStepActionExecutionService.updateTestCaseStepActionExecution(currentTestCaseStepActionExecution);
        // update the control list belonging to the current Action
        updateTestCaseStepActionControlExecutionFromJsonArray(currentAction.getJSONArray("controlArr"), appContext);
    }
}
Also used : JSONObject(org.json.JSONObject) TestCaseStepActionExecution(org.cerberus.crud.entity.TestCaseStepActionExecution) ITestCaseStepActionExecutionService(org.cerberus.crud.service.ITestCaseStepActionExecutionService)

Aggregations

ITestCaseStepActionExecutionService (org.cerberus.crud.service.ITestCaseStepActionExecutionService)2 IOException (java.io.IOException)1 ServletException (javax.servlet.ServletException)1 TestCaseStepActionExecution (org.cerberus.crud.entity.TestCaseStepActionExecution)1 JSONArray (org.json.JSONArray)1 JSONObject (org.json.JSONObject)1 PolicyFactory (org.owasp.html.PolicyFactory)1 ApplicationContext (org.springframework.context.ApplicationContext)1