How to use checkExecutorProxy method of org.cerberus.engine.execution.impl.ExecutionCheckService class

Best Cerberus-source code snippet using org.cerberus.engine.execution.impl.ExecutionCheckService.checkExecutorProxy

Source:ExecutionCheckService.java Github

copy

Full Screen

...60 // Manual application connectivity parameter61 if (this.checkTestCaseActive(tCExecution.getTestCaseObj())62 && this.checkTestActive(tCExecution.getTestObj())63 && this.checkCountry(tCExecution)64 && this.checkExecutorProxy(tCExecution)) {65 LOG.debug("Execution is checked and can proceed.");66 return new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS);67 }68 } else {69 // Automatic application connectivity parameter (from database) Correspond to manualURL = 1 or = 2 (override)70 if (this.checkEnvironmentActive(tCExecution.getCountryEnvParam())71 && this.checkRangeBuildRevision(72 tCExecution.getTestCaseObj(),73 tCExecution.getCountryEnvParam().getBuild(),74 tCExecution.getCountryEnvParam().getRevision(),75 tCExecution.getCountryEnvParam().getSystem())76 && this.checkTargetMajorRevision(tCExecution)77 && this.checkActiveEnvironmentGroup(tCExecution)78 && this.checkTestCaseActive(tCExecution.getTestCaseObj())79 && this.checkTestActive(tCExecution.getTestObj())80 && this.checkCountry(tCExecution)81 && this.checkMaintenanceTime(tCExecution)82 && this.checkExecutorProxy(tCExecution)) {83 LOG.debug("Execution is checked and can proceed.");84 return new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_CHECKINGPARAMETERS);85 }86 }87 return message;88 }89 private boolean checkEnvironmentActive(CountryEnvParam cep) {90 LOG.debug("Checking if environment is active");91 if (cep != null && cep.isActive()) {92 return true;93 }94 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_NOTACTIVE);95 return false;96 }97 private boolean checkTestCaseActive(TestCase testCase) {98 LOG.debug("Checking if testcase is active");99 if (testCase.isActive()) {100 return true;101 }102 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_NOTACTIVE);103 return false;104 }105 private boolean checkTestActive(Test test) {106 LOG.debug("Checking if test is active");107 if (test.getActive()) {108 return true;109 }110 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TEST_NOTACTIVE);111 message.setDescription(message.getDescription().replace("%TEST%", test.getTest()));112 return false;113 }114 private boolean checkTestCaseNotManual(TestCaseExecution tCExecution) {115 LOG.debug("Checking if testcase is not MANUAL");116 if (!tCExecution.getManualExecution().equals("Y") && tCExecution.getTestCaseObj().getType().equals("MANUAL")) {117 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TESTCASE_ISMANUAL);118 return false;119 }120 return true;121 }122 @Override123 public boolean checkRangeBuildRevision(TestCase tc, String envBuild, String envRevision, String envSystem) {124 LOG.debug("Checking if test can be executed in this build and revision");125 String tcFromMajor = ParameterParserUtil.parseStringParam(tc.getFromMajor(), "");126 String tcToMajor = ParameterParserUtil.parseStringParam(tc.getToMajor(), "");127 String tcFromMinor = ParameterParserUtil.parseStringParam(tc.getFromMinor(), "");128 String tcToMinor = ParameterParserUtil.parseStringParam(tc.getToMinor(), "");129 String sprint = ParameterParserUtil.parseStringParam(envBuild, "");130 String revision = ParameterParserUtil.parseStringParam(envRevision, "");131 int dif = -1;132 if (!tcFromMajor.isEmpty()) {133 try {134 if (sprint.isEmpty()) {135 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);136 return false;137 }138 dif = this.compareBuild(sprint, tcFromMajor, envSystem);139 if (dif == 0) {140 if (!tcFromMinor.isEmpty()) {141 if (revision.isEmpty()) {142 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);143 return false;144 } else if (this.compareRevision(revision, tcFromMinor, envSystem) < 0) {145 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);146 return false;147 }148 }149 } else if (dif < 0) {150 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);151 return false;152 }153 dif = this.compareBuild(tcToMajor, sprint, envSystem);154 if (dif == 0) {155 if (!tcToMinor.isEmpty()) {156 if (revision.isEmpty()) {157 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);158 return false;159 } else if (this.compareRevision(tcToMinor, revision, envSystem) < 0) {160 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);161 return false;162 }163 }164 } else if (dif < 0) {165 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_DIFFERENT);166 return false;167 }168 } catch (NumberFormatException exception) {169 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_WRONGFORMAT);170 return false;171 } catch (CerberusException ex) {172 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);173 return false;174 }175 }176 return true;177 }178 private boolean checkTargetMajorRevision(TestCaseExecution tCExecution) {179 LOG.debug("Checking target build");180 TestCase tc = tCExecution.getTestCaseObj();181 CountryEnvParam env = tCExecution.getCountryEnvParam();182 String tcTargetMajor = ParameterParserUtil.parseStringParam(tc.getTargetMajor(), "");183 String tcRevision = ParameterParserUtil.parseStringParam(tc.getTargetMinor(), "");184 String sprint = ParameterParserUtil.parseStringParam(env.getBuild(), "");185 String revision = ParameterParserUtil.parseStringParam(env.getRevision(), "");186 int dif = -1;187 if (!tcTargetMajor.isEmpty()) {188 try {189 if (sprint.isEmpty()) {190 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);191 return false;192 } else {193 dif = this.compareBuild(sprint, tcTargetMajor, env.getSystem());194 }195 if (dif == 0) {196 if (!tcRevision.isEmpty()) {197 if (revision.isEmpty()) {198 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_NOTDEFINED);199 return false;200 } else if (this.compareRevision(revision, tcRevision, env.getSystem()) < 0) {201 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);202 return false;203 }204 }205 } else if (dif < 0) {206 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_DIFFERENT);207 return false;208 }209 } catch (NumberFormatException exception) {210 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_TARGET_WRONGFORMAT);211 return false;212 } catch (CerberusException ex) {213 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED);214 return false;215 }216 }217 return true;218 }219 private boolean checkActiveEnvironmentGroup(TestCaseExecution tCExecution) {220 LOG.debug("Checking environment {}", tCExecution.getCountryEnvParam().getEnvironment());221 TestCase tc = tCExecution.getTestCaseObj();222 if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("QA")) {223 return this.checkIsActiveQA(tc, tCExecution.getEnvironmentData());224 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("UAT")) {225 return this.checkIsActiveUAT(tc, tCExecution.getEnvironmentData());226 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("PROD")) {227 return this.checkIsActivePROD(tc, tCExecution.getEnvironmentData());228 } else if (tCExecution.getEnvironmentDataObj().getGp1().equalsIgnoreCase("DEV")) {229 return true;230 }231 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_NOTDEFINED);232 message.setDescription(message.getDescription().replace("%ENV%", tCExecution.getEnvironmentData()));233 message.setDescription(message.getDescription().replace("%ENVGP%", tCExecution.getEnvironmentDataObj().getGp1()));234 return false;235 }236 private boolean checkIsActiveQA(TestCase tc, String env) {237 if (tc.isActiveQA()) {238 return true;239 }240 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ISACTIVEQA_NOTDEFINED);241 message.setDescription(message.getDescription().replace("%ENV%", env));242 return false;243 }244 private boolean checkIsActiveUAT(TestCase tc, String env) {245 if (tc.isActiveUAT()) {246 return true;247 }248 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ISACTIVEUAT_NOTDEFINED);249 message.setDescription(message.getDescription().replace("%ENV%", env));250 return false;251 }252 private boolean checkIsActivePROD(TestCase tc, String env) {253 if (tc.isActivePROD()) {254 return true;255 }256 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ISACTIVEPROD_NOTDEFINED);257 message.setDescription(message.getDescription().replace("%ENV%", env));258 return false;259 }260 private boolean checkCountry(TestCaseExecution tCExecution) {261 LOG.debug("Checking if country is setup for this testcase. {}-{}-{}", tCExecution.getTest(), tCExecution.getTestCase(), tCExecution.getCountry());262 if (testCaseCountryService.exist(tCExecution.getTest(), tCExecution.getTestCase(), tCExecution.getCountry())) {263 return true;264 } else {265 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_COUNTRY_NOTDEFINED);266 return false;267 }268 }269 private int compareBuild(String build1, String build2, String system) throws CerberusException {270 BuildRevisionInvariant b1;271 BuildRevisionInvariant b2;272 try {273 b1 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 1, build1));274 b2 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 1, build2));275 } catch (CerberusException e) {276 throw new NumberFormatException();277 }278 if (null == b1 || null == b2) {279 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_RANGE_ENVIRONMENT_BUILDREVISION_BADLYDEFINED));280 }281 return b1.getSeq().compareTo(b2.getSeq());282 }283 private int compareRevision(String rev1, String rev2, String system) {284 try {285 BuildRevisionInvariant r1 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 2, rev1));286 BuildRevisionInvariant r2 = buildRevisionInvariantService.convert(buildRevisionInvariantService.readByKey(system, 2, rev2));287 return r1.getSeq().compareTo(r2.getSeq());288 } catch (CerberusException e) {289 throw new NumberFormatException();290 }291 }292 private boolean checkMaintenanceTime(TestCaseExecution tCExecution) {293 if (tCExecution.getCountryEnvParam().isMaintenanceAct()) {294 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");295 String nowDate = sdf.format(new Date());296 try {297 long now = sdf.parse(nowDate).getTime();298 long startMaintenance = sdf.parse(nowDate).getTime();299 long endMaintenance = sdf.parse(nowDate).getTime();300 if (tCExecution.getCountryEnvParam() != null) {301 if (tCExecution.getCountryEnvParam().getMaintenanceStr() != null) {302 startMaintenance = sdf.parse(tCExecution.getCountryEnvParam().getMaintenanceStr()).getTime();303 }304 if (tCExecution.getCountryEnvParam().getMaintenanceStr() != null) {305 endMaintenance = sdf.parse(tCExecution.getCountryEnvParam().getMaintenanceEnd()).getTime();306 }307 }308 if (!(now >= startMaintenance && now <= endMaintenance)) {309 return true;310 }311 } catch (Exception exception) {312 LOG.error("Error when parsing maintenance start and/or end. {}{}{} {}{}{}",313 tCExecution.getCountryEnvParam().getSystem(), tCExecution.getCountryEnvParam().getCountry(), tCExecution.getCountryEnvParam().getEnvironment(),314 tCExecution.getCountryEnvParam().getMaintenanceStr(), tCExecution.getCountryEnvParam().getMaintenanceEnd(), exception.toString(), exception);315 }316 message = new MessageGeneral(MessageGeneralEnum.VALIDATION_FAILED_ENVIRONMENT_UNDER_MAINTENANCE);317 message.resolveDescription("START", tCExecution.getCountryEnvParam().getMaintenanceStr())318 .resolveDescription("END", tCExecution.getCountryEnvParam().getMaintenanceEnd())319 .resolveDescription("SYSTEM", tCExecution.getCountryEnvParam().getSystem())320 .resolveDescription("COUNTRY", tCExecution.getCountryEnvParam().getCountry())321 .resolveDescription("ENV", tCExecution.getCountryEnvParam().getEnvironment());322 return false;323 }324 return true;325 }326 private boolean checkExecutorProxy(TestCaseExecution tce) {327 //if executor proxy active, check cerberus-executor is available328 if (tce.getRobotExecutorObj() != null && "Y".equals(tce.getRobotExecutorObj().getExecutorProxyActive())) {329 //If ExecutorExtensionHost is null or empty, use the Robot Host330 if (tce.getRobotExecutorObj().getExecutorExtensionHost() == null || tce.getRobotExecutorObj().getExecutorExtensionHost().isEmpty()) {331 tce.getRobotExecutorObj().setExecutorExtensionHost(tce.getRobotExecutorObj().getHost());332 }333 String urlString = "http://" + tce.getRobotExecutorObj().getExecutorExtensionHost() + ":" + tce.getRobotExecutorObj().getExecutorExtensionPort() + "/check";334 LOG.debug("Url to check Proxy Executor : {}", urlString);335 URL url;336 try {337 url = new URL(urlString);338 URLConnection urlConn = url.openConnection();339 urlConn.setConnectTimeout(15000);340 urlConn.setReadTimeout(15000);...

