How to use setDescription method of org.cerberus.crud.entity.Robot class

Best Cerberus-source code snippet using org.cerberus.crud.entity.Robot.setDescription

Source:ExecutionStartService.java Github

copy

Full Screen

...117 try {118 myInvariant = invariantService.convert(invariantService.readByKey("OUTPUTFORMAT", tCExecution.getOutputFormat()));119 } catch (CerberusException ex) {120 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_OUTPUTFORMAT_INVALID);121 mes.setDescription(mes.getDescription().replace("%PARAM%", tCExecution.getOutputFormat()));122 LOG.debug(mes.getDescription());123 throw new CerberusException(mes);124 }125 try {126 myInvariant = invariantService.convert(invariantService.readByKey("VERBOSE", String.valueOf(tCExecution.getVerbose())));127 } catch (CerberusException ex) {128 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_VERBOSE_INVALID);129 mes.setDescription(mes.getDescription().replace("%PARAM%", String.valueOf(tCExecution.getVerbose())));130 LOG.debug(mes.getDescription());131 throw new CerberusException(mes);132 }133 try {134 myInvariant = invariantService.convert(invariantService.readByKey("SCREENSHOT", String.valueOf(tCExecution.getScreenshot())));135 } catch (CerberusException ex) {136 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_SCREENSHOT_INVALID);137 mes.setDescription(mes.getDescription().replace("%PARAM%", String.valueOf(tCExecution.getScreenshot())));138 LOG.debug(mes.getDescription());139 throw new CerberusException(mes);140 }141 LOG.debug("Parameters checked.");142 /**143 * Load TestCase information and set TCase to the TestCaseExecution144 * object.145 */146 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_LOADINGDATA));147 LOG.debug("Loading Test Case Information. " + tCExecution.getTest() + "-" + tCExecution.getTestCase());148 // Integrate this.loadTestCaseService.loadTestCase(tCExecution); inside with Dependency.149 try {150// TestCase tCase = testCaseService.findTestCaseByKey(tCExecution.getTest(), tCExecution.getTestCase());151 TestCase tCase = testCaseService.convert(testCaseService.readByKey(tCExecution.getTest(), tCExecution.getTestCase()));152 if (tCase != null) {153 tCExecution.setTestCaseObj(tCase);154 tCExecution.setDescription(tCase.getDescription());155 tCExecution.setConditionOperator(tCase.getConditionOperator());156 tCExecution.setConditionVal1(tCase.getConditionVal1());157 tCExecution.setConditionVal1Init(tCase.getConditionVal1());158 tCExecution.setConditionVal2(tCase.getConditionVal2());159 tCExecution.setConditionVal2Init(tCase.getConditionVal2());160 tCExecution.setConditionVal3(tCase.getConditionVal3());161 tCExecution.setConditionVal3Init(tCase.getConditionVal3());162 tCExecution.setTestCaseVersion(tCase.getVersion());163 tCExecution.setTestCasePriority(tCase.getPriority());164 } else {165 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.NO_DATA_FOUND));166 }167 /**168 * Copy the status of the testcase to the status column of the169 * Execution. This is done to know how stable was the testcase at170 * the time of the execution.171 */172 tCExecution.setStatus(tCase.getStatus());173 } catch (CerberusException ex) {174 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_NOT_FOUND);175 mes.setDescription(mes.getDescription().replace("%TEST%", tCExecution.getTest()));176 mes.setDescription(mes.getDescription().replace("%TESTCASE%", tCExecution.getTestCase()));177 LOG.debug(mes.getDescription());178 throw new CerberusException(mes);179 }180 LOG.debug("Test Case Information Loaded - " + tCExecution.getTest() + "-" + tCExecution.getTestCase());181 /**182 * Load Test information and Set TestObject to the TestCaseExecution183 * object.184 */185 LOG.debug("Loading Test Information");186 try {187 tCExecution.setTestObj(this.testService.convert(this.testService.readByKey(tCExecution.getTest())));188 } catch (CerberusException ex) {189 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TEST_NOT_FOUND);190 mes.setDescription(mes.getDescription().replace("%TEST%", tCExecution.getTest()));191 LOG.debug(mes.getDescription());192 throw new CerberusException(mes);193 }194 LOG.debug("Test Information Loaded - " + tCExecution.getTest());195 /**196 * Load Application information and Set Application to the197 * TestCaseExecution object.198 */199 LOG.debug("Loading Application Information");200 try {201 tCExecution.setApplication(tCExecution.getTestCaseObj().getApplication());202 tCExecution.setApplicationObj(applicationService.convert(this.applicationService.readByKey(tCExecution.getTestCaseObj().getApplication())));203 // Setting Application Type to value coming from Application.204 tCExecution.setAppTypeEngine(tCExecution.getApplicationObj().getType());205 // Setting System from queue.206 tCExecution.getTestCaseExecutionQueue().setSystem(tCExecution.getApplicationObj().getSystem());207 LOG.debug("Application Information Loaded - " + tCExecution.getApplicationObj().getApplication() + " - " + tCExecution.getApplicationObj().getDescription());208 } catch (CerberusException ex) {209 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_APPLICATION_NOT_FOUND);210 mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));211 LOG.debug(mes.getDescription());212 throw new CerberusException(mes);213 }214 /**215 * Init System from Application.216 */217 tCExecution.setSystem(tCExecution.getApplicationObj().getSystem());218 /**219 * Load Country information and Set it to the TestCaseExecution object.220 */221 LOG.debug("Loading Country Information");222 try {223 tCExecution.setCountryObj(invariantService.convert(invariantService.readByKey("COUNTRY", tCExecution.getCountry())));224 if (tCExecution.getCountryObj() != null) {225 LOG.debug("Country Information Loaded - " + tCExecution.getCountryObj().getValue() + " - " + tCExecution.getCountryObj().getDescription());226 } else {227 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRY_NOT_FOUND);228 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));229 LOG.debug(mes.getDescription());230 throw new CerberusException(mes);231 }232 } catch (CerberusException ex) {233 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRY_NOT_FOUND);234 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));235 LOG.debug(mes.getDescription());236 throw new CerberusException(mes);237 }238 /**239 * Checking if execution is manual or automaticaly configured. If240 * Manual, CountryEnvironmentParameters object is manually created with241 * the servlet parameters. If automatic, parameters are build from the242 * CountryEnvironmentParameters. table in the database. Environmentdata243 * will always be filled with the environment. Environment will be244 * forced to MANUAL if execution is manual.245 *246 */247 LOG.debug("Checking if connectivity parameters are manual or automatic from the database. '" + tCExecution.isManualURL() + "'");248 if (tCExecution.isManualURL()) {249 LOG.debug("Execution will be done with manual application connectivity setting.");250 if (StringUtil.isNullOrEmpty(tCExecution.getMyHost())) {251 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_MANUALURL_INVALID);252 LOG.debug(mes.getDescription());253 throw new CerberusException(mes);254 } else {255 CountryEnvironmentParameters cea;256 cea = this.factorycountryEnvironmentParameters.create(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironment(), tCExecution.getApplicationObj().getApplication(), tCExecution.getMyHost(), "", tCExecution.getMyContextRoot(), tCExecution.getMyLoginRelativeURL(), "", "", "", "", CountryEnvironmentParameters.DEFAULT_POOLSIZE, "", "");257 cea.setIp(tCExecution.getMyHost());258 cea.setUrl(tCExecution.getMyContextRoot());259 String appURL = StringUtil.getURLFromString(cea.getIp(), cea.getUrl(), "", "");260 tCExecution.setUrl(appURL);261 // If domain is empty we guess it from URL.262 if (StringUtil.isNullOrEmpty(cea.getDomain())) {263 cea.setDomain(StringUtil.getDomainFromUrl(appURL));264 }265 cea.setUrlLogin(tCExecution.getMyLoginRelativeURL());266 tCExecution.setCountryEnvironmentParameters(cea);267 LOG.debug(" -> Execution will be done with manual application connectivity setting. IP/URL/LOGIN : " + cea.getIp() + "-" + cea.getUrl() + "-" + cea.getUrlLogin());268 LOG.debug(" Domain : " + cea.getDomain());269 }270 /**271 * If execution is manual, we force the env at 'MANUAL-ENVDATA'272 * string. We keep envData information in order to trace the env273 * data that has been used.274 */275 tCExecution.setEnvironment("MANUAL-" + tCExecution.getEnvironmentData());276 } else {277 /**278 * Automatic application configuration execution.279 */280 LOG.debug("Execution will be done with automatic application connectivity setting.");281 /**282 * Load Country/Environment/Application information and set them to283 * the TestCaseExecution object284 */285 LOG.debug("Loading Country/Environment/Application Information. " + tCExecution.getCountry() + "-" + tCExecution.getEnvironment() + "-" + tCExecution.getApplicationObj().getApplication());286 CountryEnvironmentParameters cea;287 try {288 cea = this.countryEnvironmentParametersService.convert(this.countryEnvironmentParametersService.readByKey(289 tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironment(), tCExecution.getApplicationObj().getApplication()));290 if (cea != null) {291 tCExecution.setUrl(StringUtil.getURLFromString(cea.getIp(), cea.getUrl(), "", ""));292 // add possibility to override URL with MyHost if MyHost is available293 if (!StringUtil.isNullOrEmpty(tCExecution.getMyHost())) {294 String contextRoot = !StringUtil.isNullOrEmpty(tCExecution.getMyContextRoot()) ? tCExecution.getMyContextRoot() : "";295 tCExecution.setUrl(StringUtil.getURLFromString(tCExecution.getMyHost(), contextRoot, "", ""));296 }297 if (!StringUtil.isNullOrEmpty(tCExecution.getMyLoginRelativeURL())) {298 cea.setUrlLogin(tCExecution.getMyLoginRelativeURL());299 }300 // If domain is empty we guess it from URL.301 if (StringUtil.isNullOrEmpty(cea.getDomain())) {302 cea.setDomain(StringUtil.getDomainFromUrl(tCExecution.getUrl()));303 }304 tCExecution.setCountryEnvironmentParameters(cea);305 } else {306 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENVAPP_NOT_FOUND);307 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));308 mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironment()));309 mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));310 LOG.error(mes.getDescription());311 throw new CerberusException(mes);312 }313 /**314 * Forcing the IP URL and Login config from DevIP, DevURL and315 * DevLogin parameter only if DevURL is defined.316 */317 } catch (CerberusException ex) {318 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENVAPP_NOT_FOUND);319 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));320 mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironment()));321 mes.setDescription(mes.getDescription().replace("%APPLI%", tCExecution.getTestCaseObj().getApplication()));322 LOG.error(mes.getDescription(), ex);323 throw new CerberusException(mes);324 }325 LOG.debug("Country/Environment/Application Information Loaded. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironment() + " - " + tCExecution.getApplicationObj().getApplication());326 LOG.debug(" -> Execution will be done with automatic application connectivity setting. IP/URL/LOGIN : " + cea.getIp() + "-" + cea.getUrl() + "-" + cea.getUrlLogin());327 LOG.debug(" Domain : " + cea.getDomain());328 tCExecution.setEnvironmentData(tCExecution.getEnvironment());329 }330 /**331 * Load Environment object from invariant table.332 */333 LOG.debug("Loading Environment Information. " + tCExecution.getEnvironmentData());334 try {335 tCExecution.setEnvironmentDataObj(invariantService.convert(invariantService.readByKey("ENVIRONMENT", tCExecution.getEnvironmentData())));336 } catch (CerberusException ex) {337 if (tCExecution.isManualURL()) {338 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_DOESNOTEXIST_MAN);339 mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));340 LOG.debug(mes.getDescription());341 throw new CerberusException(mes);342 } else {343 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_DOESNOTEXIST);344 mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));345 LOG.debug(mes.getDescription());346 throw new CerberusException(mes);347 }348 }349 LOG.debug("Environment Information Loaded");350 /**351 * Load Country/Environment information and set them to the352 * TestCaseExecution object. Environment considered here is the data353 * environment.354 */355 LOG.debug("Loading Country/Environment Information. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironmentData());356 CountryEnvParam countEnvParam;357 try {358 countEnvParam = this.countryEnvParamService.convert(this.countryEnvParamService.readByKey(tCExecution.getApplicationObj().getSystem(), tCExecution.getCountry(), tCExecution.getEnvironmentData()));359 tCExecution.setCountryEnvParam(countEnvParam);360 /**361 * Copy the Build/Revision of the environment to the Execution. This362 * is done to keep track of all execution done on a specific version363 * of system364 */365 tCExecution.setBuild(countEnvParam.getBuild());366 tCExecution.setRevision(countEnvParam.getRevision());367 } catch (CerberusException ex) {368 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRYENV_NOT_FOUND);369 mes.setDescription(mes.getDescription().replace("%SYSTEM%", tCExecution.getApplicationObj().getSystem()));370 mes.setDescription(mes.getDescription().replace("%COUNTRY%", tCExecution.getCountry()));371 mes.setDescription(mes.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));372 LOG.debug(mes.getDescription());373 throw new CerberusException(mes);374 }375 LOG.debug("Country/Environment Information Loaded. " + tCExecution.getCountry() + " - " + tCExecution.getEnvironmentData());376 // If Robot is feeded, we check it exist. If it exist, we overwrite the associated parameters.377 Robot robObj = null;378 RobotExecutor robExeObj = null;379 String robotHost = "";380 String robotPort = "";381 String browser = tCExecution.getBrowser();382 String robotDecli = "";383 String version = "";384 String platform = "";385 if (!StringUtil.isNullOrEmpty(tCExecution.getRobot())) {386 robObj = robotService.readByKey(tCExecution.getRobot());387 if (robObj == null) {388 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_ROBOTNOTEXIST)389 .resolveDescription("ROBOT", tCExecution.getRobot()));390 }391 // If Robot parameter is defined and we can find the robot, we overwrite the corresponding parameters.392 browser = ParameterParserUtil.parseStringParam(robObj.getBrowser(), browser);393 robotDecli = ParameterParserUtil.parseStringParam(robObj.getRobotDecli(), "");394 if (StringUtil.isNullOrEmpty(robotDecli)) {395 robotDecli = robObj.getRobot();396 }397 version = ParameterParserUtil.parseStringParam(robObj.getVersion(), version);398 platform = ParameterParserUtil.parseStringParam(robObj.getPlatform(), platform);399 tCExecution.setUserAgent(robObj.getUserAgent());400 tCExecution.setScreenSize(robObj.getScreenSize());401 tCExecution.setBrowser(browser);402 tCExecution.setRobotDecli(robotDecli);403 tCExecution.setVersion(version);404 tCExecution.setPlatform(platform);405 tCExecution.setRobotObj(robObj);406 // We cannot execute a testcase on a desactivated Robot.407 if ("N".equalsIgnoreCase(robObj.getActive())) {408 LOG.debug("Robot " + tCExecution.getRobot() + " is not active.");409 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_ROBOTNOTACTIVE)410 .resolveDescription("ROBOT", tCExecution.getRobot()));411 }412 // If executor is not set, we get the best one from the list.413 if (StringUtil.isNullOrEmpty(tCExecution.getRobotExecutor())) {414 LOG.debug("Getting the best Executor on Robot : " + tCExecution.getRobot());415 robExeObj = robotExecutorService.readBestByKey(tCExecution.getRobot());416 if (robExeObj != null) {417 tCExecution.setRobotExecutor(robExeObj.getExecutor());418 tCExecution.setRobotExecutorObj(robExeObj);419 robotExecutorService.updateLastExe(robExeObj.getRobot(), robExeObj.getExecutor());420 } else {421 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_ROBOTBESTEXECUTORNOTEXIST)422 .resolveDescription("ROBOT", tCExecution.getRobot())423 .resolveDescription("EXECUTOR", tCExecution.getRobotExecutor()));424 }425 LOG.debug(" Executor retreived : " + robExeObj.getExecutor());426 } else {427 LOG.debug(" Getting Requested Robot / Executor : " + tCExecution.getRobot() + " / " + tCExecution.getRobotExecutor());428 robExeObj = robotExecutorService.convert(robotExecutorService.readByKey(tCExecution.getRobot(), tCExecution.getRobotExecutor()));429 tCExecution.setRobotExecutorObj(robExeObj);430 if (robExeObj == null) {431 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_ROBOTEXECUTORNOTEXIST)432 .resolveDescription("ROBOT", tCExecution.getRobot())433 .resolveDescription("EXECUTOR", tCExecution.getRobotExecutor()));434 } else {435 // We cannot execute a testcase on a desactivated Robot.436 if ("N".equalsIgnoreCase(robExeObj.getActive())) {437 LOG.debug("Robot Executor " + tCExecution.getRobot() + " / " + tCExecution.getRobotExecutor() + " is not active.");438 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_ROBOTEXECUTORNOTACTIVE)439 .resolveDescription("ROBOT", tCExecution.getRobot())440 .resolveDescription("EXECUTOR", tCExecution.getRobotExecutor()));441 }442 }443 }444 robotHost = ParameterParserUtil.parseStringParam(robExeObj.getHost(), tCExecution.getRobotHost());445 robotPort = ParameterParserUtil.parseStringParam(String.valueOf(robExeObj.getPort()), tCExecution.getRobotPort());446 tCExecution.setRobotHost(robotHost);447 tCExecution.setRobotPort(robotPort);448 tCExecution.setSeleniumIP(robotHost);449 tCExecution.setSeleniumPort(robotPort);450 tCExecution.setSeleniumIPUser(robExeObj.getHostUser());451 tCExecution.setSeleniumIPPassword(robExeObj.getHostPassword());452 } else {453 tCExecution.setRobotDecli(browser);454 }455 /**456 * If Timeout is defined at the execution level, set action wait default457 * to this value, else Get the cerberus_action_wait_default parameter.458 * This parameter will be used by tha wait action if no timeout/event is459 * defined.460 */461 try {462 if (!tCExecution.getTimeout().isEmpty()) {463 tCExecution.setCerberus_action_wait_default(Integer.valueOf(tCExecution.getTimeout()));464 } else {465 tCExecution.setCerberus_action_wait_default(parameterService.getParameterIntegerByKey("cerberus_action_wait_default", tCExecution.getApplicationObj().getSystem(), 90000));466 }467 } catch (NumberFormatException ex) {468 LOG.warn("Parameter cerberus_action_wait_default must be an integer, default value set to 90000 milliseconds. " + ex.toString());469 tCExecution.setCerberus_action_wait_default(90000);470 }471 /**472 * Check if test can be executed TODO : Replace Message with try/catch473 * cerberus exception474 */475 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_VALIDATIONSTARTING));476 LOG.debug("Performing the Checks before starting the execution");477 MessageGeneral canExecuteTestCase = this.executionCheckService.checkTestCaseExecution(tCExecution);478 tCExecution.setResultMessage(canExecuteTestCase);479 /**480 * We stop if the result is not OK481 */482 if (!(tCExecution.getResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS)))) {483 return tCExecution;484 }485 LOG.debug("Checks performed -- > OK to continue.");486 /**487 * Changing Automatic execution flag depending on test case information.488 */489 if (tCExecution.getManualExecution().equals(TestCaseExecution.MANUAL_A)) {490 if (tCExecution.getTestCaseObj().getType().equals(TestCase.TESTCASE_TYPE_AUTOMATED)491 || tCExecution.getTestCaseObj().getType().equals(TestCase.TESTCASE_TYPE_PRIVATE)) {492 tCExecution.setManualExecution(TestCaseExecution.MANUAL_N);493 } else {494 tCExecution.setManualExecution(TestCaseExecution.MANUAL_Y);495 }496 }497 /**498 * For GUI application, check if Browser is supported.499 */500 if (!tCExecution.getManualExecution().equals("Y") && tCExecution.getAppTypeEngine().equalsIgnoreCase(Application.TYPE_GUI)) {501 try {502 myInvariant = invariantService.convert(invariantService.readByKey("BROWSER", tCExecution.getBrowser()));503 } catch (CerberusException ex) {504 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_BROWSER_NOT_SUPPORTED);505 mes.setDescription(mes.getDescription().replace("%BROWSER%", tCExecution.getBrowser()));506 LOG.debug(mes.getDescription());507 throw new CerberusException(mes);508 }509 }510 /**511 * Register RunID inside database.512 */513 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CREATINGRUNID));514 LOG.debug("Registering Execution ID on database");515 long runID = 0;516 try {517 runID = this.testCaseExecutionService.registerRunID(tCExecution);518 if (runID != 0) {519 tCExecution.setId(runID);...

Full Screen

Full Screen

Source:CreateRobot.java Github

copy

Full Screen

...73 JSONObject jsonResponse = new JSONObject();74 Answer ans = new Answer();75 Gson gson = new Gson();76 MessageEvent msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_UNEXPECTED);77 msg.setDescription(msg.getDescription().replace("%DESCRIPTION%", ""));78 ans.setResultMessage(msg);79 PolicyFactory policy = Sanitizers.FORMATTING.and(Sanitizers.LINKS);80 response.setContentType("application/json");81 String charset = request.getCharacterEncoding();82 /**83 * Parsing and securing all required parameters.84 */85 // Parameter that are already controled by GUI (no need to decode) --> We SECURE them86 // Parameter that needs to be secured --> We SECURE+DECODE them87 String robot = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robot"), null, charset);88 String port = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("port"), null, charset);89 String platform = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("platform"), null, charset);90 String browser = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("browser"), null, charset);91 String version = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("version"), "", charset);92 String active = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("active"), "Y", charset);93 String description = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("description"), "", charset);94 String userAgent = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("useragent"), "", charset);95 String screenSize = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("screensize"), "", charset);96 String robotDecli = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("robotDecli"), "", charset);97 String hostUser = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("hostUsername"), null, charset);98 String hostPassword = ParameterParserUtil.parseStringParamAndDecodeAndSanitize(request.getParameter("hostPassword"), null, charset);99 List<RobotCapability> capabilities = (List<RobotCapability>) (request.getParameter("capabilities") == null ? Collections.emptyList() : gson.fromJson(request.getParameter("capabilities"), new TypeToken<List<RobotCapability>>() {100 }.getType()));101 // Parameter that we cannot secure as we need the html --> We DECODE them102 String host = ParameterParserUtil.parseStringParamAndDecode(request.getParameter("host"), null, charset);103 // Securing capabilities by setting them the associated robot name104 // Check also if there is no duplicated capability105 Map<String, Object> capabilityMap = new HashMap<String, Object>();106 for (RobotCapability capability : capabilities) {107 capabilityMap.put(capability.getCapability(), null);108 capability.setRobot(robot);109 }110 Integer robotid = 0;111 boolean robotid_error = false;112 try {113 if (request.getParameter("robotid") != null && !request.getParameter("robotid").equals("")) {114 robotid = Integer.valueOf(policy.sanitize(request.getParameter("robotid")));115 }116 } catch (Exception ex) {117 robotid_error = true;118 }119 /**120 * Checking all constrains before calling the services.121 */122 if (StringUtil.isNullOrEmpty(robot)) {123 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);124 msg.setDescription(msg.getDescription().replace("%ITEM%", "Robot")125 .replace("%OPERATION%", "Create")126 .replace("%REASON%", "Robot name is missing."));127 ans.setResultMessage(msg);128 } else if (StringUtil.isNullOrEmpty(host)) {129 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);130 msg.setDescription(msg.getDescription().replace("%ITEM%", "Robot")131 .replace("%OPERATION%", "Create")132 .replace("%REASON%", "Robot host is missing."));133 ans.setResultMessage(msg);134 } else if (StringUtil.isNullOrEmpty(platform)) {135 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);136 msg.setDescription(msg.getDescription().replace("%ITEM%", "Robot")137 .replace("%OPERATION%", "Create")138 .replace("%REASON%", "Robot platform is missing."));139 ans.setResultMessage(msg);140 } else if (robotid_error) {141 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);142 msg.setDescription(msg.getDescription().replace("%ITEM%", "Robot")143 .replace("%OPERATION%", "Create")144 .replace("%REASON%", "Could not manage to convert robotid to an integer value or robotid is missing."));145 ans.setResultMessage(msg);146 } else if (capabilityMap.size() != capabilities.size()) {147 msg = new MessageEvent(MessageEventEnum.DATA_OPERATION_ERROR_EXPECTED);148 msg.setDescription(msg.getDescription().replace("%ITEM%", "Robot")149 .replace("%OPERATION%", "Create")150 .replace("%REASON%", "There is at least one duplicated capability. Please edit or remove it to continue."));151 ans.setResultMessage(msg);152 } else {153 /**154 * All data seems cleans so we can call the services.155 */156 ApplicationContext appContext = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext());157 IRobotService robotService = appContext.getBean(IRobotService.class);158 IFactoryRobot robotFactory = appContext.getBean(IFactoryRobot.class);159 Robot robotData = robotFactory.create(robotid, robot, host, port, platform, browser, version, active, description, userAgent, screenSize, hostUser, hostPassword, capabilities, robotDecli);160 ans = robotService.create(robotData);161 if (ans.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {162 /**...

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2public class Robot {3 private String name;4 private String description;5 public String getName() {6 return name;7 }8 public void setName(String name) {9 this.name = name;10 }11 public String getDescription() {12 return description;13 }14 public void setDescription(String description) {15 this.description = description;16 }17}18package org.cerberus.crud.entity;19public class Robot {20 private String name;21 private String description;22 public String getName() {23 return name;24 }25 public void setName(String name) {26 this.name = name;27 }28 public String getDescription() {29 return description;30 }31 public void setDescription(String description) {32 this.description = description;33 }34}35package org.cerberus.crud.entity;36public class Robot {37 private String name;38 private String description;39 public String getName() {40 return name;41 }42 public void setName(String name) {43 this.name = name;44 }45 public String getDescription() {46 return description;47 }48 public void setDescription(String description) {49 this.description = description;50 }51}52package org.cerberus.crud.entity;53public class Robot {54 private String name;55 private String description;56 public String getName() {57 return name;58 }59 public void setName(String name) {60 this.name = name;61 }62 public String getDescription() {63 return description;64 }65 public void setDescription(String description) {66 this.description = description;67 }68}69package org.cerberus.crud.entity;70public class Robot {71 private String name;72 private String description;73 public String getName() {74 return name;75 }76 public void setName(String name) {77 this.name = name;78 }79 public String getDescription() {80 return description;81 }

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2public class Robot {3 private String name;4 private String description;5 public Robot(String name, String description) {6 this.name = name;7 this.description = description;8 }9 public String getName() {10 return name;11 }12 public void setName(String name) {13 this.name = name;14 }15 public String getDescription() {16 return description;17 }18 public void setDescription(String description) {19 this.description = description;20 }21}22package org.cerberus.crud.entity;23public class Robot {24 private String name;25 private String description;26 public Robot(String name, String description) {27 this.name = name;28 this.description = description;29 }30 public String getName() {31 return name;32 }33 public void setName(String name) {34 this.name = name;35 }36 public String getDescription() {37 return description;38 }39 public void setDescription(String description) {40 this.description = description;41 }42}43package org.cerberus.crud.entity;44public class Robot {45 private String name;46 private String description;47 public Robot(String name, String description) {48 this.name = name;49 this.description = description;50 }51 public String getName() {52 return name;53 }54 public void setName(String name) {55 this.name = name;56 }57 public String getDescription() {58 return description;59 }60 public void setDescription(String description) {61 this.description = description;62 }63}64package org.cerberus.crud.entity;65public class Robot {66 private String name;67 private String description;68 public Robot(String name, String description) {69 this.name = name;70 this.description = description;71 }72 public String getName() {73 return name;74 }75 public void setName(String name) {76 this.name = name;77 }78 public String getDescription() {79 return description;80 }81 public void setDescription(String description) {82 this.description = description;83 }84}

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.Robot;3public class RobotTest {4 public static void main(String[] args) {5 Robot robot = new Robot();6 robot.setDescription("robot");7 System.out.println(robot.getDescription());8 }9}

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.Robot;2import org.cerberus.crud.service.IRobotService;3import org.springframework.context.ApplicationContext;4import org.springframework.context.support.ClassPathXmlApplicationContext;5public class 3 {6 public static void main(String[] args) {7 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");8 IRobotService robotService = appContext.getBean(IRobotService.class);9 Robot robot = robotService.findRobotByKey("robot1");10 robot.setDescription("description of robot1");11 robotService.updateRobot(robot);12 }13}14import org.cerberus.crud.entity.Robot;15import org.cerberus.crud.service.IRobotService;16import org.springframework.context.ApplicationContext;17import org.springframework.context.support.ClassPathXmlApplicationContext;18public class 4 {19 public static void main(String[] args) {20 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");21 IRobotService robotService = appContext.getBean(IRobotService.class);22 Robot robot = robotService.findRobotByKey("robot1");23 robot.setDescription("description of robot1");24 robotService.updateRobot(robot);25 }26}27import org.cerberus.crud.entity.Robot;28import org.cerberus.crud.service.IRobotService;29import org.springframework.context.ApplicationContext;30import org.springframework.context.support.ClassPathXmlApplicationContext;31public class 5 {32 public static void main(String[] args) {33 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");34 IRobotService robotService = appContext.getBean(IRobotService.class);35 Robot robot = robotService.findRobotByKey("robot1");36 robot.setDescription("description of robot1");37 robotService.updateRobot(robot);38 }39}40import org.cerberus.crud.entity.Robot;41import org.cerberus.crud.service.IRobot

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.io.Serializable;3import java.util.Date;4import java.util.List;5import org.cerberus.crud.entity.Robot;6import org.cerberus.crud.entity.TestCaseExecution;7import org.cerberus.crud.entity.TestCaseExecutionQueue;8import org.cerberus.crud.entity.TestCaseStepExecution;9public class Robot implements Serializable {10 private Integer id;11 private String robot;12 private String description;13 private String host;14 private String port;15 private String platform;16 private String browser;17 private String version;18 private String active;19 private String robotExecutor;20 private String robotDecli;21 private String robotIp;22 private String robotPort;23 private String robotPlatform;24 private String robotBrowser;25 private String robotBrowserVersion;26 private String robotBrowserSize;27 private String robotProxyHost;28 private String robotProxyPort;29 private String robotProxyCountry;30 private String robotProxyIp;31 private String robotProxyPort;32 private String robotProxyUser;33 private String robotProxyPassword;34 private String robotTimeout;35 private String robotPageSource;36 private String robotSeleniumLog;37 private String robotVNC;38 private String robotVNCPassword;39 private String robotVNCPort;40 private String robotVNCAddress;41 private String robotVNCKey;42 private String robotVNCKeyPassword;43 private String robotVNCKeyContent;44 private String robotVNCKeyContentPassword;45 private String robotScreenSize;46 private String robotScreenSizeHeight;47 private String robotScreenSizeWidth;48 private String robotScreenSizeDepth;49 private String robotScreenOrientation;50 private String robotCapabilities;51 private String robotCapabilitiesBrowserName;52 private String robotCapabilitiesVersion;53 private String robotCapabilitiesPlatform;54 private String robotCapabilitiesJavascriptEnabled;55 private String robotCapabilitiesCssSelectorsEnabled;56 private String robotCapabilitiesAcceptSslCerts;57 private String robotCapabilitiesAcceptInsecureCerts;58 private String robotCapabilitiesIgnoreZoomSetting;59 private String robotCapabilitiesEnablePersistentHover;60 private String robotCapabilitiesEnableElementCacheCleanup;61 private String robotCapabilitiesUnexpectedAlertBehaviour;62 private String robotCapabilitiesPageLoadStrategy;63 private String robotCapabilitiesSetWindowRect;64 private String robotCapabilitiesUnhandledPromptBehaviour;65 private String robotCapabilitiesProxy;

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package com.cerberus.crud;2import org.cerberus.crud.entity.Robot;3public class RobotClass {4 public static void main(String[] args) {5 Robot robot = new Robot();6 robot.setDescription("Cerberus");7 System.out.println(robot.getDescription());8 }9}

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.List;3import java.util.ArrayList;4public class Robot {5 private String name;6 private String description;7 private List<String> weapons;8 public Robot(String name, String description, List<String> weapons) {9 this.name = name;10 this.description = description;11 this.weapons = weapons;12 }13 public String getName() {14 return name;15 }16 public String getDescription() {17 return description;18 }19 public List<String> getWeapons() {20 return weapons;21 }22 public void setName(String name) {23 this.name = name;24 }25 public void setDescription(String description) {26 this.description = description;27 }28 public void setWeapons(List<String> weapons) {29 this.weapons = weapons;30 }31}32package org.cerberus.crud.entity;33import java.util.List;34import java.util.ArrayList;35public class Robot {36 private String name;37 private String description;38 private List<String> weapons;39 public Robot(String name, String description, List<String> weapons) {40 this.name = name;41 this.description = description;42 this.weapons = weapons;43 }44 public String getName() {45 return name;46 }47 public String getDescription() {48 return description;49 }50 public List<String> getWeapons() {51 return weapons;52 }53 public void setName(String name) {54 this.name = name;55 }56 public void setDescription(String description) {57 this.description = description;58 }59 public void setWeapons(List<String> weapons) {60 this.weapons = weapons;61 }62}63package org.cerberus.crud.entity;64import java.util.List;65import java.util.ArrayList;66public class Robot {67 private String name;68 private String description;69 private List<String> weapons;70 public Robot(String name, String description, List<String> weapons) {71 this.name = name;72 this.description = description;73 this.weapons = weapons;74 }75 public String getName() {76 return name;77 }78 public String getDescription() {79 return description;80 }

Full Screen

Full Screen

setDescription

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2public class Robot {3 private String description;4 public String getDescription() {5 return description;6 }7 public void setDescription(String description) {8 this.description = description;9 }10}11package org.cerberus.crud.entity;12public class Robot {13 private String description;14 public String getDescription() {15 return description;16 }17 public void setDescription(String description) {18 this.description = description;19 }20}21package org.cerberus.crud.entity;22public class Robot {23 private String description;24 public String getDescription() {25 return description;26 }27 public void setDescription(String description) {28 this.description = description;29 }30}31package org.cerberus.crud.entity;32public class Robot {33 private String description;34 public String getDescription() {35 return description;36 }37 public void setDescription(String description) {38 this.description = description;39 }40}41package org.cerberus.crud.entity;42public class Robot {43 private String description;44 public String getDescription() {45 return description;46 }47 public void setDescription(String description) {48 this.description = description;49 }50}51package org.cerberus.crud.entity;52public class Robot {53 private String description;54 public String getDescription() {55 return description;56 }57 public void setDescription(String description) {

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