Best Cerberus-source code snippet using org.cerberus.servlet.crud.testexecution.ReadTestCaseExecution.getStatusList
Source: ReadTestCaseExecution.java
...243 + testCaseExecution.getControlStatus();244 testCaseExecutionsList.put(key, testCaseExecution);245 }246 testCaseExecutions = new ArrayList<>(testCaseExecutionsList.values());247 JSONObject statusFilter = getStatusList(request);248 JSONObject countryFilter = getCountryList(request, appContext);249 LinkedHashMap<String, JSONObject> columnMap = new LinkedHashMap<>();250 for (TestCaseExecution testCaseWithExecution : testCaseExecutions) {251 String controlStatus = testCaseWithExecution.getControlStatus();252 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseWithExecution.getCountry()).equals("on")) {253 JSONObject column = new JSONObject();254 column.put("country", testCaseWithExecution.getCountry());255 column.put("environment", testCaseWithExecution.getEnvironment());256 column.put("browser", testCaseWithExecution.getBrowser());257 columnMap.put(testCaseWithExecution.getBrowser() + "_" + testCaseWithExecution.getCountry() + "_" + testCaseWithExecution.getEnvironment(), column);258 }259 }260 jsonResponse.put("Columns", columnMap.values());261 answer.setItem(jsonResponse);262 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));263 return answer;264 }265 private AnswerItem findExecutionListByTag(ApplicationContext appContext, HttpServletRequest request, String Tag) throws CerberusException, ParseException, JSONException {266 AnswerItem<JSONObject> answer = new AnswerItem<>(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));267 testCaseLabelService = appContext.getBean(ITestCaseLabelService.class);268 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));269 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));270 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");271 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "test,testCase,application,priority,status,description,bugs,function");272 String columnToSort[] = sColumns.split(",");273 //Get Sorting information274 int numberOfColumnToSort = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortingCols"), "1"));275 int columnToSortParameter = 0;276 String sort = "asc";277 StringBuilder sortInformation = new StringBuilder();278 for (int c = 0; c < numberOfColumnToSort; c++) {279 columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_" + c), "0"));280 sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_" + c), "asc");281 String columnName = columnToSort[columnToSortParameter];282 sortInformation.append(columnName).append(" ").append(sort);283 if (c != numberOfColumnToSort - 1) {284 sortInformation.append(" , ");285 }286 }287 Map<String, List<String>> individualSearch = new HashMap<String, List<String>>();288 for (int a = 0; a < columnToSort.length; a++) {289 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {290 List<String> search = new ArrayList<>(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));291 individualSearch.put(columnToSort[a], search);292 }293 }294 List<TestCaseExecution> testCaseExecutions = readExecutionByTagList(appContext, Tag, startPosition, length, sortInformation.toString(), searchParameter, individualSearch);295 JSONArray executionList = new JSONArray();296 JSONObject statusFilter = getStatusList(request);297 JSONObject countryFilter = getCountryList(request, appContext);298 LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<>();299 String globalStart = "";300 String globalEnd = "";301 String globalStatus = "Finished";302 /**303 * Find the list of labels304 */305 AnswerList<TestCaseLabel> testCaseLabelList = testCaseLabelService.readByTestTestCase(null, null, null);306 for (TestCaseExecution testCaseExecution : testCaseExecutions) {307 try {308 if (testCaseExecution.getStart() != 0) {309 if ((globalStart.isEmpty()) || (globalStart.compareTo(String.valueOf(testCaseExecution.getStart())) > 0)) {310 globalStart = String.valueOf(testCaseExecution.getStart());311 }312 }313 if (testCaseExecution.getEnd() != 0) {314 if ((globalEnd.isEmpty()) || (globalEnd.compareTo(String.valueOf(testCaseExecution.getEnd())) < 0)) {315 globalEnd = String.valueOf(testCaseExecution.getEnd());316 }317 }318 if (testCaseExecution.getControlStatus().equalsIgnoreCase("PE")) {319 globalStatus = "Pending...";320 }321 String controlStatus = testCaseExecution.getControlStatus();322 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {323 JSONObject execution = testCaseExecutionToJSONObject(testCaseExecution);324 String execKey = testCaseExecution.getEnvironment() + " " + testCaseExecution.getCountry() + " " + testCaseExecution.getBrowser();325 String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();326 JSONObject execTab = new JSONObject();327 executionList.put(testCaseExecutionToJSONObject(testCaseExecution));328 JSONObject ttcObject = new JSONObject();329 if (ttc.containsKey(testCaseKey)) {330 ttcObject = ttc.get(testCaseKey);331 execTab = ttcObject.getJSONObject("execTab");332 execTab.put(execKey, execution);333 ttcObject.put("execTab", execTab);334 } else {335 ttcObject.put("test", testCaseExecution.getTest());336 ttcObject.put("testCase", testCaseExecution.getTestCase());337 ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription());338 ttcObject.put("status", testCaseExecution.getStatus());339 ttcObject.put("application", testCaseExecution.getApplication());340 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());341 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());342 execTab.put(execKey, execution);343 ttcObject.put("execTab", execTab);344 /**345 * Iterate on the label retrieved and generate HashMap346 * based on the key Test_TestCase347 */348 LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap<>();349 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList.getDataList()) {350 String key = label.getTest() + "_" + label.getTestcase();351 if (testCaseWithLabel.containsKey(key)) {352 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());353 testCaseWithLabel.get(key).put(jo);354 } else {355 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());356 testCaseWithLabel.put(key, new JSONArray().put(jo));357 }358 }359 ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));360 }361 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);362 }363 } catch (JSONException ex) {364 LOG.warn(ex);365 }366 }367 JSONObject jsonResponse = new JSONObject();368 jsonResponse.put("globalEnd", globalEnd.toString());369 jsonResponse.put("globalStart", globalStart.toString());370 jsonResponse.put("globalStatus", globalStatus);371 jsonResponse.put("testList", ttc.values());372 jsonResponse.put("iTotalRecords", ttc.size());373 jsonResponse.put("iTotalDisplayRecords", ttc.size());374 answer.setItem(jsonResponse);375 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));376 return answer;377 }378 private AnswerItem<JSONObject> findTestCaseExecutionList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException, CerberusException {379 AnswerItem<JSONObject> answer = new AnswerItem<>(new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED));380 List<TestCaseExecution> testCaseExecutionList;381 JSONObject object = new JSONObject();382 testCaseExecutionService = appContext.getBean(TestCaseExecutionService.class);383 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));384 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));385 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");386 int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "0"));387 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "test,description,active,automated,tdatecrea");388 String columnToSort[] = sColumns.split(",");389 String columnName = columnToSort[columnToSortParameter];390 String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "asc");391 List<String> system = ParameterParserUtil.parseListParamAndDecodeAndDeleteEmptyValue(request.getParameterValues("system"), Arrays.asList("DEFAULT"), "UTF-8");392 Map<String, List<String>> individualSearch = new HashMap<>();393 List<String> individualLike = new ArrayList<>(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));394 for (int a = 0; a < columnToSort.length; a++) {395 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {396 List<String> search = new ArrayList<>(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));397 if (individualLike.contains(columnToSort[a])) {398 individualSearch.put(columnToSort[a] + ":like", search);399 } else {400 individualSearch.put(columnToSort[a], search);401 }402 }403 }404 AnswerList<TestCaseExecution> resp = testCaseExecutionService.readByCriteria(startPosition, length, columnName.concat(" ").concat(sort), searchParameter, individualSearch, individualLike, system);405 JSONArray jsonArray = new JSONArray();406 if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values407 for (TestCaseExecution testCaseExecution : (List<TestCaseExecution>) resp.getDataList()) {408 jsonArray.put(testCaseExecution.toJson(true).put("hasPermissions", userHasPermissions));409 }410 }411 object.put("contentTable", jsonArray);412 object.put("hasPermissions", userHasPermissions);413 object.put("iTotalRecords", resp.getTotalRows());414 object.put("iTotalDisplayRecords", resp.getTotalRows());415 answer.setItem(object);416 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK_GENERIC));417 return answer;418 }419 private JSONObject getStatusList(HttpServletRequest request) {420 JSONObject statusList = new JSONObject();421 try {422 statusList.put("OK", ParameterParserUtil.parseStringParam(request.getParameter("OK"), "off"));423 statusList.put("KO", ParameterParserUtil.parseStringParam(request.getParameter("KO"), "off"));424 statusList.put("NA", ParameterParserUtil.parseStringParam(request.getParameter("NA"), "off"));425 statusList.put("NE", ParameterParserUtil.parseStringParam(request.getParameter("NE"), "off"));426 statusList.put("PE", ParameterParserUtil.parseStringParam(request.getParameter("PE"), "off"));427 statusList.put("FA", ParameterParserUtil.parseStringParam(request.getParameter("FA"), "off"));428 statusList.put("CA", ParameterParserUtil.parseStringParam(request.getParameter("CA"), "off"));429 } catch (JSONException ex) {430 LOG.warn(ex);431 }432 return statusList;433 }...
Check out the latest blogs from LambdaTest on this topic:
QA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.
There is just one area where each member of the software testing community has a distinct point of view! Metrics! This contentious issue sparks intense disputes, and most conversations finish with no definitive conclusion. It covers a wide range of topics: How can testing efforts be measured? What is the most effective technique to assess effectiveness? Which of the many components should be quantified? How can we measure the quality of our testing performance, among other things?
One of the most important tasks of a software developer is not just writing code fast; it is the ability to find what causes errors and bugs whenever you encounter one and the ability to solve them quickly.
As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????
Traditional software testers must step up if they want to remain relevant in the Agile environment. Agile will most probably continue to be the leading form of the software development process in the coming years.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!