Full Screen

Full Screen

checkExecutorProxy

Using AI Code Generation

copy

Full Screen

1package com.cerberus.example;2import java.io.IOException;3import java.util.Arrays;4import java.util.HashMap;5import java.util.List;6import java.util.Map;7import org.cerberus.engine.entity.MessageEvent;8import org.cerberus.engine.entity.MessageGeneral;9import org.cerberus.engine.entity.MessageGeneralEnum;10import org.cerberus.engine.entity.MessageGeneralFactory;11import org.cerberus.engine.execution.IExecutionCheckService;12import org.cerberus.engine.execution.impl.ExecutionCheckService;13import org.cerberus.engine.execution.impl.proxy.CheckExecutorProxy;14import org.cerberus.engine.execution.impl.proxy.CheckServiceProxy;15import org.cerberus.engine.execution.impl.proxy.CheckServiceProxyFactory;16import org.cerberus.engine.execution.impl.proxy.CheckServiceProxyFactoryImpl;17import org.cerberus.engine.execution.impl.proxy.CheckServiceProxyImpl;18import org.cerberus.engine.execution.impl.proxy.IProxyFactory;19import org.cerberus.engine.execution.impl.proxy.ProxyFactory;20import org.cerberus.engine.execution.impl.proxy.ProxyFactoryImpl;21import org.cerberus.engine.execution.impl.proxy.ProxyHandler;22import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl;23import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl2;24import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl3;25import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl4;26import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl5;27import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl6;28import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl7;29import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl8;30import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl9;31import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl10;32import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl11;33import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl12;34import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl13;35import org.cerberus.engine.execution.impl.proxy.ProxyHandlerImpl14;36import

