How to use toString method of org.cerberus.dto.TreeNode class

Best Cerberus-source code snippet using org.cerberus.dto.TreeNode.toString

Source:ReadTestCaseExecutionByTag.java Github

copy

Full Screen

...171 answer.setResultMessage(answer.getResultMessage().resolveDescription("ITEM", "Tag Statistics").resolveDescription("OPERATION", "Read"));172 jsonResponse.put("messageType", answer.getResultMessage().getMessage().getCodeString());173 jsonResponse.put("message", answer.getResultMessage().getDescription());174 jsonResponse.put("sEcho", echo);175 response.getWriter().print(jsonResponse.toString());176 } catch (ParseException ex) {177 LOG.error("Error on main call : " + ex, ex);178 } catch (CerberusException ex) {179 LOG.error("Error on main call : " + ex, ex);180 } catch (JSONException ex) {181 LOG.error("Error on main call : " + ex, ex);182 } catch (Exception ex) {183 LOG.error("Error on main call : " + ex, ex);184 }185 }186 private JSONObject testCaseExecutionToJSONObject(TestCaseExecution testCaseExecution) throws JSONException {187 JSONObject result = new JSONObject();188 result.put("ID", String.valueOf(testCaseExecution.getId()));189 result.put("QueueID", String.valueOf(testCaseExecution.getQueueID()));190 result.put("Test", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTest()));191 result.put("TestCase", JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCase()));192 result.put("Environment", JavaScriptUtils.javaScriptEscape(testCaseExecution.getEnvironment()));193 result.put("Start", testCaseExecution.getStart());194 result.put("End", testCaseExecution.getEnd());195 result.put("Country", JavaScriptUtils.javaScriptEscape(testCaseExecution.getCountry()));196 result.put("RobotDecli", JavaScriptUtils.javaScriptEscape(testCaseExecution.getRobotDecli()));197 result.put("ManualExecution", JavaScriptUtils.javaScriptEscape(testCaseExecution.getManualExecution()));198 if (testCaseExecution.getExecutor() != null) {199 result.put("Executor", JavaScriptUtils.javaScriptEscape(testCaseExecution.getExecutor()));200 }201 result.put("ControlStatus", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlStatus()));202 result.put("ControlMessage", JavaScriptUtils.javaScriptEscape(testCaseExecution.getControlMessage()));203 result.put("Status", JavaScriptUtils.javaScriptEscape(testCaseExecution.getStatus()));204 result.put("NbExecutions", String.valueOf(testCaseExecution.getNbExecutions()));205 result.put("previousExeId", testCaseExecution.getPreviousExeId());206 if (testCaseExecution.getPreviousExeStatus() != null) {207 result.put("previousExeControlStatus", JavaScriptUtils.javaScriptEscape(testCaseExecution.getPreviousExeStatus()));208 }209 if (testCaseExecution.getQueueState() != null) {210 result.put("QueueState", JavaScriptUtils.javaScriptEscape(testCaseExecution.getQueueState()));211 }212 List<JSONObject> testCaseDep = new ArrayList<>();213 if (testCaseExecution.getTestCaseExecutionQueueDepList() != null) {214 for (TestCaseExecutionQueueDep tce : testCaseExecution.getTestCaseExecutionQueueDepList()) {215 JSONObject obj = new JSONObject();216 obj.put("test", tce.getDepTest());217 obj.put("testcase", tce.getDepTestCase());218 testCaseDep.add(obj);219 }220 }221 result.put("TestCaseDep", testCaseDep);222 return result;223 }224 private JSONObject getStatusList(HttpServletRequest request) {225 JSONObject statusList = new JSONObject();226 try {227 statusList.put("OK", ParameterParserUtil.parseStringParam(request.getParameter("OK"), "off"));228 statusList.put("KO", ParameterParserUtil.parseStringParam(request.getParameter("KO"), "off"));229 statusList.put("NA", ParameterParserUtil.parseStringParam(request.getParameter("NA"), "off"));230 statusList.put("NE", ParameterParserUtil.parseStringParam(request.getParameter("NE"), "off"));231 statusList.put("WE", ParameterParserUtil.parseStringParam(request.getParameter("WE"), "off"));232 statusList.put("PE", ParameterParserUtil.parseStringParam(request.getParameter("PE"), "off"));233 statusList.put("FA", ParameterParserUtil.parseStringParam(request.getParameter("FA"), "off"));234 statusList.put("CA", ParameterParserUtil.parseStringParam(request.getParameter("CA"), "off"));235 statusList.put("QU", ParameterParserUtil.parseStringParam(request.getParameter("QU"), "off"));236 statusList.put("QE", ParameterParserUtil.parseStringParam(request.getParameter("QE"), "off"));237 } catch (JSONException ex) {238 LOG.error("Error on getStatusList : " + ex, ex);239 }240 return statusList;241 }242 private JSONObject getCountryList(HttpServletRequest request, ApplicationContext appContext) {243 JSONObject countryList = new JSONObject();244 try {245 IInvariantService invariantService = appContext.getBean(InvariantService.class);246 for (Invariant country : (List<Invariant>) invariantService.readByIdName("COUNTRY")) {247 countryList.put(country.getValue(), ParameterParserUtil.parseStringParam(request.getParameter(country.getValue()), "off"));248 }249 } catch (JSONException | CerberusException ex) {250 LOG.error("Error on getCountryList : " + ex, ex);251 }252 return countryList;253 }254 private JSONObject generateTestCaseExecutionTable(ApplicationContext appContext, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, List<TestCaseLabel> testCaseLabelList, boolean fullList) {255 JSONObject testCaseExecutionTable = new JSONObject();256 LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<>();257 LinkedHashMap<String, JSONObject> columnMap = new LinkedHashMap<>();258 for (TestCaseExecution testCaseExecution : testCaseExecutions) {259 try {260 String controlStatus = testCaseExecution.getControlStatus();261 String previousControlStatus = testCaseExecution.getPreviousExeStatus();262 // We check is Country and status is inside the fitered values.263 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {264 JSONObject executionJSON = testCaseExecutionToJSONObject(testCaseExecution);265 String execKey = testCaseExecution.getEnvironment() + " " + testCaseExecution.getCountry() + " " + testCaseExecution.getRobotDecli();266 String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();267 JSONObject execTab = new JSONObject();268 JSONObject ttcObject = new JSONObject();269 if (ttc.containsKey(testCaseKey)) {270 // We add an execution entry into the testcase line.271 ttcObject = ttc.get(testCaseKey);272 execTab = ttcObject.getJSONObject("execTab");273 execTab.put(execKey, executionJSON);274 ttcObject.put("execTab", execTab);275 // Nb Total Executions276 Integer nbExeTot = (Integer) ttcObject.get("NbExe");277 nbExeTot += testCaseExecution.getNbExecutions();278 ttcObject.put("NbExe", nbExeTot);279 // Nb Total Executions280 Integer nbRetryTot = (Integer) ttcObject.get("NbRetry");281 nbRetryTot += testCaseExecution.getNbExecutions() - 1;282 ttcObject.put("NbRetry", nbRetryTot);283 // Nb Total Usefull Executions284 Integer nbExeUsefullTot = (Integer) ttcObject.get("NbExeUsefull");285 nbExeUsefullTot++;286 ttcObject.put("NbExeUsefull", nbExeUsefullTot);287 // Nb Total Usefull Executions in QU or OK status288 Integer nbExeTmp;289 if (isToHide(controlStatus, previousControlStatus)) {290 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullToHide");291 ttcObject.put("NbExeUsefullToHide", ++nbExeTmp);292 }293 if (isNotBug(controlStatus)) {294 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullOK");295 ttcObject.put("NbExeUsefullOK", ++nbExeTmp);296 }297 if (isBug(controlStatus)) {298 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullHasBug");299 ttcObject.put("NbExeUsefullHasBug", ++nbExeTmp);300 }301 if (isPending(controlStatus)) {302 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullIsPending");303 ttcObject.put("NbExeUsefullIsPending", ++nbExeTmp);304 }305 } else {306 // We add a new testcase entry (with The current execution).307 ttcObject.put("test", testCaseExecution.getTest());308 ttcObject.put("testCase", testCaseExecution.getTestCase());309 ttcObject.put("shortDesc", testCaseExecution.getDescription());310 ttcObject.put("status", testCaseExecution.getStatus());311 ttcObject.put("application", testCaseExecution.getApplication());312 if (testCaseExecution.getApplicationObj() != null && testCaseExecution.getApplicationObj().getBugTrackerUrl() != null313 && !"".equals(testCaseExecution.getApplicationObj().getBugTrackerUrl()) && testCaseExecution.getTestCaseObj().getBugs() != null) {314 ttcObject.put("AppBugURL", testCaseExecution.getApplicationObj().getBugTrackerUrl());315 }316 boolean testExist = ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null));317 if (testExist) {318 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());319 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());320 ttcObject.put("bugs", testCaseExecution.getTestCaseObj().getBugsActive());321 } else {322 ttcObject.put("function", "");323 ttcObject.put("priority", 0);324 ttcObject.put("comment", "");325 ttcObject.put("bugs", new JSONArray());326 }327 // Flag that report if test case still exist.328 ttcObject.put("testExist", testExist);329 // Adding nb of execution on retry.330 ttcObject.put("NbRetry", (testCaseExecution.getNbExecutions() - 1));331 // Adding nb of execution on retry.332 ttcObject.put("NbExe", (testCaseExecution.getNbExecutions()));333 // Nb Total Usefull Executions334 ttcObject.put("NbExeUsefull", 1);335 // Nb Total Usefull Executions in QU or OK status336 if (isToHide(controlStatus, previousControlStatus)) {337 ttcObject.put("NbExeUsefullToHide", 1);338 } else {339 ttcObject.put("NbExeUsefullToHide", 0);340 }341 // Nb Total Usefull Executions in QU or OK status342 if (isNotBug(controlStatus)) {343 ttcObject.put("NbExeUsefullOK", 1);344 } else {345 ttcObject.put("NbExeUsefullOK", 0);346 }347 // Nb Total Usefull Executions in QU or OK status348 if (isBug(controlStatus)) {349 ttcObject.put("NbExeUsefullHasBug", 1);350 } else {351 ttcObject.put("NbExeUsefullHasBug", 0);352 }353 // Nb Total Usefull Executions in QU or OK status354 if (isPending(controlStatus)) {355 ttcObject.put("NbExeUsefullIsPending", 1);356 } else {357 ttcObject.put("NbExeUsefullIsPending", 0);358 }359 execTab.put(execKey, executionJSON);360 ttcObject.put("execTab", execTab);361 /**362 * Iterate on the label retrieved and generate HashMap363 * based on the key Test_TestCase364 */365 LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap<>();366 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList) {367 if (Label.TYPE_STICKER.equals(label.getLabel().getType())) { // We only display STICKER Type Label in Reporting By Tag Page..368 String key = label.getTest() + "_" + label.getTestcase();369 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());370 if (testCaseWithLabel.containsKey(key)) {371 testCaseWithLabel.get(key).put(jo);372 } else {373 testCaseWithLabel.put(key, new JSONArray().put(jo));374 }375 }376 }377 ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));378 }379 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);380 JSONObject column = new JSONObject();381 column.put("country", testCaseExecution.getCountry());382 column.put("environment", testCaseExecution.getEnvironment());383 column.put("robotDecli", testCaseExecution.getRobotDecli());384 columnMap.put(testCaseExecution.getRobotDecli() + "_" + testCaseExecution.getCountry() + "_" + testCaseExecution.getEnvironment(), column);385 }386 TreeMap<String, JSONObject> bugMap = new TreeMap<>();387 HashMap<String, Boolean> bugMapUniq = new HashMap<>();388 int nbTOCLEAN = 0;389 int nbPENDING = 0;390 int nbTOREPORT = 0;391 // building Bug Status.392 for (Map.Entry<String, JSONObject> entry : ttc.entrySet()) {393 JSONObject val = entry.getValue();394 JSONArray bugA = new JSONArray(val.getString("bugs"));395 int nbBug = bugA.length();396 if (nbBug > 0) {397 for (int i = 0; i < nbBug; i++) {398 bugMapUniq.put(bugA.getJSONObject(i).getString("id"), true);399 String key = bugA.getJSONObject(i).getString("id") + "#" + val.getString("test") + "#" + val.getString("testCase");400 if (bugMap.containsKey(key)) {401 JSONObject bugO = bugMap.get(key);402 } else {403 JSONObject bugO = new JSONObject();404 bugO.put("test", val.getString("test"));405 bugO.put("testCase", val.getString("testCase"));406 bugO.put("bug", bugA.getJSONObject(i).getString("id"));407 bugO.put("NbExeUsefullHasBug", val.getInt("NbExeUsefullHasBug"));408 bugO.put("testExist", val.getBoolean("testExist"));409 bugO.put("NbExeUsefull", val.getInt("NbExeUsefull"));410 bugO.put("NbExeUsefullIsPending", val.getInt("NbExeUsefullIsPending"));411 if (val.getInt("NbExeUsefullIsPending") > 0) {412 bugO.put("status", "STILL RUNNING...");413 nbPENDING++;414 } else {415 if (val.getInt("NbExeUsefull") == val.getInt("NbExeUsefullOK")) {416 bugO.put("status", "TO CLEAN");417 nbTOCLEAN++;418 }419 }420 bugMap.put(key, bugO);421 }422 }423 } else {424 if (val.getInt("NbExeUsefullHasBug") > 0) {425 String key = val.getString("test") + "#" + val.getString("testCase");426 JSONObject bugO = new JSONObject();427 bugO.put("test", val.getString("test"));428 bugO.put("testCase", val.getString("testCase"));429 bugO.put("bug", "");430 bugO.put("NbExeUsefullHasBug", val.getInt("NbExeUsefullHasBug"));431 bugO.put("testExist", val.getBoolean("testExist"));432 bugO.put("NbExeUsefull", val.getInt("NbExeUsefull"));433 bugO.put("NbExeUsefullIsPending", val.getInt("NbExeUsefullIsPending"));434 bugO.put("status", "TO REPORT...");435 nbTOREPORT++;436 bugMap.put(key, bugO);437 }438 }439 }440 JSONObject bugRes = new JSONObject();441 bugRes.put("bugSummary", bugMap.values());442 bugRes.put("nbTOREPORT", nbTOREPORT);443 bugRes.put("nbPENDING", nbPENDING);444 bugRes.put("nbTOCLEAN", nbTOCLEAN);445 bugRes.put("nbBugs", bugMapUniq.size());446 testCaseExecutionTable.put("bugContent", bugRes);447 // Now loading only necessary records to final structure (filtering testcase that have all usefull executions OK of QU).448 if (fullList) {449 testCaseExecutionTable.put("tableContent", ttc.values());450 testCaseExecutionTable.put("iTotalRecords", ttc.size());451 testCaseExecutionTable.put("iTotalDisplayRecords", ttc.size());452 } else {453 LinkedHashMap<String, JSONObject> newttc = new LinkedHashMap<>();454 for (Map.Entry<String, JSONObject> entry : ttc.entrySet()) {455 String key = entry.getKey();456 JSONObject val = entry.getValue();457 if ((val.getInt("NbExeUsefullToHide") != val.getInt("NbExeUsefull")) // One of the execution of the test case has a status <> QU and OK458 || (val.getJSONArray("bugs").length() > 0) // At least 1 bug has been assigned to the testcase.459 ) {460 newttc.put(key, val);461 }462 }463 testCaseExecutionTable.put("tableContent", newttc.values());464 testCaseExecutionTable.put("iTotalRecords", newttc.size());465 testCaseExecutionTable.put("iTotalDisplayRecords", newttc.size());466 }467 Map<String, JSONObject> treeMap = new TreeMap<>(columnMap);468 testCaseExecutionTable.put("tableColumns", treeMap.values());469 } catch (JSONException ex) {470 LOG.error("Error on generateTestCaseExecutionTable : " + ex, ex);471 } catch (Exception ex) {472 LOG.error("Error on generateTestCaseExecutionTable : " + ex, ex);473 }474 }475 return testCaseExecutionTable;476 }477 // We hide is status is QU of OK and there were no previous execution.478 private boolean isToHide(String controlStatus, String previousControlStatus) {479 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QU) && (StringUtil.isNullOrEmpty(previousControlStatus))480 || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_OK));481 }482 private boolean isPending(String controlStatus) {483 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QU) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_PE));484 }485 private boolean isBug(String controlStatus) {486 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_FA) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_KO));487 }488 private boolean isNotBug(String controlStatus) {489 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_OK) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QE));490 }491 private JSONObject generateManualExecutionTable(ApplicationContext appContext, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) {492 JSONObject manualExecutionTable = new JSONObject();493 HashMap<String, JSONObject> manualExecutions = new HashMap<>();494 int totalManualExecution = 0;495 int totalManualWEExecution = 0;496 for (TestCaseExecution testCaseExecution : testCaseExecutions) {497 try {498 String controlStatus = testCaseExecution.getControlStatus();499 boolean isManual = StringUtil.parseBoolean(testCaseExecution.getManualExecution());500 // We check is Country and status is inside the fitered values.501 if (countryFilter.get(testCaseExecution.getCountry()).equals("on")) {502 if (isManual) {503 totalManualExecution++;504 String executor = "NoExecutorDefined";505 if (!StringUtil.isNullOrEmpty(testCaseExecution.getExecutor())) {506 executor = testCaseExecution.getExecutor();507 }508 if (manualExecutions.containsKey(executor)) {509 JSONObject executorObj = manualExecutions.get(executor);510 JSONArray array = (JSONArray) executorObj.get("executionList");511 array.put(testCaseExecution.getId());512 JSONArray arrayWE = (JSONArray) executorObj.get("executionWEList");513 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {514 arrayWE.put(testCaseExecution.getId());515 }516 executorObj.put("executionList", array);517 executorObj.put("executionWEList", arrayWE);518 executorObj.put("executor", executor);519 manualExecutions.put(executor, executorObj);520 } else {521 JSONObject executorObj = new JSONObject();522 JSONArray array = new JSONArray();523 array.put(testCaseExecution.getId());524 JSONArray arrayWE = new JSONArray();525 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {526 arrayWE.put(testCaseExecution.getId());527 }528 executorObj.put("executionList", array);529 executorObj.put("executionWEList", arrayWE);530 executorObj.put("executor", executor);531 manualExecutions.put(executor, executorObj);532 }533 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {534 totalManualWEExecution++;535 }536 }537 }538 JSONArray array = new JSONArray();539 for (Map.Entry<String, JSONObject> entry : manualExecutions.entrySet()) {540 Object key = entry.getKey();541 JSONObject val = entry.getValue();542 array.put(val);543 }544 manualExecutionTable.put("perExecutor", array);545 manualExecutionTable.put("totalExecution", totalManualExecution);546 manualExecutionTable.put("totalWEExecution", totalManualWEExecution);547 } catch (JSONException ex) {548 LOG.error("Error on generateManualExecutionTable : " + ex, ex);549 } catch (Exception ex) {550 LOG.error("Error on generateManualExecutionTable : " + ex, ex);551 }552 }553 return manualExecutionTable;554 }555 private JSONObject generateTestFolderChart(List<TestCaseExecution> testCaseExecutions, String tag, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {556 JSONObject jsonResult = new JSONObject();557 Map<String, JSONObject> axisMap = new HashMap<String, JSONObject>();558 String globalStart = "";559 String globalEnd = "";560 long globalStartL = 0;561 long globalEndL = 0;562 String globalStatus = "Finished";563 for (TestCaseExecution testCaseExecution : testCaseExecutions) {564 String key;565 JSONObject control = new JSONObject();566 JSONObject function = new JSONObject();567 String controlStatus = testCaseExecution.getControlStatus();568 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {569 key = testCaseExecution.getTest();570 controlStatus = testCaseExecution.getControlStatus();571 control.put("value", 1);572 control.put("color", getColor(controlStatus));573 control.put("label", controlStatus);574 function.put("name", key);575 if (axisMap.containsKey(key)) {576 function = axisMap.get(key);577 if (function.has(controlStatus)) {578 int prec = function.getJSONObject(controlStatus).getInt("value");579 control.put("value", prec + 1);580 }581 }582 function.put(controlStatus, control);583 axisMap.put(key, function);584 }585 if (testCaseExecution.getStart() != 0) {586 if ((globalStartL == 0) || (globalStartL > testCaseExecution.getStart())) {587 globalStartL = testCaseExecution.getStart();588 globalStart = String.valueOf(new Date(testCaseExecution.getStart()));589 }590 }591 if (!testCaseExecution.getControlStatus().equalsIgnoreCase("PE") && testCaseExecution.getEnd() != 0) {592 if ((globalEndL == 0) || (globalEndL < testCaseExecution.getEnd())) {593 globalEndL = testCaseExecution.getEnd();594 globalEnd = String.valueOf(new Date(testCaseExecution.getEnd()));595 }596 }597 if (testCaseExecution.getControlStatus().equalsIgnoreCase("PE")) {598 globalStatus = "Pending...";599 }600 }601 Gson gson = new Gson();602 List<JSONObject> axisList = new ArrayList<>();603 for (Map.Entry<String, JSONObject> entry : axisMap.entrySet()) {604 String key = entry.getKey();605 JSONObject value = entry.getValue();606 axisList.add(value);607 }608 Collections.sort(axisList, new SortExecution());609 jsonResult.put("axis", axisList);610 jsonResult.put("tag", tag);611 jsonResult.put("globalEnd", gson.toJson(new Timestamp(globalEndL)).replace("\"", ""));612 jsonResult.put("globalStart", globalStart);613 jsonResult.put("globalStatus", globalStatus);614 return jsonResult;615 }616 class SortExecution implements Comparator<JSONObject> {617 // Used for sorting in ascending order of618 // name value.619 @Override620 public int compare(JSONObject a, JSONObject b) {621 if (a != null && b != null) {622 try {623 String aS = (String) a.get("name");624 String bS = (String) b.get("name");625 return aS.compareToIgnoreCase(bS);626 } catch (JSONException ex) {627 LOG.error("JSON Error Exception", ex);628 return 1;629 }630 } else {631 return 1;632 }633 }634 }635 private JSONObject generateStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, boolean splitStats) throws JSONException {636 JSONObject jsonResult = new JSONObject();637 boolean env = request.getParameter("env") != null || !splitStats;638 boolean country = request.getParameter("country") != null || !splitStats;639 boolean robotDecli = request.getParameter("robotDecli") != null || !splitStats;640 boolean app = request.getParameter("app") != null || !splitStats;641 HashMap<String, SummaryStatisticsDTO> statMap = new HashMap<String, SummaryStatisticsDTO>();642 for (TestCaseExecution testCaseExecution : testCaseExecutions) {643 String controlStatus = testCaseExecution.getControlStatus();644 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {645 StringBuilder key = new StringBuilder();646 key.append((env) ? testCaseExecution.getEnvironment() : "");647 key.append("_");648 key.append((country) ? testCaseExecution.getCountry() : "");649 key.append("_");650 key.append((robotDecli) ? testCaseExecution.getRobotDecli() : "");651 key.append("_");652 key.append((app) ? testCaseExecution.getApplication() : "");653 SummaryStatisticsDTO stat = new SummaryStatisticsDTO();654 stat.setEnvironment(testCaseExecution.getEnvironment());655 stat.setCountry(testCaseExecution.getCountry());656 stat.setRobotDecli(testCaseExecution.getRobotDecli());657 stat.setApplication(testCaseExecution.getApplication());658 statMap.put(key.toString(), stat);659 }660 }661 jsonResult.put("contentTable", getStatByEnvCountryRobotDecli(testCaseExecutions, statMap, env, country, robotDecli, app, statusFilter, countryFilter, splitStats));662 return jsonResult;663 }664 private JSONObject generateBugStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {665 JSONObject jsonResult = new JSONObject();666 SummaryStatisticsBugTrackerDTO stat = new SummaryStatisticsBugTrackerDTO();667 String bugsToReport = "KO,FA";668 stat.setNbExe(1);669 int totalBugReported = 0;670 int totalBugToReport = 0;671 int totalBugToReportReported = 0;672 int totalBugToClean = 0;673 HashMap<String, SummaryStatisticsBugTrackerDTO> statMap = new HashMap<>();674 for (TestCaseExecution testCaseExecution : testCaseExecutions) {675 String controlStatus = testCaseExecution.getControlStatus();676 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {677 String key = "";678 if (bugsToReport.contains(testCaseExecution.getControlStatus())) {679 totalBugToReport++;680 }681 if ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getBugs().length() > 0)) {682 JSONArray arr = testCaseExecution.getTestCaseObj().getBugs();683 for (int i = 0; i < arr.length(); i++) {684 JSONObject bug = (JSONObject) arr.get(i);685 key = bug.getString("id");686 stat = statMap.get(key);687 totalBugReported++;688 if (stat == null) {689 stat = new SummaryStatisticsBugTrackerDTO();690 stat.setNbExe(1);691 stat.setBugId(key);692 stat.setBugIdURL(testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", key));693 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());694 stat.setExeIdFirst(testCaseExecution.getId());695 stat.setExeIdLast(testCaseExecution.getId());696 stat.setTestFirst(testCaseExecution.getTest());697 stat.setTestLast(testCaseExecution.getTest());698 stat.setTestCaseFirst(testCaseExecution.getTestCase());699 stat.setTestCaseLast(testCaseExecution.getTestCase());700 } else {701 stat.setNbExe(stat.getNbExe() + 1);702 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());703 stat.setExeIdLast(testCaseExecution.getId());704 stat.setTestLast(testCaseExecution.getTest());705 stat.setTestCaseLast(testCaseExecution.getTestCase());706 }707 if (!(bugsToReport.contains(testCaseExecution.getControlStatus()))) {708 totalBugToClean++;709 stat.setToClean(true);710 } else {711 totalBugToReportReported++;712 }713 statMap.put(key, stat);714 }715 }716 }717 }718 Gson gson = new Gson();719 JSONArray dataArray = new JSONArray();720 for (String key : statMap.keySet()) {721 SummaryStatisticsBugTrackerDTO sumStats = statMap.get(key);722 dataArray.put(new JSONObject(gson.toJson(sumStats)));723 }724 jsonResult.put("BugTrackerStat", dataArray);725 jsonResult.put("totalBugToReport", totalBugToReport);726 jsonResult.put("totalBugToReportReported", totalBugToReportReported);727 jsonResult.put("totalBugReported", totalBugReported);728 jsonResult.put("totalBugToClean", totalBugToClean);729 return jsonResult;730 }731 private JSONObject getStatByEnvCountryRobotDecli(List<TestCaseExecution> testCaseExecutions, HashMap<String, SummaryStatisticsDTO> statMap, boolean env, boolean country, boolean robotDecli, boolean app, JSONObject statusFilter, JSONObject countryFilter, boolean splitStats) throws JSONException {732 SummaryStatisticsDTO total = new SummaryStatisticsDTO();733 total.setEnvironment("Total");734 for (TestCaseExecution testCaseExecution : testCaseExecutions) {735 String controlStatus = testCaseExecution.getControlStatus();736 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on") || !splitStats) {737 StringBuilder key = new StringBuilder();738 key.append((env) ? testCaseExecution.getEnvironment() : "");739 key.append("_");740 key.append((country) ? testCaseExecution.getCountry() : "");741 key.append("_");742 key.append((robotDecli) ? testCaseExecution.getRobotDecli() : "");743 key.append("_");744 key.append((app) ? testCaseExecution.getApplication() : "");745 if (statMap.containsKey(key.toString())) {746 statMap.get(key.toString()).updateStatisticByStatus(testCaseExecution.getControlStatus());747 }748 total.updateStatisticByStatus(testCaseExecution.getControlStatus());749 }750 }751 return extractSummaryData(statMap, total, splitStats);752 }753 private JSONObject extractSummaryData(HashMap<String, SummaryStatisticsDTO> summaryMap, SummaryStatisticsDTO total, boolean splitStats) throws JSONException {754 JSONObject extract = new JSONObject();755 Gson gson = new Gson();756 if (splitStats) {757 JSONArray dataArray = new JSONArray();758 //sort keys759 TreeMap<String, SummaryStatisticsDTO> sortedKeys = new TreeMap<String, SummaryStatisticsDTO>(summaryMap);760 for (String key : sortedKeys.keySet()) {...

Full Screen

Full Screen

toString

Using AI Code Generation

copy

Full Screen

1TreeNode node = new TreeNode("root");2node.addChild(new TreeNode("child1"));3node.addChild(new TreeNode("child2"));4node.addChild(new TreeNode("child3"));5node.addChild(new TreeNode("child4"));6node.addChild(new TreeNode("child5"));7node.addChild(new TreeNode("child6"));8node.addChild(new TreeNode("child7"));9node.addChild(new TreeNode("child8"));10node.addChild(new TreeNode("child9"));11node.addChild(new TreeNode("child10"));12node.addChild(new TreeNode("child11"));13node.addChild(new TreeNode("child12"));14node.addChild(new TreeNode("child13"));15node.addChild(new TreeNode("child14"));16node.addChild(new TreeNode("child15"));17node.addChild(new TreeNode("child16"));18node.addChild(new TreeNode("child17"));19node.addChild(new TreeNode("child18"));20node.addChild(new TreeNode("child19"));21node.addChild(new TreeNode("child20"));22node.addChild(new TreeNode("child21"));23node.addChild(new TreeNode("child22"));24node.addChild(new TreeNode("child23"));25node.addChild(new TreeNode("child24"));26node.addChild(new TreeNode("child25"));27node.addChild(new TreeNode("child26"));28node.addChild(new TreeNode("child27"));29node.addChild(new TreeNode("child28"));30node.addChild(new TreeNode("child29"));31node.addChild(new TreeNode("child30"));32node.addChild(new TreeNode("child31"));33node.addChild(new TreeNode("child32"));34node.addChild(new TreeNode("child33"));35node.addChild(new TreeNode("child34"));36node.addChild(new TreeNode("child35"));37node.addChild(new TreeNode("child36"));38node.addChild(new TreeNode("child37"));39node.addChild(new TreeNode("child38"));40node.addChild(new TreeNode("child39"));41node.addChild(new TreeNode("child40"));42node.addChild(new TreeNode("child41"));43node.addChild(new TreeNode("child42"));44node.addChild(new TreeNode("child43"));45node.addChild(new TreeNode("child44"));46node.addChild(new TreeNode("child45"));47node.addChild(new TreeNode("child46"));48node.addChild(new TreeNode("child47"));49node.addChild(new TreeNode("child48"));50node.addChild(new TreeNode("child49"));51node.addChild(new TreeNode("child50"));52node.addChild(new TreeNode("child51"));53node.addChild(new TreeNode("child52"));54node.addChild(new TreeNode("child53"));55node.addChild(new TreeNode("child54"));56node.addChild(new TreeNode("child55"));57node.addChild(new TreeNode("child56"));58node.addChild(new TreeNode("child57"));59node.addChild(new TreeNode("child58"));60node.addChild(new TreeNode("child59"));61node.addChild(new TreeNode("child60"));62node.addChild(new TreeNode("child61"));

Full Screen

Full Screen

toString

Using AI Code Generation

copy

Full Screen

1var node = new org.cerberus.dto.TreeNode("root");2node.add(new org.cerberus.dto.TreeNode("child1"));3node.add(new org.cerberus.dto.TreeNode("child2"));4node.add(new org.cerberus.dto.TreeNode("child3"));5node.toString();6var node = new org.cerberus.dto.TreeNode("root");7node.add(new org.cerberus.dto.TreeNode("child1"));8node.add(new org.cerberus.dto.TreeNode("child2"));9node.add(new org.cerberus.dto.TreeNode("child3"));10node.toString();11var node = new org.cerberus.dto.TreeNode("root");12node.add(new org.cerberus.dto.TreeNode("child1"));13node.add(new org.cerberus.dto.TreeNode("child2"));14node.add(new org.cerberus.dto.TreeNode("child3"));15node.toString();16var node = new org.cerberus.dto.TreeNode("root");17node.add(new org.cerberus.dto.TreeNode("child1"));18node.add(new org.cerberus.dto.TreeNode("child2"));19node.add(new org.cerberus.dto.TreeNode("child3"));20node.toString();21var node = new org.cerberus.dto.TreeNode("root");22node.add(new org.cerberus.dto.TreeNode("child1"));23node.add(new org.cerberus.dto.TreeNode("child2"));24node.add(new org.cerberus.dto.TreeNode("child3"));25node.toString();26var node = new org.cerberus.dto.TreeNode("root");27node.add(new org.cerberus.dto.TreeNode("child1"));28node.add(new org.cerberus.dto.TreeNode("child2"));29node.add(new org.cerberus.dto.TreeNode("child3"));30node.toString();31var node = new org.cerberus.dto.TreeNode("root");32node.add(new

Full Screen

Full Screen

toString

Using AI Code Generation

copy

Full Screen

1TreeNode t = new TreeNode();2t.setNode("Hello");3t.setChildren(new ArrayList<TreeNode>());4t.getChildren().add(new TreeNode("World"));5t.getChildren().add(new TreeNode("World2"));6t.getChildren().add(new TreeNode("World3"));7System.out.println(t.toString());8TreeNode t = new TreeNode();9t.setNode("Hello");10t.setChildren(new ArrayList<TreeNode>());11t.getChildren().add(new TreeNode("World"));12t.getChildren().add(new TreeNode("World2"));13t.getChildren().add(new TreeNode("World3"));14System.out.println(t.toString(true));15TreeNode t = new TreeNode();16t.setNode("Hello");17t.setChildren(new ArrayList<TreeNode>());18t.getChildren().add(new TreeNode("World"));19t.getChildren().add(new TreeNode("World2"));20t.getChildren().add(new TreeNode("World3"));21System.out.println(t.toString(false));22TreeNode t = new TreeNode();23t.setNode("Hello");24t.setChildren(new ArrayList<TreeNode>());25t.getChildren().add(new TreeNode("World"));26t.getChildren().add(new TreeNode("World2"));27t.getChildren().add(new TreeNode("World3"));28System.out.println(t.toString(1));29TreeNode t = new TreeNode();30t.setNode("Hello");31t.setChildren(new ArrayList<TreeNode>());32t.getChildren().add(new TreeNode("World"));33t.getChildren().add(new TreeNode("World2"));34t.getChildren().add(new

Full Screen

Full Screen

toString

Using AI Code Generation

copy

Full Screen

1import org.cerberus.dto.TreeNode;2public class TreeToString {3 public static void main(String[] args) {4 TreeNode root = new TreeNode(1);5 root.add(new TreeNode(2));6 root.add(new TreeNode(3));7 root.add(new TreeNode(4));8 root.add(new TreeNode(5));9 root.add(new TreeNode(6));10 root.add(new TreeNode(7));11 root.add(new TreeNode(8));12 root.add(new TreeNode(9));13 root.add(new TreeNode(10));14 root.add(new TreeNode(11));15 root.add(new TreeNode(12));16 root.add(new TreeNode(13));17 root.add(new TreeNode(14));18 root.add(new TreeNode(15));19 root.add(new TreeNode(16));20 root.add(new TreeNode(17));21 root.add(new TreeNode(18));22 root.add(new TreeNode(19));23 root.add(new TreeNode(20));24 root.add(new TreeNode(21));25 root.add(new TreeNode(22));26 root.add(new TreeNode(23));27 root.add(new TreeNode(24));28 root.add(new TreeNode(25));29 root.add(new TreeNode(26));30 root.add(new TreeNode(27));31 root.add(new TreeNode(28));32 root.add(new TreeNode(29));33 root.add(new TreeNode(30));34 root.add(new TreeNode(31));35 root.add(new TreeNode(32));36 root.add(new TreeNode(33));37 root.add(new TreeNode(34));38 root.add(new TreeNode(35));39 root.add(new TreeNode(36));40 root.add(new TreeNode(37));41 root.add(new TreeNode(38));42 root.add(new TreeNode(39));43 root.add(new TreeNode(40));44 root.add(new TreeNode(41));45 root.add(new TreeNode(42));46 root.add(new TreeNode(43));47 root.add(new TreeNode(44));48 root.add(new TreeNode(45));49 root.add(new TreeNode(46));50 root.add(new TreeNode(47));51 root.add(new TreeNode(48));52 root.add(new TreeNode(49));53 root.add(new TreeNode(50));54 root.add(new TreeNode(51));55 root.add(new TreeNode(52));56 root.add(new TreeNode(53));57 root.add(new TreeNode(54));58 root.add(new TreeNode(55));59 root.add(new

Full Screen

Full Screen

toString

Using AI Code Generation

copy

Full Screen

1import org.cerberus.dto.TreeNode;2TreeNode root = new TreeNode("root");3root.addChild("child1");4root.addChild("child2");5root.addChild("child3");6root.getChild("child2").addChild("child2.1");7root.getChild("child2").addChild("child2.2");8root.getChild("child2").addChild("child2.3");9root.getChild("child3").addChild("child3.1");10root.getChild("child3").addChild("child3.2");11root.getChild("child3").addChild("child3.3");12System.out.println(root.toString());

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful