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

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

Source:GetNumberOfExecutions.java Github

copy

Full Screen

...75 * @param response servlet response76 * @throws ServletException if a servlet-specific error occurs77 * @throws IOException if an I/O error occurs78 */79 protected void processRequest(HttpServletRequest request, HttpServletResponse response)80 throws ServletException, IOException {81 PrintWriter out = response.getWriter();82 // Loading Services.83 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());84 IApplicationService myApplicationService = appContext.getBean(ApplicationService.class);85 IInvariantService myInvariantService = appContext.getBean(InvariantService.class);86 // Calling Servlet Transversal Util.87 ServletUtil.servletStart(request);88 /**89 * Adding Log entry.90 */91 ILogEventService logEventService = appContext.getBean(LogEventService.class);92 logEventService.createForPublicCalls("/GetNumberOfExecutions", "CALL", "GetNumberOfExecutions called : " + request.getRequestURL(), request);93 // Parsing all parameters.94 String environment = ParameterParserUtil.parseStringParam(request.getParameter("environment"), "PROD");95 String test = ParameterParserUtil.parseStringParam(request.getParameter("test"), "");96 String application = ParameterParserUtil.parseStringParam(request.getParameter("application"), "");97 String country = ParameterParserUtil.parseStringParam(request.getParameter("country"), "");98 String controlStatus = ParameterParserUtil.parseStringParam(request.getParameter("controlstatus"), "");99 int NbMinutes = ParameterParserUtil.parseIntegerParam(request.getParameter("nbminuteshistory"), 0);100 // Defining help message.101 String helpMessage = "\nThis servlet return the number of execution performed on WORKING test cases that match the following criterias :\n"102 + "- nbminuteshistory [mandatory] : the number of minutes in the past from the moment the servlet is called. This parameter must be > 0. [" + NbMinutes + "]\n"103 + "- test : Executions done on the test. [" + test + "]\n"104 + "- environment : Environment where the execution happened. Default to PROD. [" + environment + "]\n"105 + "- country : Executions done on the country. [" + country + "]\n"106 + "- application : Executions done against that application. [" + application + "]\n"107 + "- controlstatus : execution that return the following status. [" + controlStatus + "]\n";108 try {109 // Checking the parameter validity. nbminuteshistory is a mandatory parameter.110 boolean error = false;111 if (NbMinutes == 0) {112 out.println("Error - Parameter nbminuteshistory is mandatory. Please feed it in order to specify the elapsed time where the history should be considered.");113 error = true;114 }115 // Checking the parameter validity. If application has been entered, does it exist ?116 if (!application.equalsIgnoreCase("") && !myApplicationService.exist(application)) {117 out.println("Error - Application does not exist : " + application);118 error = true;119 }120 if (!country.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("COUNTRY", country)) {121 out.println("Warning - Country does not exist : " + country);122 }123 if (!environment.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("ENVIRONMENT", environment)) {124 out.println("Warning - Environment does not exist : " + environment);125 }126 if (!controlStatus.equalsIgnoreCase("") && !myInvariantService.isInvariantExist("TCESTATUS", controlStatus)) {127 out.println("Warning - Control Status does not exist : " + controlStatus);128 }129 // Starting the request only if previous parameters exist.130 if (!error) {131 // Getting a timestamp to filter the executions based on the nb of minutes132 String dateLimitFrom = DateUtil.getMySQLTimestampTodayDeltaMinutes(-NbMinutes);133 ITestCaseExecutionService MyTestExecutionService = appContext.getBean(TestCaseExecutionService.class);134 List<TestCaseExecution> myList;135 // Getting the lists of test cases the follow the criterias.136 try {137 myList = MyTestExecutionService.findTCExecutionbyCriteria1(dateLimitFrom, test, "", application, country, environment, controlStatus, "WORKING");138 out.println(myList.size());139 } catch (CerberusException e) {140 out.println("0");141 }142 } else {143 // In case of errors, we displayu the help message.144 out.println(helpMessage);145 }146 } catch (Exception e) {147 LOG.warn(Infos.getInstance().getProjectNameAndVersion() + " - Exception catched.", e);148 out.print("Error while Getting number of executions : ");149 out.println(e.getMessage());150 } finally {151 out.close();152 }153 }154 // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">155 /**156 * Handles the HTTP157 * <code>GET</code> method.158 *159 * @param request servlet request160 * @param response servlet response161 * @throws ServletException if a servlet-specific error occurs162 * @throws IOException if an I/O error occurs163 */164 @Override165 protected void doGet(HttpServletRequest request, HttpServletResponse response)166 throws ServletException, IOException {167 processRequest(request, response);168 }169 /**170 * Handles the HTTP171 * <code>POST</code> method.172 *173 * @param request servlet request174 * @param response servlet response175 * @throws ServletException if a servlet-specific error occurs176 * @throws IOException if an I/O error occurs177 */178 @Override179 protected void doPost(HttpServletRequest request, HttpServletResponse response)180 throws ServletException, IOException {181 processRequest(request, response);182 }183 /**184 * Returns a short description of the servlet.185 *186 * @return a String containing servlet description187 */188 @Override189 public String getServletInfo() {190 return "Short description";191 }// </editor-fold>192}...

Full Screen

Full Screen

processRequest

Using AI Code Generation

copy

Full Screen

1var application = "MyApplication";2var country = "FR";3var environment = "QA";4var test = "MyTest";5var testCase = "MyTestCase";6var build = "1";7var revision = "1";8var chain = "1";9var browser = "chrome";10var browserVersion = "1";11var platform = "1";12var tag = "1";13var controlStatus = "1";14var controlMessage = "1";15var controlProperty = "1";16var controlValue1 = "1";17var controlValue2 = "1";18var controlValue3 = "1";19var controlValue4 = "1";20var controlValue5 = "1";21var status = "1";22var message = "1";

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Cerberus-source automation tests on LambdaTest cloud grid

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

Most used method in GetNumberOfExecutions

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful