How to use getTestCaseObj method of org.cerberus.crud.entity.TestCaseExecution class

Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseExecution.getTestCaseObj

Source:ReadTestCaseExecution.java Github

copy

Full Screen

...337 ttcObject.put("execTab", execTab);338 } else {339 ttcObject.put("test", testCaseExecution.getTest());340 ttcObject.put("testCase", testCaseExecution.getTestCase());341 ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());342 ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription());343 ttcObject.put("status", testCaseExecution.getStatus());344 ttcObject.put("application", testCaseExecution.getApplication());345 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());346 ttcObject.put("bugId", new JSONObject("{\"bugId\":\"" + testCaseExecution.getTestCaseObj().getBugID() + "\",\"bugTrackerUrl\":\"" + testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID()) + "\"}"));347 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());348 execTab.put(execKey, execution);349 ttcObject.put("execTab", execTab);350 /**351 * Iterate on the label retrieved and generate HashMap352 * based on the key Test_TestCase353 */354 LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap();355 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList.getDataList()) {356 String key = label.getTest() + "_" + label.getTestcase();357 if (testCaseWithLabel.containsKey(key)) {358 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());359 testCaseWithLabel.get(key).put(jo);360 } else {361 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());362 testCaseWithLabel.put(key, new JSONArray().put(jo));363 }364 }365 ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));366 }367 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);368 }369 } catch (JSONException ex) {370 LOG.warn(ex);371 }372 }373 JSONObject jsonResponse = new JSONObject();374 jsonResponse.put("globalEnd", globalEnd.toString());375 jsonResponse.put("globalStart", globalStart.toString());376 jsonResponse.put("globalStatus", globalStatus);377 jsonResponse.put("testList", ttc.values());378 jsonResponse.put("iTotalRecords", ttc.size());379 jsonResponse.put("iTotalDisplayRecords", ttc.size());380 answer.setItem(jsonResponse);381 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));382 return answer;383 }384 private AnswerItem findTestCaseExecutionList(ApplicationContext appContext, boolean userHasPermissions, HttpServletRequest request) throws JSONException, CerberusException {385 AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED));386 AnswerList testCaseExecutionList = new AnswerList();387 JSONObject object = new JSONObject();388 testCaseExecutionService = appContext.getBean(TestCaseExecutionService.class);389 int startPosition = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayStart"), "0"));390 int length = Integer.valueOf(ParameterParserUtil.parseStringParam(request.getParameter("iDisplayLength"), "0"));391 String searchParameter = ParameterParserUtil.parseStringParam(request.getParameter("sSearch"), "");392 int columnToSortParameter = Integer.parseInt(ParameterParserUtil.parseStringParam(request.getParameter("iSortCol_0"), "0"));393 String sColumns = ParameterParserUtil.parseStringParam(request.getParameter("sColumns"), "test,description,active,automated,tdatecrea");394 String columnToSort[] = sColumns.split(",");395 String columnName = columnToSort[columnToSortParameter];396 String sort = ParameterParserUtil.parseStringParam(request.getParameter("sSortDir_0"), "asc");397 Map<String, List<String>> individualSearch = new HashMap<>();398 List<String> individualLike = new ArrayList(Arrays.asList(ParameterParserUtil.parseStringParam(request.getParameter("sLike"), "").split(",")));399 400 for (int a = 0; a < columnToSort.length; a++) {401 if (null != request.getParameter("sSearch_" + a) && !request.getParameter("sSearch_" + a).isEmpty()) {402 List<String> search = new ArrayList(Arrays.asList(request.getParameter("sSearch_" + a).split(",")));403 if(individualLike.contains(columnToSort[a])) {404 individualSearch.put(columnToSort[a]+":like", search);405 }else {406 individualSearch.put(columnToSort[a], search);407 }408 }409 }410 411 testCaseExecutionList = testCaseExecutionService.readByCriteria(startPosition, length, columnName.concat(" ").concat(sort), searchParameter, individualSearch, individualLike);412 JSONArray jsonArray = new JSONArray();413 if (testCaseExecutionList.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values414 for (TestCaseExecution testCaseExecution : (List<TestCaseExecution>) testCaseExecutionList.getDataList()) {415 jsonArray.put(testCaseExecution.toJson(true).put("hasPermissions", userHasPermissions));416 }417 }418 object.put("contentTable", jsonArray);419 object.put("hasPermissions", userHasPermissions);420 object.put("iTotalRecords", testCaseExecutionList.getTotalRows());421 object.put("iTotalDisplayRecords", testCaseExecutionList.getTotalRows());422 answer.setItem(object);423 answer.setResultMessage(testCaseExecutionList.getResultMessage());424 return answer;425 }426 private JSONObject getStatusList(HttpServletRequest request) {427 JSONObject statusList = new JSONObject();428 try {429 statusList.put("OK", ParameterParserUtil.parseStringParam(request.getParameter("OK"), "off"));430 statusList.put("KO", ParameterParserUtil.parseStringParam(request.getParameter("KO"), "off"));431 statusList.put("NA", ParameterParserUtil.parseStringParam(request.getParameter("NA"), "off"));432 statusList.put("NE", ParameterParserUtil.parseStringParam(request.getParameter("NE"), "off"));433 statusList.put("PE", ParameterParserUtil.parseStringParam(request.getParameter("PE"), "off"));434 statusList.put("FA", ParameterParserUtil.parseStringParam(request.getParameter("FA"), "off"));435 statusList.put("CA", ParameterParserUtil.parseStringParam(request.getParameter("CA"), "off"));436 } catch (JSONException ex) {437 LOG.warn(ex);438 }439 return statusList;440 }441 private JSONObject getCountryList(HttpServletRequest request, ApplicationContext appContext) {442 JSONObject countryList = new JSONObject();443 try {444 IInvariantService invariantService = appContext.getBean(InvariantService.class);445 AnswerList answer = invariantService.readByIdname("COUNTRY"); //TODO: handle if the response does not turn ok446 for (Invariant country : (List<Invariant>) answer.getDataList()) {447 countryList.put(country.getValue(), ParameterParserUtil.parseStringParam(request.getParameter(country.getValue()), "off"));448 }449 } catch (JSONException ex) {450 LOG.warn(ex);451 }452 return countryList;453 }454 private List<TestCaseExecution> hashExecution(List<TestCaseExecution> testCaseExecutions, List<TestCaseExecutionQueue> testCaseExecutionsInQueue) throws ParseException {455 LinkedHashMap<String, TestCaseExecution> testCaseExecutionsList = new LinkedHashMap();456 SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");457 for (TestCaseExecution testCaseExecution : testCaseExecutions) {458 String key = testCaseExecution.getBrowser() + "_"459 + testCaseExecution.getCountry() + "_"460 + testCaseExecution.getEnvironment() + "_"461 + testCaseExecution.getTest() + "_"462 + testCaseExecution.getTestCase();463 testCaseExecutionsList.put(key, testCaseExecution);464 }465 for (TestCaseExecutionQueue testCaseExecutionInQueue : testCaseExecutionsInQueue) {466 TestCaseExecution testCaseExecution = testCaseExecutionInQueueService.convertToTestCaseExecution(testCaseExecutionInQueue);467 String key = testCaseExecution.getBrowser() + "_"468 + testCaseExecution.getCountry() + "_"469 + testCaseExecution.getEnvironment() + "_"470 + testCaseExecution.getTest() + "_"471 + testCaseExecution.getTestCase();472 if ((testCaseExecutionsList.containsKey(key)473 && testCaseExecutionsList.get(key).getStart() < testCaseExecutionInQueue.getRequestDate().getTime())474 || !testCaseExecutionsList.containsKey(key)) {475 testCaseExecutionsList.put(key, testCaseExecution);476 }477 }478 List<TestCaseExecution> result = new ArrayList<TestCaseExecution>(testCaseExecutionsList.values());479 return result;480 }481 private JSONObject testCaseExecutionToJSONObject(482 TestCaseExecution testCaseExecution) throws JSONException {483 JSONObject result = new JSONObject();484 result.put("ID", String.valueOf(testCaseExecution.getId()));485 result.put("Test", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTest()));486 result.put("TestCase", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCase()));487 result.put("Environment", JavaScriptUtils.javaScriptEscape(testCaseExecution.getEnvironment()));488 result.put("Start", testCaseExecution.getStart());489 result.put("End", testCaseExecution.getEnd());490 result.put("Country", JavaScriptUtils.javaScriptEscape(testCaseExecution.getCountry()));491 result.put("Browser", JavaScriptUtils.javaScriptEscape(testCaseExecution.getBrowser()));492 result.put("ControlStatus", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlStatus()));493 result.put("ControlMessage", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlMessage()));494 result.put("Status", JavaScriptUtils.javaScriptEscape(testCaseExecution.getStatus()));495 String bugId;496 if (testCaseExecution.getApplicationObj() != null && testCaseExecution.getApplicationObj().getBugTrackerUrl() != null497 && !"".equals(testCaseExecution.getApplicationObj().getBugTrackerUrl()) && testCaseExecution.getTestCaseObj().getBugID() != null) {498 bugId = testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID());499 bugId = new StringBuffer("<a href='")500 .append(bugId)501 .append("' target='reportBugID'>")502 .append(testCaseExecution.getTestCaseObj().getBugID())503 .append("</a>")504 .toString();505 } else {506 bugId = testCaseExecution.getTestCaseObj().getBugID();507 }508 result.put("BugID", bugId);509 result.put("Comment", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getComment()));510 result.put("Priority", JavaScriptUtils.javaScriptEscape(String.valueOf(testCaseExecution.getTestCaseObj().getPriority())));511 result.put("Function", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getFunction()));512 result.put("Application", JavaScriptUtils.javaScriptEscape(testCaseExecution.getApplication()));513 result.put("ShortDescription", testCaseExecution.getTestCaseObj().getDescription());514 return result;515 }516 private List<TestCaseExecution> readExecutionByTagList(ApplicationContext appContext, String Tag, int startPosition, int length, String sortInformation, String searchParameter, Map<String, List<String>> individualSearch) throws ParseException, CerberusException {517 AnswerList<TestCaseExecution> testCaseExecution;518 AnswerList<TestCaseExecutionQueue> testCaseExecutionInQueue;519 ITestCaseExecutionService testCaseExecService = appContext.getBean(ITestCaseExecutionService.class);520 ITestCaseExecutionQueueService testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);521 /**522 * Get list of execution by tag, env, country, browser523 */524 testCaseExecution = testCaseExecService.readByTagByCriteria(Tag, startPosition, length, sortInformation, searchParameter, individualSearch);525 List<TestCaseExecution> testCaseExecutions = testCaseExecution.getDataList();526 /**527 * Get list of Execution in Queue by Tag528 */529 testCaseExecutionInQueue = testCaseExecutionInQueueService.readByTagByCriteria(Tag, startPosition, length, sortInformation, searchParameter, individualSearch);530 List<TestCaseExecutionQueue> testCaseExecutionsInQueue = testCaseExecutionInQueue.getDataList();531 /**532 * Feed hash map with execution from the two list (to get only one by533 * test,testcase,country,env,browser)534 */535 testCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue);536 return testCaseExecutions;537 }538 private AnswerItem findExecutionListBySystem(String system, ApplicationContext appContext, HttpServletRequest request)539 throws ParseException, JSONException {540 AnswerItem answer = new AnswerItem(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));541 /**542 * Parse all parameters used in the search.543 */544 String charset = request.getCharacterEncoding();545 /**546 * Parse parameters - list of values547 */548 List<String> testList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("test"), null, charset);549 List<String> applicationList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("application"), null, charset);550 List<String> projectList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("project"), null, charset);551 List<String> tcstatusList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcstatus"), null, charset);552 List<String> groupList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("group"), null, charset);553 List<String> tcactiveList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcactive"), null, charset);554 List<String> priorityList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("priority"), null, charset);555 List<String> targetsprintList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("targetsprint"), null, charset);556 List<String> targetrevisionList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("targetrevision"), null, charset);557 List<String> creatorList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("creator"), null, charset);558 List<String> implementerList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("implementer"), null, charset);559 List<String> environmentList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("environment"), null, charset);560 List<String> buildList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("build"), null, charset);561 List<String> revisionList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("revision"), null, charset);562 List<String> countryList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("country"), null, charset);563 List<String> browserList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("browser"), null, charset);564 List<String> tcestatusList = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("tcestatus"), null, charset);565 //Sorts the lists 566 if (countryList != null) {567 Collections.sort(countryList);568 }569 if (browserList != null) {570 Collections.sort(browserList);571 }572 /**573 * Parse parameters - free text574 */575 String bugid = StringEscapeUtils.escapeHtml4(request.getParameter("bugid"));576 String ticket = StringEscapeUtils.escapeHtml4(request.getParameter("ticket"));577 String ip = StringEscapeUtils.escapeHtml4(request.getParameter("ip"));578 String port = StringEscapeUtils.escapeHtml4(request.getParameter("port"));579 String tag = StringEscapeUtils.escapeHtml4(request.getParameter("tag"));580 String browserversion = StringEscapeUtils.escapeHtml4(request.getParameter("browserversion"));581 String comment = StringEscapeUtils.escapeHtml4(request.getParameter("comment"));582 /**583 * Gets regular executions (not in queue)584 */585 AnswerList answerExecutions = testCaseExecutionService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList,586 targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList,587 environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket);588 List<TestCaseExecution> testCaseExecutions = (List<TestCaseExecution>) answerExecutions.getDataList();589 /**590 * Get list of Execution in Queue by Tag591 */592 ITestCaseExecutionQueueService testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);593 AnswerList answerExecutionsInQueue = testCaseExecutionInQueueService.readBySystemByVarious(system, testList, applicationList, projectList, tcstatusList, groupList, tcactiveList, priorityList,594 targetsprintList, targetrevisionList, creatorList, implementerList, buildList, revisionList,595 environmentList, countryList, browserList, tcestatusList, ip, port, tag, browserversion, comment, bugid, ticket);596 List<TestCaseExecutionQueue> testCaseExecutionsInQueue = (List<TestCaseExecutionQueue>) answerExecutionsInQueue.getDataList();597 /**598 * Merge Test Case Executions599 */600 List<TestCaseExecution> allTestCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue);601 JSONArray executionList = new JSONArray();602 LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<String, JSONObject>();603 for (TestCaseExecution testCaseExecution : allTestCaseExecutions) {604 try {605 JSONObject execution = testCaseExecutionToJSONObject(testCaseExecution);606 String execKey = testCaseExecution.getCountry() + " " + testCaseExecution.getBrowser(); //the key is country and browser607 String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();608 JSONObject execTab = new JSONObject();609 executionList.put(testCaseExecutionToJSONObject(testCaseExecution));610 JSONObject ttcObject = new JSONObject();611 if (ttc.containsKey(testCaseKey)) {612 ttcObject = ttc.get(testCaseKey);613 execTab = ttcObject.getJSONObject("execTab");614 execTab.put(execKey, execution);615 ttcObject.put("execTab", execTab);616 } else {617 ttcObject.put("test", testCaseExecution.getTest());618 ttcObject.put("testCase", testCaseExecution.getTestCase());619 ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());620 ttcObject.put("shortDesc", testCaseExecution.getTestCaseObj().getDescription());621 ttcObject.put("status", testCaseExecution.getTestCaseObj().getStatus());622 ttcObject.put("application", testCaseExecution.getApplication());623 ttcObject.put("bugId", testCaseExecution.getTestCaseObj().getBugID());624 ttcObject.put("ticket", testCaseExecution.getTestCaseObj().getTicket());625 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());626 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());627 ttcObject.put("status", testCaseExecution.getStatus());628 ttcObject.put("group", testCaseExecution.getTestCaseObj().getGroup());629 execTab.put(execKey, execution);630 ttcObject.put("execTab", execTab);631 }632 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);633 } catch (JSONException ex) {634 LOG.warn(ex);635 }636 }637 JSONObject jsonResponse = new JSONObject();638 jsonResponse.put("contentTable", ttc.values());639 jsonResponse.put("iTotalRecords", ttc.size());640 jsonResponse.put("iTotalDisplayRecords", ttc.size());641 answer.setItem(jsonResponse);642 answer.setResultMessage(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));...

