Best Cerberus-source code snippet using org.cerberus.servlet.zzpublic.AddToExecutionQueueV002
Source:AddToExecutionQueueV002.java  
...69 * Add a test case to the execution queue (so to be executed later).70 *71 * @author abourdon72 */73@WebServlet(name = "AddToExecutionQueueV002", urlPatterns = {"/AddToExecutionQueueV002"})74public class AddToExecutionQueueV002 extends HttpServlet {75    private static final Logger LOG = LogManager.getLogger(AddToExecutionQueueV002.class);76    private static final String PARAMETER_CAMPAIGN = "campaign";77    private static final String PARAMETER_TEST = "test";78    private static final String PARAMETER_TESTCASE = "testcase";79    private static final String PARAMETER_COUNTRY = "country";80    private static final String PARAMETER_ENVIRONMENT = "environment";81    private static final String PARAMETER_BROWSER = "browser";82    private static final String PARAMETER_ROBOT = "robot";83    private static final String PARAMETER_ROBOT_IP = "ss_ip";84    private static final String PARAMETER_ROBOT_PORT = "ss_p";85    private static final String PARAMETER_BROWSER_VERSION = "version";86    private static final String PARAMETER_PLATFORM = "platform";87    private static final String PARAMETER_SCREENSIZE = "screensize";88    private static final String PARAMETER_MANUAL_URL = "manualurl";89    private static final String PARAMETER_MANUAL_HOST = "myhost";90    private static final String PARAMETER_MANUAL_CONTEXT_ROOT = "mycontextroot";91    private static final String PARAMETER_MANUAL_LOGIN_RELATIVE_URL = "myloginrelativeurl";92    private static final String PARAMETER_MANUAL_ENV_DATA = "myenvdata";93    private static final String PARAMETER_TAG = "tag";94    private static final String PARAMETER_SCREENSHOT = "screenshot";95    private static final String PARAMETER_VERBOSE = "verbose";96    private static final String PARAMETER_TIMEOUT = "timeout";97    private static final String PARAMETER_PAGE_SOURCE = "pagesource";98    private static final String PARAMETER_SELENIUM_LOG = "seleniumlog";99    private static final String PARAMETER_RETRIES = "retries";100    private static final String PARAMETER_MANUAL_EXECUTION = "manualexecution";101    private static final String PARAMETER_EXEPRIORITY = "priority";102    private static final String PARAMETER_OUTPUTFORMAT = "outputformat";103    private static final int DEFAULT_VALUE_SCREENSHOT = 0;104    private static final int DEFAULT_VALUE_MANUAL_URL = 0;105    private static final int DEFAULT_VALUE_VERBOSE = 0;106    private static final long DEFAULT_VALUE_TIMEOUT = 300;107    private static final int DEFAULT_VALUE_PAGE_SOURCE = 1;108    private static final int DEFAULT_VALUE_SELENIUM_LOG = 1;109    private static final int DEFAULT_VALUE_RETRIES = 0;110    private static final String DEFAULT_VALUE_MANUAL_EXECUTION = "N";111    private static final int DEFAULT_VALUE_PRIORITY = 1000;112    private static final String DEFAULT_VALUE_OUTPUTFORMAT = "compact";113    private static final String LOCAL_SEPARATOR = "_-_";114    private static final String LINE_SEPARATOR = "\n";115    private static final SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd-HHmmss");116    private ITestCaseExecutionQueueService inQueueService;117    private IFactoryTestCaseExecutionQueue inQueueFactoryService;118    private IExecutionThreadPoolService executionThreadService;119    private IInvariantService invariantService;120    private IApplicationService applicationService;121    private ITestCaseService testCaseService;122    private ITestCaseCountryService testCaseCountryService;123    private ICampaignParameterService campaignParameterService;124    private ICountryEnvParamService countryEnvParamService;125    /**126     * Process request for both GET and POST method.127     *128     * <p>129     * Request processing is divided in two parts:130     * <ol>131     * <li>Getting all test cases which have been sent to this servlet;</li>132     * <li>Try to insert all these test cases to the execution queue.</li>133     * </ol>134     * </p>135     *136     * @param request137     * @param response138     * @throws ServletException139     * @throws IOException140     */141    private void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {142        PrintWriter out = response.getWriter();143        final String charset = request.getCharacterEncoding();144        Date requestDate = new Date();145        // Loading Services.146        ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());147        inQueueService = appContext.getBean(ITestCaseExecutionQueueService.class);148        inQueueFactoryService = appContext.getBean(IFactoryTestCaseExecutionQueue.class);149        executionThreadService = appContext.getBean(IExecutionThreadPoolService.class);150        testCaseService = appContext.getBean(ITestCaseService.class);151        invariantService = appContext.getBean(IInvariantService.class);152        applicationService = appContext.getBean(IApplicationService.class);153        testCaseCountryService = appContext.getBean(ITestCaseCountryService.class);154        campaignParameterService = appContext.getBean(ICampaignParameterService.class);155        countryEnvParamService = appContext.getBean(ICountryEnvParamService.class);156        // Calling Servlet Transversal Util.157        ServletUtil.servletStart(request);158        // Default message to unexpected error.159        MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);160        msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));161        AnswerItem<List<TestCase>> testcases = null;162        /**163         * Adding Log entry.164         */165        ILogEventService logEventService = appContext.getBean(ILogEventService.class);166        logEventService.createForPublicCalls("/AddToExecutionQueueV002", "CALL", "AddToExecutionQueueV002 called : " + request.getRequestURL(), request);167        // Parsing all parameters.168        // Execution scope parameters : Campaign, TestCases, Countries, Environment, Browser.169        String campaign = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter(PARAMETER_CAMPAIGN), null, charset);170        List<String> selectTest;171        selectTest = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_TEST), null, charset);172        List<String> selectTestCase;173        selectTestCase = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_TESTCASE), null, charset);174        List<String> countries;175        countries = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_COUNTRY), null, charset);176        List<String> environments;177        environments = ParameterParserUtil.parseListParamAndDecodeAndDeleteEmptyValue(request.getParameterValues(PARAMETER_ENVIRONMENT), null, charset);178        List<String> browsers = new ArrayList<>();;179        browsers = ParameterParserUtil.parseListParamAndDecode(request.getParameterValues(PARAMETER_BROWSER), browsers, charset);180        // Execution parameters....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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