Full Screen

Full Screen

checkExecutorProxy

Using AI Code Generation

copy

Full Screen

1import org.cerberus.engine.entity.MessageEvent;2import org.cerberus.engine.entity.MessageGeneral;3import org.cerberus.engine.execution.impl.ExecutionCheckService;4import org.cerberus.enums.MessageEventEnum;5import org.cerberus.util.answer.AnswerItem;6import org.cerberus.util.answer.AnswerUtil;7import org.cerberus.util.answer.IAnswerItem;8import org.cerberus.util.answer.IAnswerUtil;9import org.cerberus.engine.entity.ExecutionProxyCheck;10import org.cerberus.engine.entity.Session;11import org.cerberus.engine.execution.IExecutionCheck;12import org.cerberus.engine.execution.IExecutionCheckService;13import org.cerberus.engine.execution.IExecutionService;14import org.cerberus.engine.execution.impl.ExecutionService;15import org.cerberus.engine.execution.impl.ScreenshotService;16import org.cerberus.exception.CerberusEventException;17import org.cerberus.exception.CerberusException;18import org.cerberus.util.answer.Answer;19import org.cerberus.util.answer.AnswerUtil;20import org.cerberus.util.answer.IAnswer;21import org.cerberus.util.answer.IAnswerUtil;22import org.cerberus.engine.entity.MessageGeneral;23import org.cerberus.enums.MessageEventEnum;24import org.cerberus.engine.entity.ExecutionProxyCheck;25import org.cerberus.engine.entity.Session;26import org.cerberus.engine.execution.IExecutionCheck;27import org.cerberus.engine.execution.IExecutionCheckService;28import org.cerberus.engine.execution.IExecutionService;29import org.cerberus.engine.execution.impl.ExecutionService;30import org.cerberus.engine.execution.impl.ScreenshotService;31import org.cerberus.exception.CerberusEventException;32import org.cerberus.exception.CerberusException;33import org.cerberus.util.answer.Answer;34import org.cerberus.util.answer.AnswerUtil;35import org.cerberus.util.answer.IAnswer;36import org.cerberus.util.answer.IAnswerUtil;37import org.cerberus.engine.entity.MessageGeneral;38import org.cerberus.enums.MessageEventEnum;39import org.cerberus.engine.entity.ExecutionProxyCheck;40import org.cerberus.engine

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