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

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

Source:ReadTestCaseExecutionByTag.java Github

copy

Full Screen

...50import org.cerberus.crud.service.impl.InvariantService;51import org.cerberus.crud.service.impl.LabelService;52import org.cerberus.dto.SummaryStatisticsBugTrackerDTO;53import org.cerberus.dto.SummaryStatisticsDTO;54import org.cerberus.dto.TreeNode;55import org.cerberus.engine.entity.MessageEvent;56import org.cerberus.enums.MessageEventEnum;57import org.cerberus.exception.CerberusException;58import org.cerberus.util.ParameterParserUtil;59import org.cerberus.util.StringUtil;60import org.cerberus.util.answer.AnswerItem;61import org.cerberus.util.answer.AnswerList;62import org.cerberus.util.servlet.ServletUtil;63import org.json.JSONArray;64import org.json.JSONException;65import org.json.JSONObject;66import org.springframework.context.ApplicationContext;67import org.springframework.web.context.support.WebApplicationContextUtils;68import org.springframework.web.util.JavaScriptUtils;69/**70 *71 * @author bcivel72 */73@WebServlet(name = "ReadTestCaseExecutionByTag", urlPatterns = {"/ReadTestCaseExecutionByTag"})74public class ReadTestCaseExecutionByTag extends HttpServlet {75 private ITestCaseExecutionService testCaseExecutionService;76 private ITagService tagService;77 private ITestCaseExecutionQueueService testCaseExecutionInQueueService;78 private ITestCaseLabelService testCaseLabelService;79 private ILabelService labelService;80 private IFactoryTestCase factoryTestCase;81 private static final Logger LOG = LogManager.getLogger("ReadTestCaseExecutionByTag");82 /**83 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>84 * methods.85 *86 * @param request servlet request87 * @param response servlet response88 * @throws ServletException if a servlet-specific error occurs89 * @throws IOException if an I/O error occurs90 */91 protected void processRequest(HttpServletRequest request, HttpServletResponse response)92 throws ServletException, IOException {93 // Calling Servlet Transversal Util.94 ServletUtil.servletStart(request);95 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());96 response.setContentType("application/json");97 response.setCharacterEncoding("utf8");98 String echo = request.getParameter("sEcho");99 AnswerItem<JSONObject> answer = new AnswerItem<>(new MessageEvent(MessageEventEnum.DATA_OPERATION_OK));100 testCaseExecutionService = appContext.getBean(ITestCaseExecutionService.class);101 tagService = appContext.getBean(ITagService.class);102 factoryTestCase = appContext.getBean(IFactoryTestCase.class);103 testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);104 try {105 // Data/Filter Parameters.106 String Tag = ParameterParserUtil.parseStringParam(request.getParameter("Tag"), "");107 List<String> outputReport = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues("outputReport"), new ArrayList<>(), "UTF-8");108 boolean fullList = ParameterParserUtil.parseBooleanParam(request.getParameter("fullList"), false);109 JSONObject jsonResponse = new JSONObject();110 JSONObject statusFilter = getStatusList(request);111 JSONObject countryFilter = getCountryList(request, appContext);112 //Get Data from database113 List<TestCaseExecution> testCaseExecutions = testCaseExecutionService.readLastExecutionAndExecutionInQueueByTag(Tag);114 List<TestCaseLabel> testCaseLabelScopeList = null;115 if (outputReport.isEmpty() || outputReport.contains("labelStat") || outputReport.contains("table")) {116 String testCaseKey = "";117 HashMap<String, TestCase> ttc = new HashMap<>();118 List<TestCase> tcList = new ArrayList<>();119 for (TestCaseExecution testCaseExecution : testCaseExecutions) {120 testCaseKey = testCaseExecution.getTest() + "__" + testCaseExecution.getTestCase();121 if (ttc.get(testCaseKey) == null) {122 ttc.put(testCaseKey, factoryTestCase.create(testCaseExecution.getTest(), testCaseExecution.getTestCase()));123 tcList.add(factoryTestCase.create(testCaseExecution.getTest(), testCaseExecution.getTestCase()));124 }125 }126 testCaseLabelService = appContext.getBean(ITestCaseLabelService.class);127 AnswerList<TestCaseLabel> testCaseLabelList = testCaseLabelService.readByTestTestCase(null, null, tcList);128 testCaseLabelScopeList = testCaseLabelList.getDataList();129 }130 // Table that contain the list of testcases and corresponding executions131 if (outputReport.isEmpty() || outputReport.contains("table")) {132 jsonResponse.put("table", generateTestCaseExecutionTable(appContext, testCaseExecutions, statusFilter, countryFilter, testCaseLabelScopeList, fullList));133 }134 // Table that contain the list of testcases and corresponding executions135 if (outputReport.isEmpty() || outputReport.contains("table")) {136 jsonResponse.put("manualExecutionList", generateManualExecutionTable(appContext, testCaseExecutions, statusFilter, countryFilter));137 }138 // Executions per Function (or Test).139 if (outputReport.isEmpty() || outputReport.contains("functionChart")) {140 jsonResponse.put("functionChart", generateFunctionChart(testCaseExecutions, Tag, statusFilter, countryFilter));141 }142 // Global executions stats per Status143 if (outputReport.isEmpty() || outputReport.contains("statsChart")) {144 jsonResponse.put("statsChart", generateStats(request, testCaseExecutions, statusFilter, countryFilter, true));145 }146 // BugTracker Recap147 if (outputReport.isEmpty() || outputReport.contains("bugTrackerStat")) {148 jsonResponse.put("bugTrackerStat", generateBugStats(request, testCaseExecutions, statusFilter, countryFilter));149 }150 // Labels Stats151 if (outputReport.isEmpty() || outputReport.contains("labelStat")) {152 jsonResponse.put("labelStat", generateLabelStats(appContext, request, testCaseExecutions, statusFilter, countryFilter, testCaseLabelScopeList));153 }154 if (!outputReport.isEmpty()) {155 //currently used to optimize the homePage156 if (outputReport.contains("totalStatsCharts") && !outputReport.contains("statsChart")) {157 jsonResponse.put("statsChart", generateStats(request, testCaseExecutions, statusFilter, countryFilter, false));158 }159 //currently used to optimize the homePage160 if (outputReport.contains("resendTag")) {161 jsonResponse.put("tag", Tag);162 }163 }164 Tag mytag = tagService.convert(tagService.readByKey(Tag));165 if (mytag != null) {166 JSONObject tagJSON = convertTagToJSONObject(mytag);167 jsonResponse.put("tagObject", tagJSON);168 jsonResponse.put("tagDuration", (mytag.getDateEndQueue().getTime() - mytag.getDateCreated().getTime()) / 60000);169 }170 answer.setItem(jsonResponse);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// if (testCaseExecution.getApplicationObj() != null && testCaseExecution.getApplicationObj().getBugTrackerUrl() != null213// && !"".equals(testCaseExecution.getApplicationObj().getBugTrackerUrl()) && testCaseExecution.getTestCaseObj().getBugID() != null) {214// result.put("AppBugURL", testCaseExecution.getApplicationObj().getBugTrackerUrl());215// bugId = testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", testCaseExecution.getTestCaseObj().getBugID());216// bugId = new StringBuffer("<a href='")217// .append(bugId)218// .append("' target='reportBugID'>")219// .append(testCaseExecution.getTestCaseObj().getBugID())220// .append("</a>")221// .toString();222// }223// String comment;224// String function;225// String shortDesc;226// JSONArray bugId = new JSONArray();227// if ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null)) {228// bugId = testCaseExecution.getTestCaseObj().getBugID();229// comment = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getComment());230// function = JavaScriptUtils.javaScriptEscape(testCaseExecution.getTestCaseObj().getFunction());231// shortDesc = testCaseExecution.getTestCaseObj().getDescription();232// } else {233// comment = "";234// function = "";235// shortDesc = "";236// }237// result.put("BugID", bugId);238// result.put("Priority", JavaScriptUtils.javaScriptEscape(String.valueOf(testCaseExecution.getTestCaseObj().getPriority())));239// result.put("Comment", comment);240// result.put("Function", function);241// result.put("ShortDescription", shortDesc);242// result.put("Application", JavaScriptUtils.javaScriptEscape(testCaseExecution.getApplication()));243 List<JSONObject> testCaseDep = new ArrayList<>();244 if (testCaseExecution.getTestCaseExecutionQueueDepList() != null) {245 for (TestCaseExecutionQueueDep tce : testCaseExecution.getTestCaseExecutionQueueDepList()) {246 JSONObject obj = new JSONObject();247 obj.put("test", tce.getDepTest());248 obj.put("testcase", tce.getDepTestCase());249 testCaseDep.add(obj);250 }251 }252 result.put("TestCaseDep", testCaseDep);253 return result;254 }255 private JSONObject getStatusList(HttpServletRequest request) {256 JSONObject statusList = new JSONObject();257 try {258 statusList.put("OK", ParameterParserUtil.parseStringParam(request.getParameter("OK"), "off"));259 statusList.put("KO", ParameterParserUtil.parseStringParam(request.getParameter("KO"), "off"));260 statusList.put("NA", ParameterParserUtil.parseStringParam(request.getParameter("NA"), "off"));261 statusList.put("NE", ParameterParserUtil.parseStringParam(request.getParameter("NE"), "off"));262 statusList.put("WE", ParameterParserUtil.parseStringParam(request.getParameter("WE"), "off"));263 statusList.put("PE", ParameterParserUtil.parseStringParam(request.getParameter("PE"), "off"));264 statusList.put("FA", ParameterParserUtil.parseStringParam(request.getParameter("FA"), "off"));265 statusList.put("CA", ParameterParserUtil.parseStringParam(request.getParameter("CA"), "off"));266 statusList.put("QU", ParameterParserUtil.parseStringParam(request.getParameter("QU"), "off"));267 statusList.put("QE", ParameterParserUtil.parseStringParam(request.getParameter("QE"), "off"));268 } catch (JSONException ex) {269 LOG.error("Error on getStatusList : " + ex, ex);270 }271 return statusList;272 }273 private JSONObject getCountryList(HttpServletRequest request, ApplicationContext appContext) {274 JSONObject countryList = new JSONObject();275 try {276 IInvariantService invariantService = appContext.getBean(InvariantService.class);277 for (Invariant country : (List<Invariant>) invariantService.readByIdName("COUNTRY")) {278 countryList.put(country.getValue(), ParameterParserUtil.parseStringParam(request.getParameter(country.getValue()), "off"));279 }280 } catch (JSONException | CerberusException ex) {281 LOG.error("Error on getCountryList : " + ex, ex);282 }283 return countryList;284 }285 private JSONObject generateTestCaseExecutionTable(ApplicationContext appContext, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, List<TestCaseLabel> testCaseLabelList, boolean fullList) {286 JSONObject testCaseExecutionTable = new JSONObject();287 LinkedHashMap<String, JSONObject> ttc = new LinkedHashMap<>();288 LinkedHashMap<String, JSONObject> columnMap = new LinkedHashMap<>();289 for (TestCaseExecution testCaseExecution : testCaseExecutions) {290 try {291 String controlStatus = testCaseExecution.getControlStatus();292 // We check is Country and status is inside the fitered values.293 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {294 JSONObject executionJSON = testCaseExecutionToJSONObject(testCaseExecution);295 String execKey = testCaseExecution.getEnvironment() + " " + testCaseExecution.getCountry() + " " + testCaseExecution.getRobotDecli();296 String testCaseKey = testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase();297 JSONObject execTab = new JSONObject();298 JSONObject ttcObject = new JSONObject();299 if (ttc.containsKey(testCaseKey)) {300 // We add an execution entry into the testcase line.301 ttcObject = ttc.get(testCaseKey);302 execTab = ttcObject.getJSONObject("execTab");303 execTab.put(execKey, executionJSON);304 ttcObject.put("execTab", execTab);305 // Nb Total Executions306 Integer nbExeTot = (Integer) ttcObject.get("NbExe");307 nbExeTot += testCaseExecution.getNbExecutions();308 ttcObject.put("NbExe", nbExeTot);309 // Nb Total Executions310 Integer nbRetryTot = (Integer) ttcObject.get("NbRetry");311 nbRetryTot += testCaseExecution.getNbExecutions() - 1;312 ttcObject.put("NbRetry", nbRetryTot);313 // Nb Total Usefull Executions314 Integer nbExeUsefullTot = (Integer) ttcObject.get("NbExeUsefull");315 nbExeUsefullTot++;316 ttcObject.put("NbExeUsefull", nbExeUsefullTot);317 // Nb Total Usefull Executions in QU or OK status318 Integer nbExeTmp;319 if (isToHide(controlStatus)) {320 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullToHide");321 ttcObject.put("NbExeUsefullToHide", ++nbExeTmp);322 }323 if (isNotBug(controlStatus)) {324 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullOK");325 ttcObject.put("NbExeUsefullOK", ++nbExeTmp);326 }327 if (isBug(controlStatus)) {328 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullHasBug");329 ttcObject.put("NbExeUsefullHasBug", ++nbExeTmp);330 }331 if (isPending(controlStatus)) {332 nbExeTmp = (Integer) ttcObject.get("NbExeUsefullIsPending");333 ttcObject.put("NbExeUsefullIsPending", ++nbExeTmp);334 }335 } else {336 // We add a new testcase entry (with The current execution).337 ttcObject.put("test", testCaseExecution.getTest());338 ttcObject.put("testCase", testCaseExecution.getTestCase());339 ttcObject.put("shortDesc", testCaseExecution.getDescription());340 ttcObject.put("status", testCaseExecution.getStatus());341 ttcObject.put("application", testCaseExecution.getApplication());342 boolean testExist = ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getTest() != null));343 if (testExist) {344 ttcObject.put("function", testCaseExecution.getTestCaseObj().getFunction());345 ttcObject.put("priority", testCaseExecution.getTestCaseObj().getPriority());346 ttcObject.put("comment", testCaseExecution.getTestCaseObj().getComment());347 ttcObject.put("bugId", testCaseExecution.getTestCaseObj().getBugID());348 } else {349 ttcObject.put("function", "");350 ttcObject.put("priority", 0);351 ttcObject.put("comment", "");352 ttcObject.put("bugId", new JSONArray());353 }354 // Flag that report if test case still exist.355 ttcObject.put("testExist", testExist);356 // Adding nb of execution on retry.357 ttcObject.put("NbRetry", (testCaseExecution.getNbExecutions() - 1));358 // Adding nb of execution on retry.359 ttcObject.put("NbExe", (testCaseExecution.getNbExecutions()));360 // Nb Total Usefull Executions361 ttcObject.put("NbExeUsefull", 1);362 // Nb Total Usefull Executions in QU or OK status363 if (isToHide(controlStatus)) {364 ttcObject.put("NbExeUsefullToHide", 1);365 } else {366 ttcObject.put("NbExeUsefullToHide", 0);367 }368 // Nb Total Usefull Executions in QU or OK status369 if (isNotBug(controlStatus)) {370 ttcObject.put("NbExeUsefullOK", 1);371 } else {372 ttcObject.put("NbExeUsefullOK", 0);373 }374 // Nb Total Usefull Executions in QU or OK status375 if (isBug(controlStatus)) {376 ttcObject.put("NbExeUsefullHasBug", 1);377 } else {378 ttcObject.put("NbExeUsefullHasBug", 0);379 }380 // Nb Total Usefull Executions in QU or OK status381 if (isPending(controlStatus)) {382 ttcObject.put("NbExeUsefullIsPending", 1);383 } else {384 ttcObject.put("NbExeUsefullIsPending", 0);385 }386 execTab.put(execKey, executionJSON);387 ttcObject.put("execTab", execTab);388 /**389 * Iterate on the label retrieved and generate HashMap390 * based on the key Test_TestCase391 */392 LinkedHashMap<String, JSONArray> testCaseWithLabel = new LinkedHashMap<>();393 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList) {394 if (Label.TYPE_STICKER.equals(label.getLabel().getType())) { // We only display STICKER Type Label in Reporting By Tag Page..395 String key = label.getTest() + "_" + label.getTestcase();396 JSONObject jo = new JSONObject().put("name", label.getLabel().getLabel()).put("color", label.getLabel().getColor()).put("description", label.getLabel().getDescription());397 if (testCaseWithLabel.containsKey(key)) {398 testCaseWithLabel.get(key).put(jo);399 } else {400 testCaseWithLabel.put(key, new JSONArray().put(jo));401 }402 }403 }404 ttcObject.put("labels", testCaseWithLabel.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase()));405 }406 ttc.put(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase(), ttcObject);407 JSONObject column = new JSONObject();408 column.put("country", testCaseExecution.getCountry());409 column.put("environment", testCaseExecution.getEnvironment());410 column.put("robotDecli", testCaseExecution.getRobotDecli());411 columnMap.put(testCaseExecution.getRobotDecli() + "_" + testCaseExecution.getCountry() + "_" + testCaseExecution.getEnvironment(), column);412 }413 TreeMap<String, JSONObject> bugMap = new TreeMap<>();414 HashMap<String, Boolean> bugMapUniq = new HashMap<>();415 int nbTOCLEAN = 0;416 int nbPENDING = 0;417 int nbTOREPORT = 0;418 // building Bug Status.419 for (Map.Entry<String, JSONObject> entry : ttc.entrySet()) {420 JSONObject val = entry.getValue();421 JSONArray bugA = new JSONArray(val.getString("bugId"));422 int nbBug = bugA.length();423 if (nbBug > 0) {424 for (int i = 0; i < nbBug; i++) {425 bugMapUniq.put(bugA.getJSONObject(i).getString("id"), true);426 String key = bugA.getJSONObject(i).getString("id") + "#" + val.getString("test") + "#" + val.getString("testCase");427 if (bugMap.containsKey(key)) {428 JSONObject bugO = bugMap.get(key);429 } else {430 JSONObject bugO = new JSONObject();431 bugO.put("test", val.getString("test"));432 bugO.put("testCase", val.getString("testCase"));433 bugO.put("bug", bugA.getJSONObject(i).getString("id"));434 bugO.put("NbExeUsefullHasBug", val.getInt("NbExeUsefullHasBug"));435 bugO.put("testExist", val.getBoolean("testExist"));436 bugO.put("NbExeUsefull", val.getInt("NbExeUsefull"));437 bugO.put("NbExeUsefullIsPending", val.getInt("NbExeUsefullIsPending"));438 if (val.getInt("NbExeUsefullIsPending") > 0) {439 bugO.put("status", "STILL RUNNING...");440 nbPENDING++;441 } else {442 if (val.getInt("NbExeUsefull") == val.getInt("NbExeUsefullOK")) {443 bugO.put("status", "TO CLEAN");444 nbTOCLEAN++;445 }446 }447 bugMap.put(key, bugO);448 }449 }450 } else {451 if (val.getInt("NbExeUsefullHasBug") > 0) {452 String key = val.getString("test") + "#" + val.getString("testCase");453 JSONObject bugO = new JSONObject();454 bugO.put("test", val.getString("test"));455 bugO.put("testCase", val.getString("testCase"));456 bugO.put("bug", "");457 bugO.put("NbExeUsefullHasBug", val.getInt("NbExeUsefullHasBug"));458 bugO.put("testExist", val.getBoolean("testExist"));459 bugO.put("NbExeUsefull", val.getInt("NbExeUsefull"));460 bugO.put("NbExeUsefullIsPending", val.getInt("NbExeUsefullIsPending"));461 bugO.put("status", "TO REPORT...");462 nbTOREPORT++;463 bugMap.put(key, bugO);464 }465 }466 }467 JSONObject bugRes = new JSONObject();468 bugRes.put("bugSummary", bugMap.values());469 bugRes.put("nbTOREPORT", nbTOREPORT);470 bugRes.put("nbPENDING", nbPENDING);471 bugRes.put("nbTOCLEAN", nbTOCLEAN);472 bugRes.put("nbBugs", bugMapUniq.size());473 testCaseExecutionTable.put("bugContent", bugRes);474 // Now loading only necessary records to final structure (filtering testcase that have all usefull executions OK of QU).475 if (fullList) {476 testCaseExecutionTable.put("tableContent", ttc.values());477 testCaseExecutionTable.put("iTotalRecords", ttc.size());478 testCaseExecutionTable.put("iTotalDisplayRecords", ttc.size());479 } else {480 LinkedHashMap<String, JSONObject> newttc = new LinkedHashMap<>();481 for (Map.Entry<String, JSONObject> entry : ttc.entrySet()) {482 String key = entry.getKey();483 JSONObject val = entry.getValue();484 if ((val.getInt("NbExeUsefullToHide") != val.getInt("NbExeUsefull")) // One of the execution of the test case has a status <> QU and OK485 || (val.getJSONArray("bugId").length() > 0) // At least 1 bug has been assigned to the testcase.486 ) {487 newttc.put(key, val);488 }489 }490 testCaseExecutionTable.put("tableContent", newttc.values());491 testCaseExecutionTable.put("iTotalRecords", newttc.size());492 testCaseExecutionTable.put("iTotalDisplayRecords", newttc.size());493 }494 Map<String, JSONObject> treeMap = new TreeMap<>(columnMap);495 testCaseExecutionTable.put("tableColumns", treeMap.values());496 } catch (JSONException ex) {497 LOG.error("Error on generateTestCaseExecutionTable : " + ex, ex);498 } catch (Exception ex) {499 LOG.error("Error on generateTestCaseExecutionTable : " + ex, ex);500 }501 }502 return testCaseExecutionTable;503 }504 private boolean isToHide(String controlStatus) {505 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QU) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_OK));506 }507 private boolean isPending(String controlStatus) {508 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QU) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_PE));509 }510 private boolean isBug(String controlStatus) {511 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_FA) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_KO));512 }513 private boolean isNotBug(String controlStatus) {514 return (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_OK) || controlStatus.equals(TestCaseExecution.CONTROLSTATUS_QE));515 }516 private JSONObject generateManualExecutionTable(ApplicationContext appContext, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) {517 JSONObject manualExecutionTable = new JSONObject();518 HashMap<String, JSONObject> manualExecutions = new HashMap<>();519 int totalManualExecution = 0;520 int totalManualWEExecution = 0;521 for (TestCaseExecution testCaseExecution : testCaseExecutions) {522 try {523 String controlStatus = testCaseExecution.getControlStatus();524 boolean isManual = StringUtil.parseBoolean(testCaseExecution.getManualExecution());525 // We check is Country and status is inside the fitered values.526 if (countryFilter.get(testCaseExecution.getCountry()).equals("on")) {527 if (isManual) {528 totalManualExecution++;529 String executor = "NoExecutorDefined";530 if (!StringUtil.isNullOrEmpty(testCaseExecution.getExecutor())) {531 executor = testCaseExecution.getExecutor();532 }533 if (manualExecutions.containsKey(executor)) {534 JSONObject executorObj = manualExecutions.get(executor);535 JSONArray array = (JSONArray) executorObj.get("executionList");536 array.put(testCaseExecution.getId());537 JSONArray arrayWE = (JSONArray) executorObj.get("executionWEList");538 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {539 arrayWE.put(testCaseExecution.getId());540 }541 executorObj.put("executionList", array);542 executorObj.put("executionWEList", arrayWE);543 executorObj.put("executor", executor);544 manualExecutions.put(executor, executorObj);545 } else {546 JSONObject executorObj = new JSONObject();547 JSONArray array = new JSONArray();548 array.put(testCaseExecution.getId());549 JSONArray arrayWE = new JSONArray();550 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {551 arrayWE.put(testCaseExecution.getId());552 }553 executorObj.put("executionList", array);554 executorObj.put("executionWEList", arrayWE);555 executorObj.put("executor", executor);556 manualExecutions.put(executor, executorObj);557 }558 if (controlStatus.equals(TestCaseExecution.CONTROLSTATUS_WE)) {559 totalManualWEExecution++;560 }561 }562 }563 JSONArray array = new JSONArray();564 for (Map.Entry<String, JSONObject> entry : manualExecutions.entrySet()) {565 Object key = entry.getKey();566 JSONObject val = entry.getValue();567 array.put(val);568 }569 manualExecutionTable.put("perExecutor", array);570 manualExecutionTable.put("totalExecution", totalManualExecution);571 manualExecutionTable.put("totalWEExecution", totalManualWEExecution);572 } catch (JSONException ex) {573 LOG.error("Error on generateManualExecutionTable : " + ex, ex);574 } catch (Exception ex) {575 LOG.error("Error on generateManualExecutionTable : " + ex, ex);576 }577 }578 return manualExecutionTable;579 }580 private JSONObject generateFunctionChart(List<TestCaseExecution> testCaseExecutions, String tag, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {581 JSONObject jsonResult = new JSONObject();582 Map<String, JSONObject> axisMap = new HashMap<String, JSONObject>();583 String globalStart = "";584 String globalEnd = "";585 long globalStartL = 0;586 long globalEndL = 0;587 String globalStatus = "Finished";588 for (TestCaseExecution testCaseExecution : testCaseExecutions) {589 String key;590 JSONObject control = new JSONObject();591 JSONObject function = new JSONObject();592 String controlStatus = testCaseExecution.getControlStatus();593 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {594 if (testCaseExecution.getTestCaseObj() != null && testCaseExecution.getTestCaseObj().getFunction() != null && !"".equals(testCaseExecution.getTestCaseObj().getFunction())) {595 key = testCaseExecution.getTestCaseObj().getFunction();596 } else {597 key = testCaseExecution.getTest();598 }599 controlStatus = testCaseExecution.getControlStatus();600 control.put("value", 1);601 control.put("color", getColor(controlStatus));602 control.put("label", controlStatus);603 function.put("name", key);604 if (axisMap.containsKey(key)) {605 function = axisMap.get(key);606 if (function.has(controlStatus)) {607 int prec = function.getJSONObject(controlStatus).getInt("value");608 control.put("value", prec + 1);609 }610 }611 function.put(controlStatus, control);612 axisMap.put(key, function);613 }614 if (testCaseExecution.getStart() != 0) {615 if ((globalStartL == 0) || (globalStartL > testCaseExecution.getStart())) {616 globalStartL = testCaseExecution.getStart();617 globalStart = String.valueOf(new Date(testCaseExecution.getStart()));618 }619 }620 if (!testCaseExecution.getControlStatus().equalsIgnoreCase("PE") && testCaseExecution.getEnd() != 0) {621 if ((globalEndL == 0) || (globalEndL < testCaseExecution.getEnd())) {622 globalEndL = testCaseExecution.getEnd();623 globalEnd = String.valueOf(new Date(testCaseExecution.getEnd()));624 }625 }626 if (testCaseExecution.getControlStatus().equalsIgnoreCase("PE")) {627 globalStatus = "Pending...";628 }629 }630 Gson gson = new Gson();631 List<JSONObject> axisList = new ArrayList<>();632 for (Map.Entry<String, JSONObject> entry : axisMap.entrySet()) {633 String key = entry.getKey();634 JSONObject value = entry.getValue();635 axisList.add(value);636 }637 Collections.sort(axisList, new SortExecution());638 jsonResult.put("axis", axisList);639 jsonResult.put("tag", tag);640 jsonResult.put("globalEnd", gson.toJson(new Timestamp(globalEndL)).replace("\"", ""));641 jsonResult.put("globalStart", globalStart);642 jsonResult.put("globalStatus", globalStatus);643 return jsonResult;644 }645 class SortExecution implements Comparator<JSONObject> {646 // Used for sorting in ascending order of 647 // name value. 648 @Override649 public int compare(JSONObject a, JSONObject b) {650 if (a != null && b != null) {651 try {652 String aS = (String) a.get("name");653 String bS = (String) b.get("name");654 return aS.compareToIgnoreCase(bS);655 } catch (JSONException ex) {656 LOG.error("JSON Error Exception", ex);657 return 1;658 }659 } else {660 return 1;661 }662 }663 }664 private JSONObject generateStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, boolean splitStats) throws JSONException {665 JSONObject jsonResult = new JSONObject();666 boolean env = request.getParameter("env") != null || !splitStats;667 boolean country = request.getParameter("country") != null || !splitStats;668 boolean robotDecli = request.getParameter("robotDecli") != null || !splitStats;669 boolean app = request.getParameter("app") != null || !splitStats;670 HashMap<String, SummaryStatisticsDTO> statMap = new HashMap<String, SummaryStatisticsDTO>();671 for (TestCaseExecution testCaseExecution : testCaseExecutions) {672 String controlStatus = testCaseExecution.getControlStatus();673 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {674 StringBuilder key = new StringBuilder();675 key.append((env) ? testCaseExecution.getEnvironment() : "");676 key.append("_");677 key.append((country) ? testCaseExecution.getCountry() : "");678 key.append("_");679 key.append((robotDecli) ? testCaseExecution.getRobotDecli() : "");680 key.append("_");681 key.append((app) ? testCaseExecution.getApplication() : "");682 SummaryStatisticsDTO stat = new SummaryStatisticsDTO();683 stat.setEnvironment(testCaseExecution.getEnvironment());684 stat.setCountry(testCaseExecution.getCountry());685 stat.setRobotDecli(testCaseExecution.getRobotDecli());686 stat.setApplication(testCaseExecution.getApplication());687 statMap.put(key.toString(), stat);688 }689 }690 jsonResult.put("contentTable", getStatByEnvCountryRobotDecli(testCaseExecutions, statMap, env, country, robotDecli, app, statusFilter, countryFilter, splitStats));691 return jsonResult;692 }693 private JSONObject generateBugStats(HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter) throws JSONException {694 JSONObject jsonResult = new JSONObject();695 SummaryStatisticsBugTrackerDTO stat = new SummaryStatisticsBugTrackerDTO();696 String bugsToReport = "KO,FA";697 stat.setNbExe(1);698 int totalBugReported = 0;699 int totalBugToReport = 0;700 int totalBugToReportReported = 0;701 int totalBugToClean = 0;702 HashMap<String, SummaryStatisticsBugTrackerDTO> statMap = new HashMap<>();703 for (TestCaseExecution testCaseExecution : testCaseExecutions) {704 String controlStatus = testCaseExecution.getControlStatus();705 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {706 String key = "";707 if (bugsToReport.contains(testCaseExecution.getControlStatus())) {708 totalBugToReport++;709 }710 if ((testCaseExecution.getTestCaseObj() != null) && (testCaseExecution.getTestCaseObj().getBugID().length() > 0)) {711 JSONArray arr = testCaseExecution.getTestCaseObj().getBugID();712 for (int i = 0; i < arr.length(); i++) {713 JSONObject bug = (JSONObject) arr.get(i);714 key = bug.getString("id");715 stat = statMap.get(key);716 totalBugReported++;717 if (stat == null) {718 stat = new SummaryStatisticsBugTrackerDTO();719 stat.setNbExe(1);720 stat.setBugId(key);721 stat.setBugIdURL(testCaseExecution.getApplicationObj().getBugTrackerUrl().replace("%BUGID%", key));722 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());723 stat.setExeIdFirst(testCaseExecution.getId());724 stat.setExeIdLast(testCaseExecution.getId());725 stat.setTestFirst(testCaseExecution.getTest());726 stat.setTestLast(testCaseExecution.getTest());727 stat.setTestCaseFirst(testCaseExecution.getTestCase());728 stat.setTestCaseLast(testCaseExecution.getTestCase());729 } else {730 stat.setNbExe(stat.getNbExe() + 1);731 stat.setExeIdLastStatus(testCaseExecution.getControlStatus());732 stat.setExeIdLast(testCaseExecution.getId());733 stat.setTestLast(testCaseExecution.getTest());734 stat.setTestCaseLast(testCaseExecution.getTestCase());735 }736 if (!(bugsToReport.contains(testCaseExecution.getControlStatus()))) {737 totalBugToClean++;738 stat.setToClean(true);739 } else {740 totalBugToReportReported++;741 }742 statMap.put(key, stat);743 }744 }745 }746 }747 Gson gson = new Gson();748 JSONArray dataArray = new JSONArray();749 for (String key : statMap.keySet()) {750 SummaryStatisticsBugTrackerDTO sumStats = statMap.get(key);751 dataArray.put(new JSONObject(gson.toJson(sumStats)));752 }753 jsonResult.put("BugTrackerStat", dataArray);754 jsonResult.put("totalBugToReport", totalBugToReport);755 jsonResult.put("totalBugToReportReported", totalBugToReportReported);756 jsonResult.put("totalBugReported", totalBugReported);757 jsonResult.put("totalBugToClean", totalBugToClean);758 return jsonResult;759 }760 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 {761 SummaryStatisticsDTO total = new SummaryStatisticsDTO();762 total.setEnvironment("Total");763 for (TestCaseExecution testCaseExecution : testCaseExecutions) {764 String controlStatus = testCaseExecution.getControlStatus();765 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on") || !splitStats) {766 StringBuilder key = new StringBuilder();767 key.append((env) ? testCaseExecution.getEnvironment() : "");768 key.append("_");769 key.append((country) ? testCaseExecution.getCountry() : "");770 key.append("_");771 key.append((robotDecli) ? testCaseExecution.getRobotDecli() : "");772 key.append("_");773 key.append((app) ? testCaseExecution.getApplication() : "");774 if (statMap.containsKey(key.toString())) {775 statMap.get(key.toString()).updateStatisticByStatus(testCaseExecution.getControlStatus());776 }777 total.updateStatisticByStatus(testCaseExecution.getControlStatus());778 }779 }780 return extractSummaryData(statMap, total, splitStats);781 }782 private JSONObject extractSummaryData(HashMap<String, SummaryStatisticsDTO> summaryMap, SummaryStatisticsDTO total, boolean splitStats) throws JSONException {783 JSONObject extract = new JSONObject();784 Gson gson = new Gson();785 if (splitStats) {786 JSONArray dataArray = new JSONArray();787 //sort keys788 TreeMap<String, SummaryStatisticsDTO> sortedKeys = new TreeMap<String, SummaryStatisticsDTO>(summaryMap);789 for (String key : sortedKeys.keySet()) {790 SummaryStatisticsDTO sumStats = summaryMap.get(key);791 //percentage values792 sumStats.updatePercentageStatistics();793 dataArray.put(new JSONObject(gson.toJson(sumStats)));794 }795 extract.put("split", dataArray);796 }797 total.updatePercentageStatistics();798 extract.put("total", new JSONObject(gson.toJson(total)));799 return extract;800 }801 private String getColor(String controlStatus) {802 String color = null;803 if ("OK".equals(controlStatus)) {804 color = TestCaseExecution.CONTROLSTATUS_OK_COL;805 } else if ("KO".equals(controlStatus)) {806 color = TestCaseExecution.CONTROLSTATUS_KO_COL;807 } else if ("FA".equals(controlStatus)) {808 color = TestCaseExecution.CONTROLSTATUS_FA_COL;809 } else if ("CA".equals(controlStatus)) {810 color = TestCaseExecution.CONTROLSTATUS_CA_COL;811 } else if ("NA".equals(controlStatus)) {812 color = TestCaseExecution.CONTROLSTATUS_NA_COL;813 } else if ("NE".equals(controlStatus)) {814 color = TestCaseExecution.CONTROLSTATUS_NE_COL;815 } else if ("WE".equals(controlStatus)) {816 color = TestCaseExecution.CONTROLSTATUS_WE_COL;817 } else if ("PE".equals(controlStatus)) {818 color = TestCaseExecution.CONTROLSTATUS_PE_COL;819 } else if ("QU".equals(controlStatus)) {820 color = TestCaseExecution.CONTROLSTATUS_QU_COL;821 } else if ("QE".equals(controlStatus)) {822 color = TestCaseExecution.CONTROLSTATUS_QE_COL;823 } else {824 color = "#000000";825 }826 return color;827 }828 private JSONObject convertTagToJSONObject(Tag tag) throws JSONException {829 Gson gson = new Gson();830 JSONObject result = new JSONObject(gson.toJson(tag));831 return result;832 }833 private JSONObject generateLabelStats(ApplicationContext appContext, HttpServletRequest request, List<TestCaseExecution> testCaseExecutions, JSONObject statusFilter, JSONObject countryFilter, List<TestCaseLabel> testCaseLabelList) throws JSONException {834 JSONObject jsonResult = new JSONObject();835 labelService = appContext.getBean(LabelService.class);836 TreeNode node;837 JSONArray jsonArraySTICKER = new JSONArray();838 JSONArray jsonArrayREQUIREMENT = new JSONArray();839 AnswerList<Label> resp = labelService.readByVarious(new ArrayList<>(), new ArrayList<>(asList(Label.TYPE_STICKER, Label.TYPE_REQUIREMENT)));840 // Building Label inputlist with target layout841 if (resp.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {842 HashMap<Integer, TreeNode> inputList = new HashMap<>();843 for (Label label : (List<Label>) resp.getDataList()) {844 String text = "";845 text += "<span class='label label-primary' style='background-color:" + label.getColor() + "' data-toggle='tooltip' data-labelid='" + label.getId() + "' title='' data-original-title=''>" + label.getLabel() + "</span>";846 text += "<span style='margin-left: 5px; margin-right: 5px;' class=''>" + label.getDescription() + "</span>";847 text += "%STATUSBAR%";848 text += "%COUNTER1TEXT%";849 text += "%COUNTER1WITHCHILDTEXT%";850 text += "%NBNODESWITHCHILDTEXT%";851 // Specific pills852 //text += "<span class='badge badge-pill badge-secondary'>666</span>";853 // Standard pills854 List<String> attributList = new ArrayList<>();855 if (Label.TYPE_REQUIREMENT.equals(label.getType())) {856 if (!StringUtil.isNullOrEmpty(label.getReqType()) && !"unknown".equalsIgnoreCase(label.getReqType())) {857 attributList.add("<span class='badge badge-pill badge-secondary'>" + label.getReqType() + "</span>");858 }859 if (!StringUtil.isNullOrEmpty(label.getReqStatus()) && !"unknown".equalsIgnoreCase(label.getReqStatus())) {860 attributList.add("<span class='badge badge-pill badge-secondary'>" + label.getReqStatus() + "</span>");861 }862 if (!StringUtil.isNullOrEmpty(label.getReqCriticity()) && !"unknown".equalsIgnoreCase(label.getReqCriticity())) {863 attributList.add("<span class='badge badge-pill badge-secondary'>" + label.getReqCriticity() + "</span>");864 }865 }866 // Create Node.867 node = new TreeNode(label.getId() + "-" + label.getSystem() + "-" + label.getLabel(), label.getSystem(), label.getLabel(), label.getId(), label.getParentLabelID(), text, null, null, false);868 node.setCounter1(0);869 node.setCounter1WithChild(0);870 node.setTags(attributList);871 node.setType(label.getType());872 node.setCounter1Text("<span style='background-color:#000000' class='cnt1 badge badge-pill badge-secondary'>%COUNTER1%</span>");873 node.setCounter1WithChildText("<span class='cnt1WC badge badge-pill badge-secondary'>%COUNTER1WITHCHILD%</span>");874 node.setNbNodesText("<span style='background-color:#337ab7' class='nbNodes badge badge-pill badge-primary'>%NBNODESWITHCHILD%</span>");875 node.setLabelObj(label);876 inputList.put(node.getId(), node);877// LOG.debug("Label : " + node.getId() + " T : " + node);878 }879 HashMap<String, List<Integer>> testCaseWithLabel1 = new HashMap<>();880 for (TestCaseLabel label : (List<TestCaseLabel>) testCaseLabelList) {881// LOG.debug("TCLabel : " + label.getLabel() + " T : " + label.getTest() + " C : " + label.getTestcase() + " Type : " + label.getLabel().getType());882 if ((Label.TYPE_STICKER.equals(label.getLabel().getType()))883 || (Label.TYPE_REQUIREMENT.equals(label.getLabel().getType()))) {884 String key = label.getTest() + "_" + label.getTestcase();885 List<Integer> curLabelIdList = new ArrayList<>();886 if (testCaseWithLabel1.get(key) != null) {887 curLabelIdList = testCaseWithLabel1.get(key);888 curLabelIdList.add(label.getLabelId());889 testCaseWithLabel1.put(key, curLabelIdList);890// LOG.debug(" ADDED");891 } else {892 curLabelIdList.add(label.getLabelId());893 testCaseWithLabel1.put(key, curLabelIdList);894// LOG.debug(" ADDED");895 }896 }897 }898 /**899 * For All execution, get all labels from the test case and add if900 * those labels were in the list add the stats of executions into901 * the counters.902 */903 for (TestCaseExecution testCaseExecution : testCaseExecutions) {904// LOG.debug("Exe : " + testCaseExecution.getId() + " T : " + testCaseExecution.getTest() + " C : " + testCaseExecution.getTestCase());905 String controlStatus = testCaseExecution.getControlStatus();906 if (statusFilter.get(controlStatus).equals("on") && countryFilter.get(testCaseExecution.getCountry()).equals("on")) {907 //Get label for current test_testcase908 List<Integer> labelsForTestCase = testCaseWithLabel1.get(testCaseExecution.getTest() + "_" + testCaseExecution.getTestCase());909 if (labelsForTestCase != null) {910 for (Integer integer : labelsForTestCase) {911// LOG.debug(" T : " + testCaseExecution.getTest() + " C : " + testCaseExecution.getTestCase() + " T : " + integer);912 TreeNode curTreenode = inputList.get(integer);913 if (curTreenode != null) {914// LOG.debug(" K : " + titi.getKey() + " C : " + titi.getCounter1());915 curTreenode.setCounter1(curTreenode.getCounter1() + 1);916 curTreenode.setCounter1WithChild(curTreenode.getCounter1WithChild() + 1);917 switch (testCaseExecution.getControlStatus()) {918 case TestCaseExecution.CONTROLSTATUS_OK:919 curTreenode.setNbOK(curTreenode.getNbOK() + 1);920 break;921 case TestCaseExecution.CONTROLSTATUS_KO:922 curTreenode.setNbKO(curTreenode.getNbKO() + 1);923 break;924 case TestCaseExecution.CONTROLSTATUS_FA:925 curTreenode.setNbFA(curTreenode.getNbFA() + 1);926 break;927 case TestCaseExecution.CONTROLSTATUS_NA:928 curTreenode.setNbNA(curTreenode.getNbNA() + 1);929 break;930 case TestCaseExecution.CONTROLSTATUS_NE:931 curTreenode.setNbNE(curTreenode.getNbNE() + 1);932 break;933 case TestCaseExecution.CONTROLSTATUS_WE:934 curTreenode.setNbWE(curTreenode.getNbWE() + 1);935 break;936 case TestCaseExecution.CONTROLSTATUS_PE:937 curTreenode.setNbPE(curTreenode.getNbPE() + 1);938 break;939 case TestCaseExecution.CONTROLSTATUS_QE:940 curTreenode.setNbQE(curTreenode.getNbQE() + 1);941 break;942 case TestCaseExecution.CONTROLSTATUS_QU:943 curTreenode.setNbQU(curTreenode.getNbQU() + 1);944 break;945 case TestCaseExecution.CONTROLSTATUS_CA:946 curTreenode.setNbCA(curTreenode.getNbCA() + 1);947 break;948 }949 inputList.put(curTreenode.getId(), curTreenode);950 }951 }952 }953 }954 }955 // Build Tres.956 List<TreeNode> finalList;957 jsonArraySTICKER = new JSONArray();958 jsonArrayREQUIREMENT = new JSONArray();959 finalList = labelService.hierarchyConstructor(inputList);960 for (TreeNode treeNode : finalList) {961 if (treeNode.getCounter1WithChild() > 0) {962 if (Label.TYPE_STICKER.equals(treeNode.getType())) {963 jsonArraySTICKER.put(treeNode.toJson());964 } else {965 jsonArrayREQUIREMENT.put(treeNode.toJson());966 }967 }968 }969 }970 if ((jsonArraySTICKER.length() <= 0) && (jsonArrayREQUIREMENT.length() <= 0)) {971 return null;972 }973 jsonResult.put("labelTreeSTICKER", jsonArraySTICKER);974 jsonResult.put("labelTreeREQUIREMENT", jsonArrayREQUIREMENT);...

Full Screen

Full Screen

TreeNode

Using AI Code Generation

copy

Full Screen

1import org.cerberus.dto.TreeNode;2import org.cerberus.dto.TreeNodeFactory;3import org.cerberus.dto.TreeNodePosition;4public class TreeNodeTest {5 public static void main(String[] args) {6 TreeNode<Integer> root = new TreeNode<Integer>(1);7 TreeNode<Integer> node2 = new TreeNode<Integer>(2);8 TreeNode<Integer> node3 = new TreeNode<Integer>(3);9 TreeNode<Integer> node4 = new TreeNode<Integer>(4);10 TreeNode<Integer> node5 = new TreeNode<Integer>(5);11 TreeNode<Integer> node6 = new TreeNode<Integer>(6);12 TreeNode<Integer> node7 = new TreeNode<Integer>(7);13 TreeNode<Integer> node8 = new TreeNode<Integer>(8);14 TreeNode<Integer> node9 = new TreeNode<Integer>(9);15 TreeNode<Integer> node10 = new TreeNode<Integer>(10);16 TreeNode<Integer> node11 = new TreeNode<Integer>(11);17 TreeNode<Integer> node12 = new TreeNode<Integer>(12);18 TreeNode<Integer> node13 = new TreeNode<Integer>(13);19 TreeNode<Integer> node14 = new TreeNode<Integer>(14);20 TreeNode<Integer> node15 = new TreeNode<Integer>(15);21 TreeNode<Integer> node16 = new TreeNode<Integer>(16);22 TreeNode<Integer> node17 = new TreeNode<Integer>(17);23 TreeNode<Integer> node18 = new TreeNode<Integer>(18);24 TreeNode<Integer> node19 = new TreeNode<Integer>(19);25 TreeNode<Integer> node20 = new TreeNode<Integer>(20);26 TreeNode<Integer> node21 = new TreeNode<Integer>(21);27 TreeNode<Integer> node22 = new TreeNode<Integer>(22);28 TreeNode<Integer> node23 = new TreeNode<Integer>(23);29 TreeNode<Integer> node24 = new TreeNode<Integer>(24);30 TreeNode<Integer> node25 = new TreeNode<Integer>(25);31 TreeNode<Integer> node26 = new TreeNode<Integer>(26);32 TreeNode<Integer> node27 = new TreeNode<Integer>(27);33 TreeNode<Integer> node28 = new TreeNode<Integer>(28);34 TreeNode<Integer> node29 = new TreeNode<Integer>(29);35 TreeNode<Integer> node30 = new TreeNode<Integer>(30);36 TreeNode<Integer> node31 = new TreeNode<Integer>(31);37 TreeNode<Integer> node32 = new TreeNode<Integer>(32);38 TreeNode<Integer> node33 = new TreeNode<Integer>(33);39 TreeNode<Integer> node34 = new TreeNode<Integer>(34);

Full Screen

Full Screen

TreeNode

Using AI Code Generation

copy

Full Screen

1 public TreeNode buildTree(List<TreeNode> nodes) {2 TreeNode root = new TreeNode();3 root.setChildren(nodes);4 return root;5 }6 public TreeNode buildTree(List<TreeNode> nodes) {7 TreeNode root = new TreeNode();8 root.setChildren(nodes);9 return root;10 }11 public TreeNode buildTree(List<TreeNode> nodes) {12 TreeNode root = new TreeNode();13 root.setChildren(nodes);14 return root;15 }16 public TreeNode buildTree(List<TreeNode> nodes) {17 TreeNode root = new TreeNode();18 root.setChildren(nodes);19 return root;20 }21 public TreeNode buildTree(List<TreeNode> nodes) {22 TreeNode root = new TreeNode();23 root.setChildren(nodes);24 return root;25 }26 public TreeNode buildTree(List<TreeNode> nodes) {27 TreeNode root = new TreeNode();28 root.setChildren(nodes);29 return root;30 }31 public TreeNode buildTree(List<TreeNode> nodes) {32 TreeNode root = new TreeNode();33 root.setChildren(nodes);34 return root;35 }36 public TreeNode buildTree(List<TreeNode> nodes) {37 TreeNode root = new TreeNode();38 root.setChildren(nodes);39 return root;40 }41 public TreeNode buildTree(List<TreeNode> nodes) {42 TreeNode root = new TreeNode();43 root.setChildren(nodes);44 return root;45 }46 public TreeNode buildTree(List<TreeNode> nodes) {47 TreeNode root = new TreeNode();48 root.setChildren(nodes);49 return root;50 }51 public TreeNode buildTree(List<TreeNode> nodes) {52 TreeNode root = new TreeNode();53 root.setChildren(nodes);54 return root;

Full Screen

Full Screen

TreeNode

Using AI Code Generation

copy

Full Screen

1def root = nodes.find { it.parent == null }2def tree = root.buildTree(nodes)3tree.each { node ->4 println "Node: ${node.name}"5 node.children.each { child ->6 println "Child: ${child.name}"7 }8}

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