Full Screen

Full Screen

Source:ReadTestCaseExecutionByTag.java Github

copy

Full Screen

...175 String bugId;176 String comment;177 String function;178 String shortDesc;179 if ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null)) {180 if (testCaseExecution.getApplicationObj() != null && testCaseExecution.getApplicationObj().getBugTrackerUrl() != null181 && !"".equals(testCaseExecution.getApplicationObj().getBugTrackerUrl()) && testCaseExecution.getTestCaseObj().getBugID() != null) {182 bugId = testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID());183 bugId = new StringBuffer("<a href='")184 .append(bugId)185 .append("' target='reportBugID'>")186 .append(testCaseExecution.getTestCaseObj().getBugID())187 .append("</a>")188 .toString();189 } else {190 bugId = testCaseExecution.getTestCaseObj().getBugID();191 }192 comment = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getComment());193 function = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getFunction());194 shortDesc = testCaseExecution.getTestCaseObj().getDescription();195 } else {196 bugId = "";197 comment = "";198 function = "";199 shortDesc = "";200 }201 result.put("BugID", bugId);202 result.put("Priority", JavaScriptUtils.javaScriptEscape(String.valueOf(testCaseExecution.getTestCaseObj().getPriority())));203 result.put("Comment", comment);204 result.put("Function", function);205 result.put("ShortDescription", shortDesc);206 result.put("Application", JavaScriptUtils.javaScriptEscape(testCaseExecution.getApplication()));207 return result;208 }209 private JSONObject getStatusList(HttpServletRequest request) {210 JSONObject statusList = new JSONObject();211 try {212 statusList.put("OK", ParameterParserUtil.parseStringParam(request.getParameter("OK"), "off"));213 statusList.put("KO", ParameterParserUtil.parseStringParam(request.getParameter("KO"), "off"));214 statusList.put("NA", ParameterParserUtil.parseStringParam(request.getParameter("NA"), "off"));215 statusList.put("NE", ParameterParserUtil.parseStringParam(request.getParameter("NE"), "off"));216 statusList.put("PE", ParameterParserUtil.parseStringParam(request.getParameter("PE"), "off"));217 statusList.put("FA", ParameterParserUtil.parseStringParam(request.getParameter("FA"), "off"));218 statusList.put("CA", ParameterParserUtil.parseStringParam(request.getParameter("CA"), "off"));219 statusList.put("QU", ParameterParserUtil.parseStringParam(request.getParameter("QU"), "off"));220 } catch (JSONException ex) {221 LOG.error("Error on getStatusList : " + ex);222 }223 return statusList;224 }225 private JSONObject getCountryList(HttpServletRequest request, ApplicationContext appContext) {226 JSONObject countryList = new JSONObject();227 try {228 IInvariantService invariantService = appContext.getBean(InvariantService.class);229 AnswerList answer = invariantService.readByIdname("COUNTRY"); //TODO: handle if the response does not turn ok230 for (Invariant country : (List<Invariant>) answer.getDataList()) {231 countryList.put(country.getValue(), ParameterParserUtil.parseStringParam(request.getParameter(country.getValue()), "off"));232 }233 } catch (JSONException ex) {234 LOG.error("Error on getCountryList : " + ex);235 }236 return countryList;237 }238 private JSONObject generateTestCaseExecutionTable(ApplicationContext appContext, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) {239 JSONObject testCaseExecutionTable = new JSONObject();240 LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<String, JSONObject>();241 LinkedHashMap<String, JSONObject> columnMap = new LinkedHashMap<String, JSONObject>();242 testCaseLabelService = appContext.getBean(ITestCaseLabelService.class);243 AnswerList testCaseLabelList = testCaseLabelService.readByTestTestCase(null, null);244 for (TestCaseExecution testCaseExecution : testCaseExecutions) {245 try {246 String controlStatus = testCaseExecution.getControlStatus();247 // We check is Country and status is inside the fitered values.248 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {249 JSONObject executionJSON = testCaseExecutionToJSONObject(testCaseExecution);250 String execKey = testCaseExecution.getEnvironment() + " " + testCaseExecution.getCountry() + " " + testCaseExecution.getRobotDecli();251 String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();252 JSONObject execTab = new JSONObject();253 JSONObject ttcObject = new JSONObject();254 if (ttc.containsKey(testCaseKey)) {255 // We add an execution entry into the testcase line.256 ttcObject = ttc.get(testCaseKey);257 execTab = ttcObject.getJSONObject("execTab");258 execTab.put(execKey, executionJSON);259 ttcObject.put("execTab", execTab);260 Integer toto = (Integer) ttcObject.get("NbExecutionsTotal");261 toto += testCaseExecution.getNbExecutions() - 1;262 ttcObject.put("NbExecutionsTotal", toto);263 } else {264 // We add a new testcase entry (with The current execution).265 ttcObject.put("test", testCaseExecution.getTest());266 ttcObject.put("testCase", testCaseExecution.getTestCase());267 ttcObject.put("shortDesc", testCaseExecution.getDescription());268 ttcObject.put("status", testCaseExecution.getStatus());269 ttcObject.put("application", testCaseExecution.getApplication());270 boolean testExist = ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null));271 if (testExist) {272 ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());273 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());274 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());275 if ((testCaseExecution.getApplicationObj() != null) && (testCaseExecution.getApplicationObj().getBugTrackerUrl() != null) && (testCaseExecution.getTestCaseObj().getBugID() != null)) {276 ttcObject.put("bugId", new JSONObject("{\"bugId\":\"" + testCaseExecution.getTestCaseObj().getBugID() + "\",\"bugTrackerUrl\":\"" + testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID()) + "\"}"));277 } else {278 ttcObject.put("bugId", new JSONObject("{\"bugId\":\"\",\"bugTrackerUrl\":\"\"}"));279 }280 } else {281 ttcObject.put("function", "");282 ttcObject.put("priority", 0);283 ttcObject.put("comment", "");284 ttcObject.put("bugId", new JSONObject("{\"bugId\":\"\",\"bugTrackerUrl\":\"\"}"));285 }286 // Flag that report if test case still exist.287 ttcObject.put("testExist", testExist);288 // Adding nb of execution on retry.289 ttcObject.put("NbExecutionsTotal", (testCaseExecution.getNbExecutions() - 1));290 execTab.put(execKey, executionJSON);291 ttcObject.put("execTab", execTab);292 /**293 * Iterate on the label retrieved and generate HashMap294 * based on the key Test_TestCase295 */296 LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap();297 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList.getDataList()) {298 if (Label.TYPE_STICKER.equals(label.getLabel().getType())) { // We only display STICKER Type Label in Reporting By Tag Page..299 String key = label.getTest() + "_" + label.getTestcase();300 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());301 if (testCaseWithLabel.containsKey(key)) {302 testCaseWithLabel.get(key).put(jo);303 } else {304 testCaseWithLabel.put(key, new JSONArray().put(jo));305 }306 }307 }308 ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));309 }310 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);311 JSONObject column = new JSONObject();312 column.put("country", testCaseExecution.getCountry());313 column.put("environment", testCaseExecution.getEnvironment());314 column.put("robotDecli", testCaseExecution.getRobotDecli());315 columnMap.put(testCaseExecution.getRobotDecli() + "_" + testCaseExecution.getCountry() + "_" + testCaseExecution.getEnvironment(), column);316 }317 Map<String, JSONObject> treeMap = new TreeMap<String, JSONObject>(columnMap);318 testCaseExecutionTable.put("tableContent", ttc.values());319 testCaseExecutionTable.put("iTotalRecords", ttc.size());320 testCaseExecutionTable.put("iTotalDisplayRecords", ttc.size());321 testCaseExecutionTable.put("tableColumns", treeMap.values());322 } catch (JSONException ex) {323 LOG.error("Error on generateTestCaseExecutionTable : " + ex);324 } catch (Exception ex) {325 LOG.error("Error on generateTestCaseExecutionTable : " + ex);326 }327 }328 return testCaseExecutionTable;329 }330 private JSONObject generateFunctionChart(List<TestCaseExecution> testCaseExecutions, String tag, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {331 JSONObject jsonResult = new JSONObject();332 Map<String, JSONObject> axisMap = new HashMap<String, JSONObject>();333 String globalStart = "";334 String globalEnd = "";335 long globalStartL = 0;336 long globalEndL = 0;337 String globalStatus = "Finished";338 for (TestCaseExecution testCaseExecution : testCaseExecutions) {339 String key;340 JSONObject control = new JSONObject();341 JSONObject function = new JSONObject();342 String controlStatus = testCaseExecution.getControlStatus();343 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {344 if (testCaseExecution.getTestCaseObj() != null && testCaseExecution.getTestCaseObj().getFunction() != null && !"".equals(testCaseExecution.getTestCaseObj().getFunction())) {345 key = testCaseExecution.getTestCaseObj().getFunction();346 } else {347 key = testCaseExecution.getTest();348 }349 controlStatus = testCaseExecution.getControlStatus();350 control.put("value", 1);351 control.put("color", getColor(controlStatus));352 control.put("label", controlStatus);353 function.put("name", key);354 if (axisMap.containsKey(key)) {355 function = axisMap.get(key);356 if (function.has(controlStatus)) {357 int prec = function.getJSONObject(controlStatus).getInt("value");358 control.put("value", prec + 1);359 }360 }361 function.put(controlStatus, control);362 axisMap.put(key, function);363 }364 if (testCaseExecution.getStart() != 0) {365 if ((globalStartL == 0) || (globalStartL > testCaseExecution.getStart())) {366 globalStartL = testCaseExecution.getStart();367 globalStart = String.valueOf(new Date(testCaseExecution.getStart()));368 }369 }370 if (!testCaseExecution.getControlStatus().equalsIgnoreCase("PE") && testCaseExecution.getEnd() != 0) {371 if ((globalEndL == 0) || (globalEndL < testCaseExecution.getEnd())) {372 globalEndL = testCaseExecution.getEnd();373 globalEnd = String.valueOf(new Date(testCaseExecution.getEnd()));374 }375 }376 if (testCaseExecution.getControlStatus().equalsIgnoreCase("PE")) {377 globalStatus = "Pending...";378 }379 }380 Gson gson = new Gson();381 jsonResult.put("axis", axisMap.values());382 jsonResult.put("tag", tag);383 jsonResult.put("globalEnd", gson.toJson(new Timestamp(globalEndL)).replace("\"", ""));384 jsonResult.put("globalStart", globalStart);385 jsonResult.put("globalStatus", globalStatus);386 return jsonResult;387 }388 private JSONObject generateStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, boolean splitStats) throws JSONException {389 JSONObject jsonResult = new JSONObject();390 boolean env = request.getParameter("env") != null || !splitStats;391 boolean country = request.getParameter("country") != null || !splitStats;392 boolean robotDecli = request.getParameter("robotDecli") != null || !splitStats;393 boolean app = request.getParameter("app") != null || !splitStats;394 HashMap<String, SummaryStatisticsDTO> statMap = new HashMap<String, SummaryStatisticsDTO>();395 for (TestCaseExecution testCaseExecution : testCaseExecutions) {396 String controlStatus = testCaseExecution.getControlStatus();397 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {398 StringBuilder key = new StringBuilder();399 key.append((env) ? testCaseExecution.getEnvironment() : "");400 key.append("_");401 key.append((country) ? testCaseExecution.getCountry() : "");402 key.append("_");403 key.append((robotDecli) ? testCaseExecution.getRobotDecli() : "");404 key.append("_");405 key.append((app) ? testCaseExecution.getApplication() : "");406 SummaryStatisticsDTO stat = new SummaryStatisticsDTO();407 stat.setEnvironment(testCaseExecution.getEnvironment());408 stat.setCountry(testCaseExecution.getCountry());409 stat.setRobotDecli(testCaseExecution.getRobotDecli());410 stat.setApplication(testCaseExecution.getApplication());411 statMap.put(key.toString(), stat);412 }413 }414 jsonResult.put("contentTable", getStatByEnvCountryRobotDecli(testCaseExecutions, statMap, env, country, robotDecli, app, statusFilter, countryFilter, splitStats));415 return jsonResult;416 }417 private JSONObject generateBugStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {418 JSONObject jsonResult = new JSONObject();419 SummaryStatisticsBugTrackerDTO stat = new SummaryStatisticsBugTrackerDTO();420 String bugsToReport = "KO,FA";421 stat.setNbExe(1);422 int totalBugReported = 0;423 int totalBugToReport = 0;424 int totalBugToReportReported = 0;425 int totalBugToClean = 0;426 HashMap<String, SummaryStatisticsBugTrackerDTO> statMap = new HashMap<String, SummaryStatisticsBugTrackerDTO>();427 for (TestCaseExecution testCaseExecution : testCaseExecutions) {428 String controlStatus = testCaseExecution.getControlStatus();429 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {430 String key = "";431 if (bugsToReport.contains(testCaseExecution.getControlStatus())) {432 totalBugToReport++;433 }434 if ((testCaseExecution.getTestCaseObj() != null) && (!StringUtil.isNullOrEmpty(testCaseExecution.getTestCaseObj().getBugID()))) {435 key = testCaseExecution.getTestCaseObj().getBugID();436 stat = statMap.get(key);437 totalBugReported++;438 if (stat == null) {439 stat = new SummaryStatisticsBugTrackerDTO();440 stat.setNbExe(1);441 stat.setBugId(testCaseExecution.getTestCaseObj().getBugID());442 stat.setBugIdURL(testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID()));443 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());444 stat.setExeIdFirst(testCaseExecution.getId());445 stat.setExeIdLast(testCaseExecution.getId());446 stat.setTestFirst(testCaseExecution.getTest());447 stat.setTestLast(testCaseExecution.getTest());448 stat.setTestCaseFirst(testCaseExecution.getTestCase());449 stat.setTestCaseLast(testCaseExecution.getTestCase());450 } else {451 stat.setNbExe(stat.getNbExe() + 1);452 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());453 stat.setExeIdLast(testCaseExecution.getId());454 stat.setTestLast(testCaseExecution.getTest());455 stat.setTestCaseLast(testCaseExecution.getTestCase());456 }...

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.factory;2import org.cerberus.crud.entity.TestCaseExecution;3import org.cerberus.crud.service.ITestCaseExecutionService;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.stereotype.Service;6public class TestCaseExecutionFactory {7 private ITestCaseExecutionService testCaseExecutionService;8 public TestCaseExecution create(long id) {9 return testCaseExecutionService.getTestCaseExecutionById(id);10 }11}12package org.cerberus.crud.factory;13import org.cerberus.crud.entity.TestCaseExecution;14import org.cerberus.crud.service.ITestCaseExecutionService;15import org.springframework.beans.factory.annotation.Autowired;16import org.springframework.stereotype.Service;17public class TestCaseExecutionFactory {18 private ITestCaseExecutionService testCaseExecutionService;19 public TestCaseExecution create(long id) {20 return testCaseExecutionService.getTestCaseExecutionById(id);21 }22}23package org.cerberus.crud.factory;24import org.cerberus.crud.entity.TestCaseExecution;25import org.cerberus.crud.service.ITestCaseExecutionService;26import org.springframework.beans.factory.annotation.Autowired;27import org.springframework.stereotype.Service;28public class TestCaseExecutionFactory {29 private ITestCaseExecutionService testCaseExecutionService;30 public TestCaseExecution create(long id) {31 return testCaseExecutionService.getTestCaseExecutionById(id);32 }33}34package org.cerberus.crud.factory;35import org.cerberus.crud.entity.TestCaseExecution;36import org.cerberus.crud.service.ITestCaseExecutionService;37import org.springframework.beans.factory.annotation.Autowired;38import

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.List;3public class TestCaseExecution {4 private String test;5 private String testcase;6 private String country;7 private String environment;8 private String browser;9 private String version;10 private String platform;11 private String browserfullversion;12 private String browsermajor;13 private String browserminor;14 private String screenSize;15 private String robotDecli;16 private String robot;17 private String robotIP;18 private String robotPort;19 private String tag;20 private String verbose;21 private String screenshot;22 private String pageSource;23 private String seleniumLog;24 private String timeout;25 private String retries;26 private String manualExecution;27 private String myHost;28 private String myContextRoot;29 private String myLoginRelativeURL;30 private String myEnvData;31 private String seleniumIP;32 private String seleniumPort;33 private String outputFormat;34 private String controlStatus;35 private String controlMessage;36 private String start;37 private String end;38 private String state;39 private String verboseInteger;40 private String screenshotInteger;41 private String pageSourceInteger;42 private String seleniumLogInteger;43 private String timeoutInteger;44 private String retriesInteger;45 private String manualExecutionInteger;46 private String controlStatusInteger;47 private String controlMessageInteger;48 private String startInteger;49 private String endInteger;50 private String stateInteger;51 private String id;52 private String idInteger;53 private String application;54 private String applicationObj;55 private String testCaseObj;56 private String countryObj;57 private String environmentObj;58 private String browserObj;59 private String platformObj;60 private String robotObj;61 private String robotDecliObj;62 private String robotIPObj;63 private String robotPortObj;64 private String tagObj;65 private String controlStatusObj;66 private String controlMessageObj;67 private String startObj;68 private String endObj;69 private String stateObj;70 private String verboseObj;71 private String screenshotObj;72 private String pageSourceObj;73 private String seleniumLogObj;74 private String timeoutObj;75 private String retriesObj;76 private String manualExecutionObj;77 private String myHostObj;78 private String myContextRootObj;79 private String myLoginRelativeURLObj;

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.entity.TestCase;3public class 3 {4 public static void main(String[] args) {5 TestCaseExecution t = new TestCaseExecution();6 TestCase t1 = t.getTestCaseObj();7 System.out.println(t1);8 }9}10import org.cerberus.crud.entity.TestCaseExecution;11import org.cerberus.crud.entity.TestCase;12public class 4 {13 public static void main(String[] args) {14 TestCaseExecution t = new TestCaseExecution();15 TestCase t1 = new TestCase();16 t.setTestCaseObj(t1);17 System.out.println(t.getTestCaseObj());18 }19}20import org.cerberus.crud.entity.TestCaseExecution;21public class 5 {22 public static void main(String[] args) {23 TestCaseExecution t = new TestCaseExecution();24 System.out.println(t.getTag());25 }26}

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1TestCaseExecution tce = testcaseexecution.getTestCaseObj();2TestCaseExecution tce = testcaseexecution.getTestCaseObj();3TestCaseExecution tce = testcaseexecution.getTestCaseObj();4TestCaseExecution tce = testcaseexecution.getTestCaseObj();5TestCaseExecution tce = testcaseexecution.getTestCaseObj();6TestCaseExecution tce = testcaseexecution.getTestCaseObj();7TestCaseExecution tce = testcaseexecution.getTestCaseObj();

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.factory.IFactoryTestCaseExecution;3import org.cerberus.crud.service.ITestCaseExecutionService;4import org.springframework.beans.factory.annotation.Autowired;5import org.springframework.stereotype.Service;6public class TestCaseExecutionService implements ITestCaseExecutionService {7 private IFactoryTestCaseExecution factoryTestCaseExecution;

Full Screen

Full Screen

getTestCaseObj

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseExecution;2import org.cerberus.crud.entity.TestCase;3import org.cerberus.crud.entity.TestCaseList;4import org.cerberus.crud.service.ITestCaseExecutionService;5import org.cerberus.crud.service.ITestCaseListService;6import org.cerberus.crud.service.ITestCaseService;7import org.springframework.beans.factory.annotation.Autowired;8import org.springframework.stereotype.Service;9public class TestService {10 private ITestCaseExecutionService testCaseExecutionService;11 private ITestCaseListService testCaseListService;12 private ITestCaseService testCaseService;13 public void testMethod() {14 TestCaseExecution testCaseExecution = testCaseExecutionService.getTestCaseExecutionById(1);15 TestCaseList testCaseList = testCaseListService.readByKey(testCaseExecution.getTest(), testCaseExecution.getTestCase(), testCaseExecution.getEnvironment(), testCaseExecution.getCountry(), testCaseExecution.getBrowser(), testCaseExecution.getPlatform());16 TestCase testCase = testCaseService.findTestCaseByKey(testCaseList.getTest(), testCaseList.getTestCase());17 System.out.println(testCase.getDescription());18 }19}20import org.cerberus.crud.entity.TestCaseExecution;21import org.cerberus.crud.entity.TestCase;22import org.cerberus.crud.entity.TestCaseList;23import org.cerberus.crud.service.ITestCaseExecutionService;24import org.cerberus.crud.service.ITestCaseListService

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 method in TestCaseExecution

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful