How to use processRequest method of org.cerberus.servlet.zzpublic.ResultCIV004 class

Best Cerberus-source code snippet using org.cerberus.servlet.zzpublic.ResultCIV004.processRequest

Source:ResultCIV004.java Github

copy

Full Screen

...48 */49@WebServlet(name = "ResultCIV004", urlPatterns = {"/ResultCIV004"})50public class ResultCIV004 extends HttpServlet {51 private static Logger LOG = LogManager.getLogger(ResultCIV004.class);52 protected void processRequest(HttpServletRequest request,53 HttpServletResponse response) throws ServletException, IOException {54 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());55 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);56 // Calling Servlet Transversal Util.57 ServletUtil.servletStart(request);58 /**59 * Adding Log entry.60 */61 ILogEventService logEventService = appContext.getBean(ILogEventService.class);62 logEventService.createForPublicCalls("/ResultCIV004", "CALL", "ResultCIV004 called : " + request.getRequestURL(), request);63 try {64 JSONObject jsonResponse = new JSONObject();65 String tag = policy.sanitize(request.getParameter("tag"));66 String campaign = policy.sanitize(request.getParameter("campaign"));67 String outputFormat = policy.sanitize(request.getParameter("outputformat"));68 String helpMessage = "This servlet is used to provide various execution counters as well as a global OK or KO status based on the number and status of the execution done on a specific tag. \n"69 + "The number of executions are ponderated by parameters by priority from cerberus_ci_okcoefprio1 to cerberus_ci_okcoefprio4. \n"70 + "Formula used is the following : \n"71 + "Nb Exe Prio 1 testcases * cerberus_ci_okcoefprio1 + Nb Exe Prio 2 testcases * cerberus_ci_okcoefprio2 + "72 + "Nb Exe Prio 3 testcases * cerberus_ci_okcoefprio3 + Nb Exe Prio 4 testcases * cerberus_ci_okcoefprio4.\n"73 + "If no executions are found, the result is KO.\n"74 + "With at least 1 execution, if result is < 1 then global servlet result is OK. If not, it is KO.\n"75 + "All execution needs to have a status equal to KO, FA, NA, PE or NE.\n"76 + "If at least 1 PE or 1 NE if found, global status will be PE\n"77 + "Output format is json by default, or SVG if outputFormat=svg is defined\n"78 + "Parameter list :\n"79 + "- tag : Execution Tag to filter the test cases execution. [" + tag + "]\n"80 + "- campaign : If you feed the campaign, the lastest Tag from that campaign will be selected. [" + campaign + "]\n"81 + "- outputformat : ['text','json', 'svg']. Output format of the result. [" + outputFormat + "]\n";82 jsonResponse.put("helpMessage", helpMessage);83 boolean error = false;84 String error_message = "";85 // Checking the parameter validity. Tag is a mandatory parameter86 if (StringUtil.isNullOrEmpty(tag)) {87 if (!StringUtil.isNullOrEmpty(campaign)) {88 ITagService tagService = appContext.getBean(ITagService.class);89 List<Tag> myList;90 AnswerList<Tag> myAnswerList = tagService.readByVariousByCriteria(campaign, 0, 1, "id", "desc", null, null);91 if (myAnswerList.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {//the service was able to perform the query, then we should get all values92 for (Tag tagCur : (List<Tag>) myAnswerList.getDataList()) {93 tag = tagCur.getTag();94 }95 }96 }97 }98 if (StringUtil.isNullOrEmpty(tag)) {99 error_message += "Error - Either specify a tag or specify a campaign to get the latest tag from that campaign.";100 error = true;101 }102 if (!error) {103 ICIService ciService = appContext.getBean(ICIService.class);104 jsonResponse = ciService.getCIResult(tag, null);105 // Log the result with calculation detail.106 logEventService.createForPublicCalls("/ResultCIV004", "CALLRESULT", "ResultCIV004 calculated for tag " + tag + " result [" + jsonResponse.getString("result") + "]", request);107 } else {108 jsonResponse.put("messageType", "KO");109 jsonResponse.put("message", error_message);110 }111 generateResponse(response, outputFormat, jsonResponse, error);112 } catch (JSONException e) {113 LOG.warn(e);114 //returns a default error message with the json format that is able to be parsed by the client-side115 response.getWriter().print(AnswerUtil.createGenericErrorAnswer());116 }117 }118 private void generateResponse(HttpServletResponse response, String outputFormat, JSONObject jsonResponse, boolean error) throws IOException {119 StringBuilder returnMessage = new StringBuilder();120 switch (outputFormat) {121 case "svg":122 response.setContentType("image/svg+xml");123 response.setHeader("Cache-Control", "no-cache");124 response.setDateHeader("Expires", 0);125 try {126 String tagToDisplay = "";127 String resultToDisplay = "";128 if (error) {129 tagToDisplay = StringUtils.substring(jsonResponse.getString("message"), 0, 32);130 resultToDisplay = "ERR";131 } else {132 tagToDisplay = StringUtils.substring(jsonResponse.getString("tag"), 0, 32);133 resultToDisplay = jsonResponse.getString("result");134 }135 String responseSvg = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"350\" height=\"20\">"136 + "<linearGradient id=\"b\" x2=\"0\" y2=\"100%\">"137 + "<stop offset=\"0\" stop-color=\"#bbb\" stop-opacity=\".1\"></stop>"138 + "<stop offset=\"1\" stop-opacity=\".1\"></stop>"139 + "</linearGradient>"140 //RECTANGLE141 + "<rect rx=\"3\" fill=\"#555\" width=\"250\" height=\"20\"></rect>"142 + "<rect rx=\"3\" x=\"210\" fill=\"" + getColor(resultToDisplay) + "\" width=\"40\" height=\"20\"></rect>"143 //TEXT 144 + "<g fill=\"#fff\" text-anchor=\"start\" font-family=\"DejaVu Sans,Verdana,Geneva,sans-serif\" font-size=\"9\">"145 + "<text x=\"10\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">" + tagToDisplay + "</text>"146 + "<text x=\"10\" y=\"14\">" + tagToDisplay + "</text>"147 + "<text x=\"225\" y=\"15\" fill=\"#010101\" fill-opacity=\".3\">" + resultToDisplay + "</text>"148 + "<text x=\"225\" y=\"14\">" + resultToDisplay + "</text>"149 + "</g>"150 + "</svg>";151 response.getWriter().print(responseSvg);152 } catch (JSONException ex) {153 LOG.warn(ex);154 }155 break;156 case "text":157 response.setContentType("text");158 response.setCharacterEncoding("utf8");159 try {160 if (error) {161 returnMessage.append(jsonResponse.get("message"));162 returnMessage.append("\n\n");163 returnMessage.append(jsonResponse.get("helpMessage"));164 } else {165 returnMessage.append(jsonResponse.get("result"));166 }167 response.getWriter().print(returnMessage.toString());168 } catch (JSONException ex) {169 LOG.warn(ex);170 }171 break;172 default:173 response.setContentType("application/json");174 response.setCharacterEncoding("utf8");175 response.getWriter().print(jsonResponse.toString());176 }177 }178 private String getColor(String controlStatus) {179 String color = null;180 if ("OK".equals(controlStatus)) {181 color = "#5CB85C";182 } else if ("KO".equals(controlStatus)) {183 color = "#D9534F";184 } else {185 color = "#3498DB";186 }187 return color;188 }189 // <editor-fold defaultstate="collapsed"190 // desc="HttpServlet methods. Click on the + sign on the left to edit the code.">191 /**192 * Handles the HTTP <code>GET</code> method.193 *194 * @param request servlet request195 * @param response servlet response196 * @throws ServletException if a servlet-specific error occurs197 * @throws IOException if an I/O error occurs198 */199 @Override200 protected void doGet(HttpServletRequest request,201 HttpServletResponse response) throws ServletException, IOException {202 processRequest(request, response);203 }204 /**205 * Handles the HTTP <code>POST</code> method.206 *207 * @param request servlet request208 * @param response servlet response209 * @throws ServletException if a servlet-specific error occurs210 * @throws IOException if an I/O error occurs211 */212 @Override213 protected void doPost(HttpServletRequest request,214 HttpServletResponse response) throws ServletException, IOException {215 processRequest(request, response);216 }217 /**218 * Returns a short description of the servlet.219 *220 * @return a String containing servlet description221 */222 @Override223 public String getServletInfo() {224 return "Short description";225 }// </editor-fold>226}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1importClass(Packages.org.cerberus.servlet.zzpublic.ResultCIV004);2importClass(Packages.org.cerberus.servlet.zzpublic.ResultCIV004$ExecutionStatus);3var resultCIV004 = new ResultCIV004();4var executionStatus = resultCIV004.processRequest("CIV004", "DE", "QA");5if (executionStatus == ResultCIV004$ExecutionStatus.OK) {6} else if (executionStatus == ResultCIV004$ExecutionStatus.KO) {7} else if (executionStatus == ResultCIV004$ExecutionStatus.NA) {8} else if (executionStatus == ResultCIV004$ExecutionStatus.FA) {9} else if (executionStatus == ResultCIV004$ExecutionStatus.NC) {10} else if (executionStatus == ResultCIV004$ExecutionStatus.NE) {11}12importClass(Packages.org.cerberus.servlet.zzpublic.ResultCIV004);13importClass(Packages.org.cerberus.servlet.zzpublic.ResultCIV004$ExecutionStatus);14var resultCIV004 = new ResultCIV004();15var executionStatus = resultCIV004.processRequest("CIV004", "DE", "QA", "1.0.0", "1");16if (executionStatus == ResultCIV004$ExecutionStatus.OK) {17} else if (executionStatus == ResultCIV004$ExecutionStatus.KO) {18} else if (executionStatus == ResultCIV004$ExecutionStatus.N

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1var test = execution.test;2var testcase = execution.testcase;3var executionId = execution.id;4var executionDate = execution.start;5var environment = execution.environment;6var country = execution.country;7var robot = execution.robot;8var robotIP = execution.robotIP;9var robotPort = execution.robotPort;10var controlStatus = execution.controlStatus;11var controlMessage = execution.controlMessage;12var application = execution.application;13var browser = execution.browser;14var browserVersion = execution.browserVersion;15var platform = execution.platform;16var tag = execution.tag;17var verbose = execution.verbose;18var screenshot = execution.screenshot;19var pageSource = execution.pageSource;20var seleniumLog = execution.seleniumLog;21var timeout = execution.timeout;22var manualURL = execution.manualURL;23var manualHost = execution.manualHost;24var manualContextRoot = execution.manualContextRoot;25var manualLoginRelativeURL = execution.manualLoginRelativeURL;26var manualEnvData = execution.manualEnvData;27var manualExecution = execution.manualExecution;28var manualCountry = execution.manualCountry;29var manualEnvironment = execution.manualEnvironment;30var manualBrowser = execution.manualBrowser;31var manualBrowserVersion = execution.manualBrowserVersion;32var manualPlatform = execution.manualPlatform;33var manualScreenSize = execution.manualScreenSize;

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Cerberus-source automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful