How to use SummaryStatisticsDTO class of org.cerberus.dto package

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

Source:GetReportData.java Github

copy

Full Screen

...39import org.cerberus.crud.entity.TestCaseExecution;40import org.cerberus.crud.entity.TestCaseExecutionQueue;41import org.cerberus.exception.CerberusException;42import org.cerberus.crud.service.ITestCaseExecutionService;43import org.cerberus.dto.SummaryStatisticsDTO;44import org.cerberus.util.ParameterParserUtil;45import org.cerberus.util.answer.AnswerList;46import org.json.JSONArray;47import org.json.JSONException;48import org.json.JSONObject;49import org.springframework.context.ApplicationContext;50import org.springframework.web.context.support.WebApplicationContextUtils;51import org.cerberus.crud.service.ITestCaseExecutionQueueService;52/**53 *54 * @author cerberus55 */56@WebServlet(name = "GetReportData", urlPatterns = {"/GetReportData"})57public class GetReportData extends HttpServlet {58 59 private static final Logger LOG = LogManager.getLogger(GetReportData.class);60 ITestCaseExecutionService testCaseExecutionService;61 ITestCaseExecutionQueueService testCaseExecutionInQueueService;62 /**63 * Processes requests for both HTTP <code>GET</code> and <code>POST</code>64 * methods.65 *66 * @param request servlet request67 * @param response servlet response68 * @throws ServletException if a servlet-specific error occurs69 * @throws IOException if an I/O error occurs70 */71 protected void processRequest(HttpServletRequest request, HttpServletResponse response)72 throws ServletException, IOException, CerberusException, ParseException, JSONException {73 response.setContentType("text/html;charset=UTF-8");74 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());75 testCaseExecutionService = appContext.getBean(ITestCaseExecutionService.class);76 testCaseExecutionInQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);77 response.setContentType("application/json");78 response.setCharacterEncoding("utf8");79 JSONObject jsonResult = new JSONObject();80 String tag = request.getParameter("Tag");81 boolean split = ParameterParserUtil.parseBooleanParam(request.getParameter("split"), false);82 /**83 * Get list of execution by tag, env, country, browser84 */85 AnswerList<TestCaseExecution> listOfExecution = testCaseExecutionService.readByTagByCriteria(tag, 0, 0, null, null, null);86 List<TestCaseExecution> testCaseExecutions = listOfExecution.getDataList();87 /**88 * Get list of Execution in Queue by Tag89 */90 List<TestCaseExecutionQueue> testCaseExecutionsInQueue = testCaseExecutionInQueueService.findTestCaseExecutionInQueuebyTag(tag);91 /**92 * Feed hash map with execution from the two list (to get only one by93 * test,testcase,country,env,browser)94 */95 testCaseExecutions = hashExecution(testCaseExecutions, testCaseExecutionsInQueue);96 /**97 * Geting the global start and end of the execution tag.98 */99 long startMin = 0;100 long endMax = 0;101 for (TestCaseExecution testCaseExecution : testCaseExecutions) {102 if ((startMin == 0) || (testCaseExecution.getStart() < startMin)) {103 startMin = testCaseExecution.getStart();104 }105 if ((endMax == 0) || (testCaseExecution.getEnd() > endMax)) {106 endMax = testCaseExecution.getEnd();107 }108 }109 if (!split) {110 Map<String, JSONObject> axisMap = new HashMap<String, JSONObject>();111 for (TestCaseExecution testCaseWithExecution : testCaseExecutions) {112 String key;113 String controlStatus;114 JSONObject control = new JSONObject();115 JSONObject function = new JSONObject();116 if (testCaseWithExecution.getTestCaseObj().getFunction() != null && !"".equals(testCaseWithExecution.getTestCaseObj().getFunction())) {117 key = testCaseWithExecution.getTestCaseObj().getFunction();118 } else {119 key = testCaseWithExecution.getTest();120 }121 controlStatus = testCaseWithExecution.getControlStatus();122 control.put("value", 1);123 control.put("color", getColor(controlStatus));124 control.put("label", controlStatus);125 function.put("name", key);126 if (axisMap.containsKey(key)) {127 function = axisMap.get(key);128 if (function.has(controlStatus)) {129 int prec = function.getJSONObject(controlStatus).getInt("value");130 control.put("value", prec + 1);131 }132 }133 function.put(controlStatus, control);134 axisMap.put(key, function);135 }136 jsonResult.put("axis", axisMap.values());137 jsonResult.put("tag", tag);138 jsonResult.put("start", new Date(startMin));139 jsonResult.put("end", new Date(endMax));140 } else if (split) {141 boolean env = ParameterParserUtil.parseBooleanParam(request.getParameter("env"), false);142 boolean country = ParameterParserUtil.parseBooleanParam(request.getParameter("country"), false);143 boolean browser = ParameterParserUtil.parseBooleanParam(request.getParameter("browser"), false);144 boolean app = ParameterParserUtil.parseBooleanParam(request.getParameter("app"), false);145 AnswerList columnExec = testCaseExecutionService.readDistinctColumnByTag(tag, env, country, browser, app);146 List<TestCaseExecution> columnTcExec = columnExec.getDataList();147 AnswerList columnQueue = testCaseExecutionInQueueService.readDistinctColumnByTag(tag, env, country, browser, app);148 List<TestCaseExecutionQueue> columnInQueue = columnQueue.getDataList();149 Map<String, TestCaseExecution> testCaseExecutionsList = new LinkedHashMap();150 for (TestCaseExecution column : columnTcExec) {151 String key = column.getBrowser()152 + column.getCountry()153 + column.getEnvironment()154 + column.getApplication();155 testCaseExecutionsList.put(key, column);156 }157 for (TestCaseExecutionQueue column : columnInQueue) {158 TestCaseExecution testCaseExecution = testCaseExecutionInQueueService.convertToTestCaseExecution(column);159 String key = testCaseExecution.getBrowser()160 + testCaseExecution.getCountry()161 + testCaseExecution.getEnvironment()162 + testCaseExecution.getApplicationObj().getApplication();163 testCaseExecutionsList.put(key, testCaseExecution);164 }165 List<TestCaseExecution> res = new ArrayList<TestCaseExecution>(testCaseExecutionsList.values());166 HashMap<String, SummaryStatisticsDTO> statMap = new HashMap<String, SummaryStatisticsDTO>();167 for (TestCaseExecution column : res) {168 SummaryStatisticsDTO stat = new SummaryStatisticsDTO();169 stat.setEnvironment(column.getEnvironment());170 stat.setCountry(column.getCountry());171 stat.setRobotDecli(column.getBrowser());172 stat.setApplication(column.getApplication());173 statMap.put(column.getEnvironment() + "_" + column.getCountry() + "_" + column.getBrowser() + "_" + column.getApplication(),174 stat);175 }176 jsonResult.put("contentTable", getStatByEnvCountryBrowser(testCaseExecutions, statMap, env, country, browser, app));177 }178 response.getWriter().print(jsonResult);179 }180 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">181 /**182 * Handles the HTTP <code>GET</code> method.183 *184 * @param request servlet request185 * @param response servlet response186 * @throws ServletException if a servlet-specific error occurs187 * @throws IOException if an I/O error occurs188 */189 @Override190 protected void doGet(HttpServletRequest request, HttpServletResponse response)191 throws ServletException, IOException {192 try {193 processRequest(request, response);194 } catch (CerberusException ex) {195 LOG.warn(ex);196 } catch (ParseException ex) {197 LOG.warn(ex);198 } catch (JSONException ex) {199 LOG.warn(ex);200 }201 }202 /**203 * Handles the HTTP <code>POST</code> method.204 *205 * @param request servlet request206 * @param response servlet response207 * @throws ServletException if a servlet-specific error occurs208 * @throws IOException if an I/O error occurs209 */210 @Override211 protected void doPost(HttpServletRequest request, HttpServletResponse response)212 throws ServletException, IOException {213 try {214 processRequest(request, response);215 } catch (CerberusException ex) {216 LOG.warn(ex);217 } catch (ParseException ex) {218 LOG.warn(ex);219 } catch (JSONException ex) {220 LOG.warn(ex);221 }222 }223 /**224 * Returns a short description of the servlet.225 *226 * @return a String containing servlet description227 */228 @Override229 public String getServletInfo() {230 return "Short description";231 }// </editor-fold>232 private List<TestCaseExecution> hashExecution(List<TestCaseExecution> testCaseExecutions, List<TestCaseExecutionQueue> testCaseExecutionsInQueue) throws ParseException {233 Map<String, TestCaseExecution> testCaseExecutionsList = new LinkedHashMap();234 SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");235 for (TestCaseExecution testCaseExecution : testCaseExecutions) {236 String key = testCaseExecution.getBrowser() + "_"237 + testCaseExecution.getCountry() + "_"238 + testCaseExecution.getEnvironment() + "_"239 + testCaseExecution.getTest() + "_"240 + testCaseExecution.getTestCase();241 testCaseExecutionsList.put(key, testCaseExecution);242 }243 for (TestCaseExecutionQueue testCaseExecutionInQueue : testCaseExecutionsInQueue) {244 TestCaseExecution testCaseExecution = testCaseExecutionInQueueService.convertToTestCaseExecution(testCaseExecutionInQueue);245 String key = testCaseExecution.getBrowser() + "_"246 + testCaseExecution.getCountry() + "_"247 + testCaseExecution.getEnvironment() + "_"248 + testCaseExecution.getTest() + "_"249 + testCaseExecution.getTestCase();250 if ((testCaseExecutionsList.containsKey(key)251 && testCaseExecutionsList.get(key).getStart() < testCaseExecution.getStart())252 || !testCaseExecutionsList.containsKey(key)) {253 testCaseExecutionsList.put(key, testCaseExecution);254 }255 }256 List<TestCaseExecution> result = new ArrayList<TestCaseExecution>(testCaseExecutionsList.values());257 return result;258 }259 private JSONObject getStatByEnvCountryBrowser(List<TestCaseExecution> testCaseExecutions, HashMap<String, SummaryStatisticsDTO> statMap, boolean env, boolean country, boolean browser, boolean app) throws JSONException {260 SummaryStatisticsDTO total = new SummaryStatisticsDTO();261 total.setEnvironment("Total");262 for (TestCaseExecution testCaseExecution : testCaseExecutions) {263 StringBuilder key = new StringBuilder();264 key.append((env) ? testCaseExecution.getEnvironment() : "");265 key.append("_");266 key.append((country) ? testCaseExecution.getCountry() : "");267 key.append("_");268 key.append((browser) ? testCaseExecution.getBrowser() : "");269 key.append("_");270 key.append((app) ? testCaseExecution.getApplication() : "");271 if (statMap.containsKey(key.toString())) {272 statMap.get(key.toString()).updateStatisticByStatus(testCaseExecution.getControlStatus());273 }274 total.updateStatisticByStatus(testCaseExecution.getControlStatus());275 }276 return extractSummaryData(statMap, total);277 }278 private JSONObject extractSummaryData(HashMap<String, SummaryStatisticsDTO> summaryMap, SummaryStatisticsDTO total) throws JSONException {279 JSONObject extract = new JSONObject();280 JSONArray dataArray = new JSONArray();281 Gson gson = new Gson();282 //sort keys283 TreeMap<String, SummaryStatisticsDTO> sortedKeys = new TreeMap<String, SummaryStatisticsDTO>(summaryMap);284 for (String key : sortedKeys.keySet()) {285 SummaryStatisticsDTO sumStats = summaryMap.get(key);286 //percentage values287 sumStats.updatePercentageStatistics();288 dataArray.put(new JSONObject(gson.toJson(sumStats)));289 }290 total.updatePercentageStatistics();291 extract.put("split", dataArray);292 extract.put("total", new JSONObject(gson.toJson(total)));293 return extract;294 }295 private String getColor(String controlStatus) {296 String color = null;297 if ("OK".equals(controlStatus)) {298 color = "#5CB85C";299 } else if ("KO".equals(controlStatus)) {...

Full Screen

Full Screen

SummaryStatisticsDTO

Using AI Code Generation

copy

Full Screen

1SummaryStatisticsDTO summaryStatisticsDTO = new SummaryStatisticsDTO();2summaryStatisticsDTO.setTotal(100);3summaryStatisticsDTO.setPassed(90);4summaryStatisticsDTO.setFailed(10);5summaryStatisticsDTO.setBroken(0);6summaryStatisticsDTO.setOther(0);7summaryStatisticsDTO.setTotalLength(100);8summaryStatisticsDTO.setPassedLength(90);9summaryStatisticsDTO.setFailedLength(10);10summaryStatisticsDTO.setBrokenLength(0);11summaryStatisticsDTO.setOtherLength(0);12summaryStatisticsDTO.setTotalTime(100);13summaryStatisticsDTO.setPassedTime(90);14summaryStatisticsDTO.setFailedTime(10);15summaryStatisticsDTO.setBrokenTime(0);16summaryStatisticsDTO.setOtherTime(0);17summaryStatisticsDTO.setTotalDefects(100);18summaryStatisticsDTO.setPassedDefects(90);19summaryStatisticsDTO.setFailedDefects(10);20summaryStatisticsDTO.setBrokenDefects(0);21summaryStatisticsDTO.setOtherDefects(0);22summaryStatisticsDTO.setTotalExecuted(100);23summaryStatisticsDTO.setPassedExecuted(90);24summaryStatisticsDTO.setFailedExecuted(10);25summaryStatisticsDTO.setBrokenExecuted(0);26summaryStatisticsDTO.setOtherExecuted(0);27summaryStatisticsDTO.setTotalNotExecuted(100);28summaryStatisticsDTO.setPassedNotExecuted(90);29summaryStatisticsDTO.setFailedNotExecuted(10);30summaryStatisticsDTO.setBrokenNotExecuted(0);31summaryStatisticsDTO.setOtherNotExecuted(0);32summaryStatisticsDTO.setTotalKO(100);33summaryStatisticsDTO.setPassedKO(90);34summaryStatisticsDTO.setFailedKO(10);35summaryStatisticsDTO.setBrokenKO(0);36summaryStatisticsDTO.setOtherKO(0);37summaryStatisticsDTO.setTotalOK(100);38summaryStatisticsDTO.setPassedOK(90);39summaryStatisticsDTO.setFailedOK(10);40summaryStatisticsDTO.setBrokenOK(0);41summaryStatisticsDTO.setOtherOK(0);42summaryStatisticsDTO.setTotalNA(100);43summaryStatisticsDTO.setPassedNA(90);44summaryStatisticsDTO.setFailedNA(10);45summaryStatisticsDTO.setBrokenNA(0);46summaryStatisticsDTO.setOtherNA(0);47summaryStatisticsDTO.setTotalNE(100);48summaryStatisticsDTO.setPassedNE(90);49summaryStatisticsDTO.setFailedNE(10);50summaryStatisticsDTO.setBrokenNE(0);51summaryStatisticsDTO.setOtherNE(0);52summaryStatisticsDTO.setTotalPE(100);53summaryStatisticsDTO.setPassedPE(

Full Screen

Full Screen

SummaryStatisticsDTO

Using AI Code Generation

copy

Full Screen

1SummaryStatisticsDTO summaryStatisticsDTO = new SummaryStatisticsDTO();2summaryStatisticsDTO.setNbOfExecutions(10);3summaryStatisticsDTO.setNbOfExecutionsOK(8);4summaryStatisticsDTO.setNbOfExecutionsKO(2);5summaryStatisticsDTO.setNbOfExecutionsFA(0);6summaryStatisticsDTO.setNbOfExecutionsNA(0);7summaryStatisticsDTO.setNbOfExecutionsPE(0);8summaryStatisticsDTO.setNbOfExecutionsQU(0);9summaryStatisticsDTO.setNbOfExecutionsWE(0);10summaryStatisticsDTO.setNbOfExecutionsNE(0);11summaryStatisticsDTO.setNbOfExecutionsCA(0);

Full Screen

Full Screen

SummaryStatisticsDTO

Using AI Code Generation

copy

Full Screen

1SummaryStatisticsDTO summaryStatisticsDTO = new SummaryStatisticsDTO();2summaryStatisticsDTO.setCountry("FR");3summaryStatisticsDTO.setApplication("MyApp");4summaryStatisticsDTO.setEnvironment("QA");5summaryStatisticsDTO.setBuild("1.0.0");6summaryStatisticsDTO.setRevision("1.0.0");7summaryStatisticsDTO.setTotalExecuted(1);8summaryStatisticsDTO.setTotalOK(1);9summaryStatisticsDTO.setTotalKO(0);10summaryStatisticsDTO.setTotalFA(0);11summaryStatisticsDTO.setTotalNA(0);12summaryStatisticsDTO.setTotalQU(0);13summaryStatisticsDTO.setTotalPE(0);14summaryStatisticsDTO.setTotalQE(0);15summaryStatisticsDTO.setTotalCA(0);16summaryStatisticsDTO.setTotalWE(0);17summaryStatisticsDTO.setTotalNE(0);18summaryStatisticsDTO.setTotalQE(0);19summaryStatisticsDTO.setTotalPE(0);20summaryStatisticsDTO.setTotalCA(0);21summaryStatisticsDTO.setTotalWE(0);22summaryStatisticsDTO.setTotalNE(0);23summaryStatisticsDTO.setTotalOK(1);24summaryStatisticsDTO.setTotalKO(0);25summaryStatisticsDTO.setTotalFA(0);26summaryStatisticsDTO.setTotalNA(0);27summaryStatisticsDTO.setTotalQU(0);28summaryStatisticsDTO.setTotalPE(0);29summaryStatisticsDTO.setTotalQE(0);30summaryStatisticsDTO.setTotalCA(0);31summaryStatisticsDTO.setTotalWE(0);32summaryStatisticsDTO.setTotalNE(0);33summaryStatisticsDTO.setTotalOK(1);34summaryStatisticsDTO.setTotalKO(0);35summaryStatisticsDTO.setTotalFA(0);36summaryStatisticsDTO.setTotalNA(0);37summaryStatisticsDTO.setTotalQU(0);38summaryStatisticsDTO.setTotalPE(0);39summaryStatisticsDTO.setTotalQE(0);40summaryStatisticsDTO.setTotalCA(0);41summaryStatisticsDTO.setTotalWE(0);42summaryStatisticsDTO.setTotalNE(0);43summaryStatisticsDTO.setTotalOK(1);44summaryStatisticsDTO.setTotalKO(0);45summaryStatisticsDTO.setTotalFA(0);46summaryStatisticsDTO.setTotalNA(0);47summaryStatisticsDTO.setTotalQU(0);48summaryStatisticsDTO.setTotalPE(0);49summaryStatisticsDTO.setTotalQE(0);50summaryStatisticsDTO.setTotalCA(0);51summaryStatisticsDTO.setTotalWE(0);52summaryStatisticsDTO.setTotalNE(0);53summaryStatisticsDTO.setTotalOK(1);54summaryStatisticsDTO.setTotalKO(0);

Full Screen

Full Screen

SummaryStatisticsDTO

Using AI Code Generation

copy

Full Screen

1package org.cerberus.dto;2import java.util.List;3public class SummaryStatisticsDTO {4 private String application;5 private String country;6 private String environment;7 private String build;8 private String revision;9 private String chain;10 private String status;11 private String controlStatus;12 private String controlMessage;13 private List<TestCaseExecutionDTO> testCaseExecutionList;14 public String getApplication() {15 return application;16 }17 public void setApplication(String application) {18 this.application = application;19 }20 public String getCountry() {21 return country;22 }23 public void setCountry(String country) {24 this.country = country;25 }26 public String getEnvironment() {27 return environment;28 }29 public void setEnvironment(String environment) {30 this.environment = environment;31 }32 public String getBuild() {33 return build;34 }35 public void setBuild(String build) {36 this.build = build;37 }38 public String getRevision() {39 return revision;40 }41 public void setRevision(String revision) {42 this.revision = revision;43 }44 public String getChain() {45 return chain;46 }47 public void setChain(String chain) {48 this.chain = chain;49 }50 public String getStatus() {51 return status;52 }53 public void setStatus(String status) {54 this.status = status;55 }56 public String getControlStatus() {57 return controlStatus;58 }59 public void setControlStatus(String controlStatus) {60 this.controlStatus = controlStatus;61 }62 public String getControlMessage() {63 return controlMessage;64 }65 public void setControlMessage(String controlMessage) {66 this.controlMessage = controlMessage;67 }68 public List<TestCaseExecutionDTO> getTestCaseExecutionList() {69 return testCaseExecutionList;70 }71 public void setTestCaseExecutionList(List<TestCaseExecutionDTO> testCaseExecutionList) {72 this.testCaseExecutionList = testCaseExecutionList;73 }74}75package org.cerberus.dto;76import java.util.Date;77public class TestCaseExecutionDTO {78 private long id;79 private String test;80 private String testCase;81 private String country;82 private String environment;83 private String robot;84 private String robotDecli;85 private String robotHost;86 private String robotPort;

Full Screen

Full Screen

SummaryStatisticsDTO

Using AI Code Generation

copy

Full Screen

1public class SummaryStatisticsDTO {2 private String country;3 private String environment;4 private String build;5 private String revision;6 private String version;7 private String project;8 private String application;9 private String active;10 private String activeQA;11 private String activeUAT;12 private String activePROD;13 private String total;14 private String totalQA;15 private String totalUAT;16 private String totalPROD;17 private String totalOK;18 private String totalOKQA;19 private String totalOKUAT;20 private String totalOKPROD;21 private String totalKO;22 private String totalKOQA;23 private String totalKOUAT;24 private String totalKOPROD;25 private String totalFA;26 private String totalFAQA;27 private String totalFAUAT;28 private String totalFAPROD;29 private String totalNA;30 private String totalNAQA;31 private String totalNAUAT;32 private String totalNAPROD;33 private String totalNC;34 private String totalNCQA;35 private String totalNCUAT;36 private String totalNCPROD;37 private String totalNE;38 private String totalNEQA;39 private String totalNEUAT;40 private String totalNEPROD;41 private String totalPE;42 private String totalPEQA;43 private String totalPEUAT;44 private String totalPEPROD;45 private String totalQU;46 private String totalQUQA;47 private String totalQUUAT;48 private String totalQUPROD;49 private String totalWE;50 private String totalWEQA;51 private String totalWEUAT;52 private String totalWEPROD;53 private String totalWEOK;54 private String totalWEOKQA;55 private String totalWEOKUAT;56 private String totalWEOKPROD;57 private String totalWEKO;58 private String totalWEKOQA;59 private String totalWEKOUAT;60 private String totalWEKOPROD;61 private String totalWEFA;62 private String totalWEFAQA;63 private String totalWEFAUAT;64 private String totalWEFAPROD;65 private String totalWENA;66 private String totalWENAPROD;67 private String totalWENAQA;68 private String totalWENAUAT;69 private String totalWENC;

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