How to use findExecutionInQueueStatus method of org.cerberus.servlet.crud.testexecution.ReadTestCaseExecutionQueue class

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

Source:ReadTestCaseExecutionQueue.java Github

copy

Full Screen

...115 } else if (queueid != 0) {116 answer = findExecutionQueueByKeyTech(queueid, appContext, userHasPermissions);117 jsonResponse = (JSONObject) answer.getItem();118 } else if (request.getParameter("flag") != null && request.getParameter("flag").equals("queueStatus")) {119 answer = findExecutionInQueueStatus(appContext, request);120 jsonResponse = (JSONObject) answer.getItem();121 } else {122 answer = findExecutionInQueueList(appContext, true, request);123 jsonResponse = (JSONObject) answer.getItem();124 }125 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());126 jsonResponse.put("message", answer.getResultMessage().getDescription());127 jsonResponse.put("sEcho", echo);128 response.getWriter().print(jsonResponse.toString());129 } catch (JSONException e) {130 LOG.warn(e);131 //returns a default error message with the json format that is able to be parsed by the client-side132 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());133 }134 }135 /**136 * Handles the HTTP <code>GET</code> method.137 *138 * @param request servlet request139 * @param response servlet response140 * @throws ServletException if a servlet-specific error occurs141 * @throws IOException if an I/O error occurs142 */143 @Override144 protected void doGet(HttpServletRequest request, HttpServletResponse response)145 throws ServletException, IOException {146 try {147 processRequest(request, response);148 } catch (CerberusException ex) {149 LOG.warn(ex);150 }151 }152 /**153 * Handles the HTTP <code>POST</code> method.154 *155 * @param request servlet request156 * @param response servlet response157 * @throws ServletException if a servlet-specific error occurs158 * @throws IOException if an I/O error occurs159 */160 @Override161 protected void doPost(HttpServletRequest request, HttpServletResponse response)162 throws ServletException, IOException {163 try {164 processRequest(request, response);165 } catch (CerberusException ex) {166 LOG.warn(ex);167 }168 }169 private AnswerItem findExecutionQueueByKeyTech(Long queueid, ApplicationContext appContext, boolean userHasPermissions) throws JSONException, CerberusException {170 AnswerItem item = new AnswerItem();171 JSONObject object = new JSONObject();172 ITestCaseExecutionQueueService queueService = appContext.getBean(ITestCaseExecutionQueueService.class);173 //finds the project 174 AnswerItem answer = queueService.readByKey(queueid);175 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {176 //if the service returns an OK message then we can get the item and convert it to JSONformat177 TestCaseExecutionQueue lib = (TestCaseExecutionQueue) answer.getItem();178 JSONObject response = convertTestCaseExecutionInQueueToJSONObject(lib);179 int nb = 0;180 nb = queueService.getNbEntryToGo(lib.getId(), lib.getPriority());181 response.put("nbEntryInQueueToGo", nb);182 object.put("contentTable", response);183 }184 object.put("hasPermissions", userHasPermissions);185 item.setItem(object);186 item.setResultMessage(answer.getResultMessage());187 return item;188 }189 private AnswerItem findExecutionInQueueList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException {190 AnswerItem item = new AnswerItem();191 JSONObject object = new JSONObject();192 executionService = appContext.getBean(ITestCaseExecutionQueueService.class);193 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));194 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));195 /*int sEcho = Integer.valueOf(request.getParameter("sEcho"));*/196 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");197 int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "2"));198 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "id,test,testcase,country,environment,browser,tag");199 String columnToSort[] = sColumns.split(",");200 String columnName = columnToSort[columnToSortParameter];201 String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "desc");202 List<String> individualLike = new ArrayList(Arrays.asList(request.getParameter("sLike").split(",")));203 Map<String, List<String>> individualSearch = new HashMap<>();204 for (int a = 0; a < columnToSort.length; a++) {205 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {206 List<String> search = new ArrayList(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));207 if(individualLike.contains(columnToSort[a])) {208 individualSearch.put(columnToSort[a]+":like", search);209 }else {210 individualSearch.put(columnToSort[a], search);211 }212 }213 }214 AnswerList resp = executionService.readByCriteria(startPosition, length, columnName, sort, searchParameter, individualSearch);215 JSONArray jsonArray = new JSONArray();216 if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values217 for (TestCaseExecutionQueue exec : (List<TestCaseExecutionQueue>) resp.getDataList()) {218 jsonArray.put(convertTestCaseExecutionInQueueToJSONObject(exec));219 }220 }221 object.put("hasPermissions", userHasPermissions);222 object.put("contentTable", jsonArray);223 object.put("iTotalRecords", resp.getTotalRows());224 object.put("iTotalDisplayRecords", resp.getTotalRows());225 item.setItem(object);226 item.setResultMessage(resp.getResultMessage());227 return item;228 }229 private AnswerItem findExecutionInQueueStatus(ApplicationContext appContext, HttpServletRequest request) throws JSONException {230 AnswerItem item = new AnswerItem();231 JSONObject object = new JSONObject();232 executionThreadPoolService = appContext.getBean(IExecutionThreadPoolService.class);233 parameterService = appContext.getBean(IParameterService.class);234 invariantService = appContext.getBean(IInvariantService.class);235 JSONArray jsonArray = new JSONArray();236 try {237 HashMap<String, Integer> mapRunning = executionThreadPoolService.getCurrentlyRunning();238 HashMap<String, Integer> mapInQueue = executionThreadPoolService.getCurrentlyToTreat();239 HashMap<String, Integer> mapPoolSize = executionThreadPoolService.getCurrentlyPoolSizes();240 for (Map.Entry<String, Integer> entry : mapRunning.entrySet()) {241 String column = entry.getKey();242 Integer name = entry.getValue();243 if (!("".equals(column))) {...

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful