How to use CreateTestCaseExecutionQueue class of org.cerberus.servlet.crud.testexecution package

Best Cerberus-source code snippet using org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue

Source:CreateTestCaseExecutionQueue.java Github

copy

Full Screen

...55/**56 *57 * @author bcivel58 */59@WebServlet(name = "CreateTestCaseExecutionQueue", urlPatterns = {"/CreateTestCaseExecutionQueue"})60public class CreateTestCaseExecutionQueue extends HttpServlet {61 private static final Logger LOG = LogManager.getLogger(CreateTestCaseExecutionQueue.class);62 /**63 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>64 * methods.65 *66 * @param request servlet request67 * @param response servlet response68 * @throws ServletException if a servlet-specific error occurs69 * @throws IOException if an I/O error occurs70 */71 protected void processRequest(HttpServletRequest request, HttpServletResponse response)72 throws ServletException, IOException, CerberusException, JSONException {73 JSONObject jsonResponse = new JSONObject();74 JSONObject executionQueue = new JSONObject();75 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());76 Answer ans = new Answer();77 AnswerItem ansItem = new AnswerItem();78 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);79 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));80 ans.setResultMessage(msg);81 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);82 String charset = request.getCharacterEncoding();83 response.setContentType("application/json");84 // Calling Servlet Transversal Util.85 ServletUtil.servletStart(request);86 /**87 * Parsing and securing all required parameters.88 */89 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them90 String actionState = policy.sanitize(request.getParameter("actionState"));91 String actionSave = policy.sanitize(request.getParameter("actionSave"));92 String environment = policy.sanitize(request.getParameter("environment"));93 String country = policy.sanitize(request.getParameter("country"));94 String manualEnvData = policy.sanitize(request.getParameter("manualEnvData"));95 // Parameter that needs to be secured --> We SECURE+DECODE them96 String test = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("test"), "", charset);97 String testcase = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("testCase"), "", charset);98 int manualURL = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("manualURL"), 0, charset);99 String manualHost = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualHost"), "", charset);100 String manualContextRoot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualContextRoot"), "", charset);101 String manualLoginRelativeURL = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualLoginRelativeURL"), "", charset);102 String tag = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("tag"), "", charset);103 String robot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robot"), "", charset);104 String robotIP = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robotIP"), "", charset);105 String robotPort = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robotPort"), "", charset);106 String browser = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("browser"), "", charset);107 String browserVersion = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("browserVersion"), "", charset);108 String platform = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("platform"), "", charset);109 String screenSize = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("screenSize"), "", charset);110 int verbose = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("verbose"), 1, charset);111 int screenshot = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("screenshot"), 0, charset);112 int pageSource = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("pageSource"), 0, charset);113 int seleniumLog = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("seleniumLog"), 0, charset);114 String timeout = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("timeout"), "", charset);115 int retries = ParameterParserUtil.parseIntegerParamAndDecode(request.getParameter("retries"), 0, charset);116 String manualExecution = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("manualExecution"), "", charset);117 String debugFlag = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("debugFlag"), "N", charset);118 // Parameter that we cannot secure as we need the html --> We DECODE them119 String[] myIds = request.getParameterValues("id");120 if (myIds == null) {121 myIds = new String[1];122 myIds[0] = "0";123 }124 long id = 0;125 Integer priority = TestCaseExecutionQueue.PRIORITY_DEFAULT;126 boolean prio_error = false;127 try {128 if (request.getParameter("priority") != null && !request.getParameter("priority").equals("")) {129 priority = Integer.valueOf(policy.sanitize(request.getParameter("priority")));130 }131 } catch (Exception ex) {132 prio_error = true;133 }134 boolean id_error = false;135 IExecutionThreadPoolService executionThreadPoolService = appContext.getBean(IExecutionThreadPoolService.class);136 // Create Tag when exist.137 if (!StringUtil.isNullOrEmpty(tag)) {138 // We create or update it.139 ITagService tagService = appContext.getBean(ITagService.class);140 tagService.createAuto(tag, "", request.getRemoteUser());141 }142 // Prepare the final answer.143 MessageEvent msg1 = new MessageEvent(MessageEventEnum.GENERIC_OK);144 Answer finalAnswer = new Answer(msg1);145 List<TestCaseExecutionQueue> insertedList = new ArrayList();146 for (String myId : myIds) {147 id_error = false;148 id = 0;149 try {150 id = Long.valueOf(myId);151 } catch (NumberFormatException ex) {152 id_error = true;153 }154 /**155 * Checking all constrains before calling the services.156 */157 if (id_error) {158 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);159 msg.setDescription(msg.getDescription().replace("%ITEM%", "Execution Queue")160 .replace("%OPERATION%", "Update")161 .replace("%REASON%", "Could not manage to convert id to an integer value."));162 ans.setResultMessage(msg);163 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);164 } else if (prio_error || priority > 2147483647 || priority < -2147483648) {165 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);166 msg.setDescription(msg.getDescription().replace("%ITEM%", "Execution Queue")167 .replace("%OPERATION%", "Update")168 .replace("%REASON%", "Could not manage to convert priority to an integer value."));169 ans.setResultMessage(msg);170 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ans);171 } else {172 try {173 /**174 * All data seems cleans so we can call the services.175 */176 ITestCaseExecutionQueueService executionQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);177 IFactoryTestCaseExecutionQueue executionQueueFactory = appContext.getBean(IFactoryTestCaseExecutionQueue.class);178 if (actionSave.equals("save")) {179 /**180 * The service was able to perform the query and confirm181 * the object exist, then we can update it.182 */183 TestCaseExecutionQueue executionQueueData;184 if (id == 0) {185 // If id is not defined, we build the execution queue from all request datas.186 executionQueueData = executionQueueFactory.create(test, testcase, country, environment, robot, robotIP, robotPort, browser, browserVersion,187 platform, screenSize, manualURL, manualHost, manualContextRoot, manualLoginRelativeURL, manualEnvData, tag, screenshot, verbose, timeout,188 pageSource, seleniumLog, 0, retries, manualExecution, priority, request.getRemoteUser(), null, null, null);189 executionQueueData.setDebugFlag(debugFlag);190 } else {191 // If id is defined, we get the execution queue from database.192 executionQueueData = executionQueueService.convert(executionQueueService.readByKey(id));193 executionQueueData.setState(TestCaseExecutionQueue.State.QUEUED);194 executionQueueData.setComment("");195 executionQueueData.setDebugFlag("N");196 executionQueueData.setPriority(TestCaseExecutionQueue.PRIORITY_DEFAULT);197 executionQueueData.setUsrCreated(request.getRemoteUser());198 }199 ansItem = executionQueueService.create(executionQueueData);200 finalAnswer = AnswerUtil.agregateAnswer(finalAnswer, (Answer) ansItem);201 if (ansItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {202 TestCaseExecutionQueue addedExecution = (TestCaseExecutionQueue) ansItem.getItem();203 insertedList.add(addedExecution);204 }205 if (myIds.length <= 1) {206 if (ansItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {207 /**208 * Update was successful. Adding Log entry.209 */210 ILogEventService logEventService = appContext.getBean(LogEventService.class);211 logEventService.createForPrivateCalls("/CreateTestCaseExecutionQueue", "CREATE", "Created ExecutionQueue : ['" + id + "']", request);212 }213 }214 }215 } catch (FactoryCreationException ex) {216 LOG.warn(ex);217 }218 }219 }220 // Update is done, we now check what action needs to be performed.221 if (actionState.equals("toQUEUED")) {222 executionThreadPoolService.executeNextInQueueAsynchroneously(false);223 }224 /**225 * Formating and returning the json result....

Full Screen

Full Screen

CreateTestCaseExecutionQueue

Using AI Code Generation

copy

Full Screen

1import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue;2import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$;3import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1;4import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2;5import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3;6import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4;7import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5;8import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6;9import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6$$anonfun$apply$7;10import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6$$anonfun$apply$7$$anonfun$apply$8;11import org.cerberus.servlet.crud.testexecution.CreateTestCaseExecutionQueue$$anonfun$apply$1$$anonfun$apply$2$$anonfun$apply$3$$anonfun$apply$4$$anonfun$apply$5$$anonfun$apply$6$$anonfun$apply$7$$anonfun$apply$8$$anonfun$apply$9;12import org.cerberus

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in CreateTestCaseExecutionQueue

Test Your Web Or Mobile Apps On 3000+ Browsers

Signup for free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful