Best Cerberus-source code snippet using org.cerberus.engine.queuemanagement.entity.TestCaseExecutionQueueToTreat.getEnvironment
Source:ExecutionThreadPoolService.java
...116 List<TestCaseExecutionQueueToTreat> executionsRunning = answer.getDataList();117 // Calculate constrain values.118 for (TestCaseExecutionQueueToTreat exe : executionsRunning) {119 String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;120 String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLIENV + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();121 String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_APPLICATION + CONST_SEPARATOR + exe.getApplication();122 String const04_key = TestCaseExecutionQueueToTreat.CONSTRAIN4_ROBOT + CONST_SEPARATOR + exe.getSelectedRobotHost();123 String const05_key = TestCaseExecutionQueueToTreat.CONSTRAIN5_EXECUTOREXTENSION + CONST_SEPARATOR + exe.getSelectedRobotExtensionHost();124 if (constrains_current.containsKey(const01_key)) {125 constrains_current.put(const01_key, constrains_current.get(const01_key) + 1);126 } else {127 constrains_current.put(const01_key, 1);128 }129 if (constrains_current.containsKey(const02_key)) {130 constrains_current.put(const02_key, constrains_current.get(const02_key) + 1);131 } else {132 constrains_current.put(const02_key, 1);133 }134 if (constrains_current.containsKey(const03_key)) {135 constrains_current.put(const03_key, constrains_current.get(const03_key) + 1);136 } else {137 constrains_current.put(const03_key, 1);138 }139 if (constrains_current.containsKey(const04_key)) {140 constrains_current.put(const04_key, constrains_current.get(const04_key) + 1);141 } else {142 constrains_current.put(const04_key, 1);143 }144 if (constrains_current.containsKey(const05_key)) {145 constrains_current.put(const05_key, constrains_current.get(const05_key) + 1);146 } else {147 constrains_current.put(const05_key, 1);148 }149 }150 return constrains_current;151 }152 @Override153 public HashMap<String, Integer> getCurrentlyPoolSizes() throws CerberusException {154 AnswerList<TestCaseExecutionQueueToTreat> answer = new AnswerList<>();155 HashMap<String, Integer> constrains_current = new HashMap<>();156 String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;157 int poolSizeGeneral = parameterService.getParameterIntegerByKey("cerberus_queueexecution_global_threadpoolsize", "", 12);158 int poolSizeRobot = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultrobothost_threadpoolsize", "", 10);159 int poolSizeExecutorExt = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultexecutorexthost_threadpoolsize", "", 2);160 constrains_current.put(const01_key, poolSizeGeneral);161 // Getting RobotHost PoolSize162 HashMap<String, Integer> robot_poolsize = new HashMap<String, Integer>();163 robot_poolsize = invariantService.readToHashMapGp1IntegerByIdname("ROBOTHOST", poolSizeRobot);164 HashMap<String, Integer> robotext_poolsize = new HashMap<String, Integer>();165 robotext_poolsize = invariantService.readToHashMapGp1IntegerByIdname("EXECUTOREXTENSIONHOST", poolSizeExecutorExt);166 // Getting all executions to be treated.167 answer = tceiqService.readQueueToTreatOrRunning();168 List<TestCaseExecutionQueueToTreat> executionsToTreat = answer.getDataList();169 // Calculate constrain values.170 for (TestCaseExecutionQueueToTreat exe : executionsToTreat) {171 String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLIENV + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();172 String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_APPLICATION + CONST_SEPARATOR + exe.getApplication();173 String const04_key = TestCaseExecutionQueueToTreat.CONSTRAIN4_ROBOT + CONST_SEPARATOR + exe.getSelectedRobotHost();174 String const05_key = TestCaseExecutionQueueToTreat.CONSTRAIN5_EXECUTOREXTENSION + CONST_SEPARATOR + exe.getSelectedRobotExtensionHost();175 constrains_current.put(const02_key, exe.getPoolSizeAppEnvironment());176 constrains_current.put(const03_key, exe.getPoolSizeApplication());177 // Getting Robot Host PoolSize from invariant hashmap.178 int robot_poolsize_final = 0;179 if (!StringUtil.isNullOrEmpty(exe.getSelectedRobotHost())) {180 if (robot_poolsize.containsKey(exe.getSelectedRobotHost())) {181 robot_poolsize_final = ParameterParserUtil.parseIntegerParam(robot_poolsize.get(exe.getSelectedRobotHost()), poolSizeRobot);182 } else {183 robot_poolsize_final = poolSizeRobot;184 }185 }186 constrains_current.put(const04_key, robot_poolsize_final);187 // Getting Robot Host PoolSize from invariant hashmap.188 int robotext_poolsize_final = 0;189 if (!StringUtil.isNullOrEmpty(exe.getSelectedRobotExtensionHost())) {190 if (robotext_poolsize.containsKey(exe.getSelectedRobotExtensionHost())) {191 robotext_poolsize_final = ParameterParserUtil.parseIntegerParam(robotext_poolsize.get(exe.getSelectedRobotExtensionHost()), poolSizeExecutorExt);192 } else {193 robotext_poolsize_final = poolSizeExecutorExt;194 }195 }196 constrains_current.put(const05_key, robotext_poolsize_final);197 }198 return constrains_current;199 }200 @Override201 public HashMap<String, Integer> getCurrentlyToTreat() throws CerberusException {202 AnswerList<TestCaseExecutionQueueToTreat> answer = new AnswerList<>();203 HashMap<String, Integer> constrains_current = new HashMap<String, Integer>();204 // Getting all executions to be treated.205 answer = tceiqService.readQueueToTreat();206 List<TestCaseExecutionQueueToTreat> executionsToTreat = answer.getDataList();207 // Calculate constrain values.208 for (TestCaseExecutionQueueToTreat exe : executionsToTreat) {209 String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;210 String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLIENV + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();211 String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_APPLICATION + CONST_SEPARATOR + exe.getApplication();212 String const04_key = TestCaseExecutionQueueToTreat.CONSTRAIN4_ROBOT + CONST_SEPARATOR + exe.getQueueRobotHost();213 String const05_key = TestCaseExecutionQueueToTreat.CONSTRAIN5_EXECUTOREXTENSION + CONST_SEPARATOR + "";214 if (constrains_current.containsKey(const01_key)) {215 constrains_current.put(const01_key, constrains_current.get(const01_key) + 1);216 } else {217 constrains_current.put(const01_key, 1);218 }219 if (constrains_current.containsKey(const02_key)) {220 constrains_current.put(const02_key, constrains_current.get(const02_key) + 1);221 } else {222 constrains_current.put(const02_key, 1);223 }224 if (constrains_current.containsKey(const03_key)) {225 constrains_current.put(const03_key, constrains_current.get(const03_key) + 1);226 } else {227 constrains_current.put(const03_key, 1);228 }229 if (constrains_current.containsKey(const04_key)) {230 constrains_current.put(const04_key, constrains_current.get(const04_key) + 1);231 } else {232 constrains_current.put(const04_key, 1);233 }234 }235 return constrains_current;236 }237 /**238 * {@inheritDoc}239 */240 @Override241 public void executeNextInQueue(boolean forceExecution) throws CerberusException {242 if (!isInstanceActive) {243 LOG.warn("Queue execution disable on that JVM instance.");244 return;245 }246 // Job can be desactivated by parameter.247 if (!(parameterService.getParameterBooleanByKey("cerberus_queueexecution_enable", "", true))) {248 LOG.debug("Queue_Processing_Job disabled by parameter : 'cerberus_queueexecution_enable'.");249 return;250 }251 // Flag in database that job is already running.252 if (myVersionService.flagMyVersionString("queueprocessingjobrunning") || forceExecution) {253 // Saving the timestamps when the job start in database.254 myVersionService.updateMyVersionString("queueprocessingjobstart", String.valueOf(new Date()));255 if (forceExecution) {256 LOG.debug("Forcing Start of Queue_Processing_Job.");257 }258 int nbqueuedexe = 0;259 // We try to submit new jobs until the job does not trigger any new execution.260 // In Other Words : As long as the job trigger new execution, we execute it.261 do {262 if (!(parameterService.getParameterBooleanByKey("cerberus_queueexecution_enable", "", true))) {263 LOG.debug("Queue_Processing_Job disabled by parameter : 'cerberus_queueexecution_enable'.");264 // Flag in database that job is finished.265 myVersionService.updateMyVersionString("queueprocessingjobrunning", "N");266 return;267 }268 nbqueuedexe = 0;269 // Job is not already running, we can trigger it.270 LOG.debug("Starting Queue_Processing_Job.");271 // Getting all executions to be treated.272 AnswerList<TestCaseExecutionQueueToTreat> answer = new AnswerList<>();273 answer = tceiqService.readQueueToTreat();274 List<TestCaseExecutionQueueToTreat> executionsInQueue = answer.getDataList();275 int poolSizeGeneral = 12;276 int poolSizeRobot = 10;277 int poolSizeExecutorExt = 2;278 int queueTimeout = 600000;279 // Init constrain counter (from list of already running execution.).280 int const01_current = 0;281 int const02_current = 0;282 int const03_current = 0;283 int const04_current = 0;284 int const05_current = 0;285 HashMap<String, Integer> constrains_current = new HashMap<>();286 HashMap<String, Integer> robothost_poolsize = new HashMap<>();287 HashMap<String, Integer> executorexthost_poolsize = new HashMap<>();288 HashMap<String, List<RobotExecutor>> robot_executor = new HashMap<>();289 HashMap<String, Robot> robot_header = new HashMap<>();290 poolSizeGeneral = parameterService.getParameterIntegerByKey("cerberus_queueexecution_global_threadpoolsize", "", 12);291 constrains_current = getCurrentlyRunning();292 LOG.debug("Current Constrains : " + constrains_current);293 if (!executionsInQueue.isEmpty()) {294 poolSizeRobot = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultrobothost_threadpoolsize", "", 10);295 poolSizeExecutorExt = parameterService.getParameterIntegerByKey("cerberus_queueexecution_defaultexecutorexthost_threadpoolsize", "", 2);296 queueTimeout = parameterService.getParameterIntegerByKey("cerberus_queueexecution_timeout", "", 600000);297 // Init constrain counter (from list of already running execution.).298 const01_current = 0;299 const02_current = 0;300 const03_current = 0;301 const04_current = 0;302 const05_current = 0;303 // Getting RobotHost PoolSize304 robothost_poolsize = invariantService.readToHashMapGp1IntegerByIdname("ROBOTHOST", poolSizeRobot);305 // Getting CerberusExecutorHost PoolSize306 executorexthost_poolsize = invariantService.readToHashMapGp1IntegerByIdname("EXECUTOREXTENSIONHOST", poolSizeExecutorExt);307 // Getting the list of robot in scope of the queue entries. This is to avoid getting all robots from database.308 LOG.debug("Getting List of Robot Executor.");309 for (TestCaseExecutionQueueToTreat exe : executionsInQueue) {310 if (!StringUtil.isNullOrEmpty(exe.getQueueRobot())) {311 robot_executor.put(exe.getQueueRobot(), new ArrayList<>());312 }313 }314 LOG.debug("List of Robot from Queue entries : " + robot_executor);315 robot_executor = robotExecutorService.getExecutorListFromRobotHash(robot_executor);316 LOG.debug("Robot Executor List : " + robot_executor);317 LOG.debug("Getting List of Robot (Header).");318 List<String> listRobotS = new ArrayList<>();319 for (Map.Entry<String, List<RobotExecutor>> entry : robot_executor.entrySet()) {320 String key = entry.getKey();321 listRobotS.add(key);322 }323 robot_header = robotService.readToHashMapByRobotList(listRobotS);324 LOG.debug("Robot Header List : " + robot_header);325 }326 String robot = "";327 String robotExecutor = "";328 String robotHost = "";329 String robotExtHost = "";330 String robotPort = "";331 String appType = "";332 List<RobotExecutor> tmpExelist = new ArrayList<>();333 List<RobotExecutor> newTmpExelist = new ArrayList<>();334 // Analysing each execution in the database queue.335 for (TestCaseExecutionQueueToTreat exe : executionsInQueue) {336 LOG.debug("Starting analysing : " + exe.getId());337 String notTriggeredExeMessage = "";338 boolean triggerExe = false;339 robot = exe.getQueueRobot();340 // Getting here the list of possible executor sorted by prio.341 List<RobotExecutor> robotExelist = new ArrayList<>();342 appType = exe.getAppType();343 if ((appType.equals(Application.TYPE_APK)) || (appType.equals(Application.TYPE_GUI)) || (appType.equals(Application.TYPE_FAT)) || (appType.equals(Application.TYPE_IPA))) {344 // Application require a robot so we can get the list of executors.345 if (StringUtil.isNullOrEmpty(robot)) {346 robotExelist = new ArrayList<>();347 robotExelist.add(factoryRobotExecutor.create(0, "", "", "Y", 1, exe.getQueueRobotHost(), exe.getQueueRobotPort(), "", "", "", "", null, "", "", 0, "", 0, "", "", "", null, "", null));348 } else {349 robotExelist = robot_executor.get(robot);350 if (robotExelist == null || robotExelist.size() < 1) {351 robotExelist = new ArrayList<>();352 robotExelist.add(factoryRobotExecutor.create(0, "", "", "Y", 1, "", "", "", "", "", "", null, "", "", 0, "", 0, "", "", "", null, "", null));353 }354 }355 } else {356 // Application does not require a robot so we create a fake one with empty data.357 robotExelist = new ArrayList<>();358 robotExelist.add(factoryRobotExecutor.create(0, "", "", "Y", 1, "", "", "", "", "", "", null, "", "", 0, "", 0, "", "", "", null, "", null));359 }360 // Looping other every potential executor on the corresponding robot.361 for (RobotExecutor robotExecutor1 : robotExelist) {362 if ("Y".equalsIgnoreCase(robotExecutor1.getExecutorProxyActive())) {363 robotExtHost = robotExecutor1.getExecutorExtensionHost();364 if (StringUtil.isNullOrEmpty(robotExtHost)) {365 robotExtHost = robotExecutor1.getHost();366 }367 } else {368 robotExtHost = "";369 }370 robotHost = robotExecutor1.getHost();371 robotPort = robotExecutor1.getPort();372 robotExecutor = robotExecutor1.getExecutor();373 LOG.debug("Trying with : " + robotHost + " Port : " + robotPort + " From Robot/Executor : " + robotExecutor1.getRobot() + "/" + robotExecutor1.getExecutor() + " Extension : " + robotExtHost);374 // RobotHost PoolSize if retreived from invariant hashmap.375 int robothost_poolsize_final = 0;376 if (!StringUtil.isNullOrEmpty(robotHost)) {377 if (robothost_poolsize.containsKey(robotHost)) {378 robothost_poolsize_final = ParameterParserUtil.parseIntegerParam(robothost_poolsize.get(robotHost), poolSizeRobot);379 } else {380 robothost_poolsize_final = poolSizeRobot;381 }382 }383 // RobotExtensionHost PoolSize if retreived from invariant hashmap.384 int robotexthost_poolsize_final = 0;385 if (!StringUtil.isNullOrEmpty(robotExtHost)) {386 if (executorexthost_poolsize.containsKey(robotExtHost)) {387 robotexthost_poolsize_final = ParameterParserUtil.parseIntegerParam(executorexthost_poolsize.get(robotExtHost), poolSizeExecutorExt);388 } else {389 robotexthost_poolsize_final = poolSizeExecutorExt;390 }391 }392 LOG.debug("Pool Values : poolGen " + poolSizeGeneral + " poolAppEnv " + exe.getPoolSizeAppEnvironment() + " poolApp " + exe.getPoolSizeApplication() + " poolRobotHost " + robothost_poolsize_final + " poolRobotExtHost " + robotexthost_poolsize_final);393 String const01_key = TestCaseExecutionQueueToTreat.CONSTRAIN1_GLOBAL;394 String const02_key = TestCaseExecutionQueueToTreat.CONSTRAIN2_APPLIENV + CONST_SEPARATOR + exe.getSystem() + CONST_SEPARATOR + exe.getEnvironment() + CONST_SEPARATOR + exe.getCountry() + CONST_SEPARATOR + exe.getApplication();395 String const03_key = TestCaseExecutionQueueToTreat.CONSTRAIN3_APPLICATION + CONST_SEPARATOR + exe.getApplication();396 String const04_key = TestCaseExecutionQueueToTreat.CONSTRAIN4_ROBOT + CONST_SEPARATOR + robotHost;397 String const05_key = TestCaseExecutionQueueToTreat.CONSTRAIN5_EXECUTOREXTENSION + CONST_SEPARATOR + robotExtHost;398 // Eval Constrain 1399 if (constrains_current.containsKey(const01_key)) {400 const01_current = constrains_current.get(const01_key);401 } else {402 const01_current = 0;403 }404 // Eval Constrain 1405 boolean constMatch01;406 if (poolSizeGeneral == 0) {407 // if poolsize == 0, this means no constrain specified.408 constMatch01 = false;...
Source:TestCaseExecutionQueueService.java
...177 if (ret.getItem() != null) {178 // Get the QueueId Result from inserted record.179 long insertedQueueId = ret.getItem().getId();180 // Adding dependencies181 AnswerItem<Integer> retDep = testCaseExecutionQueueDepService.insertFromTestCaseDep(insertedQueueId, object.getEnvironment(), object.getCountry(), object.getTag(), object.getTest(), object.getTestCase());182 LOG.debug("Dep inserted : " + retDep.getItem());183 if (retDep.getItem() < 1) {184 // In case there are no dependencies, we release the execution moving to targetState State185 updateToState(insertedQueueId, "", targetState);186 } else {187 // In case there is at least 1 dependency, we leave the state to QUWITHDEP but move the prio to high so that when dependencies are released execution is triggered ASAP.188 object.setPriority(TestCaseExecutionQueue.PRIORITY_WHENDEPENDENCY); // pass prio to 100 if it's a QUWITHDEP189 updatePriority(insertedQueueId, TestCaseExecutionQueue.PRIORITY_WHENDEPENDENCY);190 }191 }192 } else {193 // New execution Queue from an existing one (duplicated from an existing queue entry).194 object.setState(targetState);195 ret = testCaseExecutionInQueueDAO.create(object);196 // We duplicate here the dependencies from the original exeQueue entry.197 if (ret.getItem() != null) {198 // Get the QueueId Result from inserted record.199 long insertedQueueId = ret.getItem().getId();200 // Adding dependencies201 AnswerItem<Integer> retDep = testCaseExecutionQueueDepService.insertFromExeQueueIdDep(insertedQueueId, exeQueueId);202 LOG.debug("Dep inserted from old entries : " + retDep.getItem());203 }204 }205 }206 return ret;207 }208 @Override209 public void checkAndReleaseQueuedEntry(long exeQueueId, String tag) {210 LOG.debug("Checking if we can move QUWITHDEP Queue entry to QUEUED : " + exeQueueId);211 AnswerItem ansNbWaiting = testCaseExecutionQueueDepService.readNbWaitingByExeQueueId(exeQueueId);212 int nbwaiting = (int) ansNbWaiting.getItem();213 if (nbwaiting < 1) {214 // No more waiting dependencies.215 AnswerItem ansNbReleasedNOK = testCaseExecutionQueueDepService.readNbReleasedWithNOKByExeQueueId(exeQueueId);216 int nbReleasedNOK = (int) ansNbReleasedNOK.getItem();217 if (nbReleasedNOK <= 0) {218 // If all execution of RELEASED dep are OK, we update ExeQueue status from QUWITHDEP to QUEUED in order to allow queue entry to be executed.219 updateToQueuedFromQuWithDep(exeQueueId, "All Dependencies RELEASED.");220 } else {221 try {222 String notExecutedMessage = nbReleasedNOK + " RELEASED dependency(ies) not OK.";223 updateToErrorFromQuWithDep(exeQueueId, notExecutedMessage);224 testCaseExecutionQueueDepService.manageDependenciesEndOfQueueExecution(exeQueueId);225 tagService.manageCampaignEndOfExecution(tag);226 } catch (CerberusException ex) {227 LOG.error(ex.toString(), ex);228 }229 }230 }231 }232 @Override233 public Answer update(TestCaseExecutionQueue object) {234 return testCaseExecutionInQueueDAO.update(object);235 }236 @Override237 public Answer updatePriority(long id, int priority) {238 return testCaseExecutionInQueueDAO.updatePriority(id, priority);239 }240 @Override241 public Answer updateComment(long id, String comment) {242 return testCaseExecutionInQueueDAO.updateComment(id, comment);243 }244 @Override245 public Answer updateToState(long id, String comment, TestCaseExecutionQueue.State targetState) {246 return testCaseExecutionInQueueDAO.updateToState(id, comment, targetState);247 }248 @Override249 public Answer updateToQueued(long id, String comment) {250 return testCaseExecutionInQueueDAO.updateToQueued(id, comment);251 }252 @Override253 public Answer updateAllTagToQueuedFromQuTemp(String tag, List<Long> queueIds) {254 return testCaseExecutionInQueueDAO.updateAllTagToQueuedFromQuTemp(tag, queueIds);255 }256 @Override257 public Answer updateToQueuedFromQuWithDep(long id, String comment) {258 return testCaseExecutionInQueueDAO.updateToQueuedFromQuWithDep(id, comment);259 }260 @Override261 public boolean updateToWaiting(final Long id) throws CerberusException {262 return testCaseExecutionInQueueDAO.updateToWaiting(id);263 }264 @Override265 public void updateToStarting(long id, String selectedRobot, String selectedRobotExt) throws CerberusException {266 testCaseExecutionInQueueDAO.updateToStarting(id, selectedRobot, selectedRobotExt);267 }268 @Override269 public void updateToExecuting(long id, String comment, long exeId) throws CerberusException {270 testCaseExecutionInQueueDAO.updateToExecuting(id, comment, exeId);271 }272 @Override273 public void updateToError(long id, String comment) throws CerberusException {274 testCaseExecutionInQueueDAO.updateToError(id, comment);275 }276 @Override277 public void updateToErrorFromQuWithDep(long id, String comment) throws CerberusException {278 testCaseExecutionInQueueDAO.updateToErrorFromQuWithDep(id, comment);279 }280 @Override281 public void updateToDone(long id, String comment, long exeId) throws CerberusException {282 testCaseExecutionInQueueDAO.updateToDone(id, comment, exeId);283 }284 @Override285 public Answer updateToCancelled(long id, String comment) {286 return testCaseExecutionInQueueDAO.updateToCancelled(id, comment);287 }288 @Override289 public Answer updateToCancelledForce(long id, String comment) {290 return testCaseExecutionInQueueDAO.updateToCancelledForce(id, comment);291 }292 @Override293 public Answer updateToErrorForce(long id, String comment) {294 return testCaseExecutionInQueueDAO.updateToErrorForce(id, comment);295 }296 @Override297 public Answer delete(TestCaseExecutionQueue object) {298 return testCaseExecutionInQueueDAO.delete(object);299 }300 @Override301 public Answer delete(Long id) {302 return testCaseExecutionInQueueDAO.delete(id);303 }304 @Override305 public void cancelRunningOldQueueEntries() {306 /**307 * Automatic Cancellation job. That Job force to CANCELLED queue entries308 * that still in Executing state and too old to be still running.309 */310 Integer timeout = parameterService.getParameterIntegerByKey("cerberus_automaticqueuecancellationjob_timeout", "", 3600);311 testCaseExecutionInQueueDAO.updateToCancelledOldRecord(timeout, "Cancelled by automatic job.");312 }313 @Override314 public TestCaseExecutionQueue convert(AnswerItem<TestCaseExecutionQueue> answerItem) throws CerberusException {315 if (answerItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {316 //if the service returns an OK message then we can get the item317 return (TestCaseExecutionQueue) answerItem.getItem();318 }319 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));320 }321 @Override322 public List<TestCaseExecutionQueue> convert(AnswerList<TestCaseExecutionQueue> answerList) throws CerberusException {323 if (answerList.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {324 //if the service returns an OK message then we can get the item325 return (List<TestCaseExecutionQueue>) answerList.getDataList();326 }327 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));328 }329 @Override330 public void convert(Answer answer) throws CerberusException {331 if (answer.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode())) {332 //if the service returns an OK message then we can get the item333 return;334 }335 throw new CerberusException(new MessageGeneral(MessageGeneralEnum.DATA_OPERATION_ERROR));336 }337 @Override338 public TestCaseExecution convertToTestCaseExecution(TestCaseExecutionQueue testCaseExecutionInQueue) {339 String test = testCaseExecutionInQueue.getTest();340 String testCase = testCaseExecutionInQueue.getTestCase();341 String environment = testCaseExecutionInQueue.getEnvironment();342 String country = testCaseExecutionInQueue.getCountry();343 String browser = testCaseExecutionInQueue.getBrowser();344 String robotDecli = testCaseExecutionInQueue.getRobotDecli();345 if (StringUtil.isNullOrEmpty(robotDecli)) {346 if (!StringUtil.isNullOrEmpty(browser)) {347 robotDecli = browser;348 } else {349 robotDecli = "";350 }351 }352 String version = testCaseExecutionInQueue.getBrowserVersion();353 String platform = testCaseExecutionInQueue.getPlatform();354 long start = testCaseExecutionInQueue.getRequestDate() != null ? testCaseExecutionInQueue.getRequestDate().getTime() : 0;355 long end = 0;...
Source:TestCaseExecutionQueueToTreat.java
...83 }84 public void setSystem(String system) {85 this.system = system;86 }87 public String getEnvironment() {88 return environment;89 }90 public void setEnvironment(String environment) {91 this.environment = environment;92 }93 public String getCountry() {94 return country;95 }96 public void setCountry(String country) {97 this.country = country;98 }99 public String getApplication() {100 return application;101 }...
getEnvironment
Using AI Code Generation
1package org.cerberus.engine.queuemanagement.entity;2import org.cerberus.engine.entity.MessageGeneral;3import org.cerberus.engine.entity.MessageEvent;4import org.cerberus.engine.entity.MessageEventEnum;5import org.cerberus.crud.entity.TestCaseExecution;6import org.cerberus.crud.entity.TestCaseExecutionQueue;7import org.cerberus.crud.service.ITestCaseExecutionQueueService;8import org.cerberus.engine.queuemanagement.IQueueManagerService;9import org.cerberus.engine.queuemanagement.IQueueService;10import org.cerberus.exception.CerberusException;11import org.cerberus.log.MyLogger;12import org.cerberus.service.engine.IParameterService;13import org.cerberus.service.engine.IRecorderService;14import org.cerberus.service.engine.IPropertyService;15import org.cerberus.service.engine.IRecorderService;16import org.springframework.beans.factory.annotation.Autowired;17import org.springframework.context.ApplicationContext;18import org.springframework.stereotype.Service;19import java.util.ArrayList;20import java.util.List;21public class QueueManagerService implements IQueueManagerService {22 private ApplicationContext appContext;23 private ITestCaseExecutionQueueService testCaseExecutionQueueService;24 private IQueueService queueService;25 private IParameterService parameterService;26 private IPropertyService propertyService;27 private IRecorderService recorderService;28 private final String OBJECT_NAME = "TestCaseExecutionQueueToTreat";29 private static final org.apache.logging.log4j.Logger LOG = org.apache.logging.log4j.LogManager.getLogger(QueueManagerService.class);30 public List<TestCaseExecutionQueueToTreat> getEnvironment(String environment) throws CerberusException {31 return getEnvironment(environment, null);32 }33 public List<TestCaseExecutionQueueToTreat> getEnvironment(String environment, String country) throws CerberusException {34 List<TestCaseExecutionQueueToTreat> result = new ArrayList<TestCaseExecutionQueueToTreat>();35 List<TestCaseExecutionQueue> list = new ArrayList<TestCaseExecutionQueue>();36 try {37 list = testCaseExecutionQueueService.readByEnvCoutnry(environment, country);38 for (TestCaseExecutionQueue testCaseExecution
getEnvironment
Using AI Code Generation
1package org.cerberus.engine.queuemanagement.entity;2import org.cerberus.engine.entity.MessageEvent;3import org.cerberus.engine.entity.MessageGeneral;4import org.cerberus.engine.entity.MessageGeneralEnum;5import org.cerberus.engine.entity.SeleniumServer;6import org.cerberus.engine.execution.IExecution;7import org.cerberus.engine.execution.impl.Execution;8import org.cerberus.engine.queuemanagement.IQueueManagerService;9import org.cerberus.engine.queuemanagement.entity.TestCaseExecutionQueueToTreat;10import org.cerberus.engine.queuemanagement.impl.QueueManagerService;11import org.cerberus.engine.queuemanagement.impl.TestCaseExecutionQueueToTreatService;12import org.cerberus.engine.threadpool.IExecutionThreadPoolService;13import org.cerberus.engine.threadpool.impl.ExecutionThreadPoolService;14import org.cerberus.engine.threadpool.impl.ThreadPoolService;15import org.cerberus.enums.MessageEventEnum;16import org.cerberus.enums.MessageGeneralEnum;17import org.cerberus.exception.CerberusEventException;18import org.cerberus.util.answer.AnswerItem;19import java.util.ArrayList;20import java.util.HashMap;21import java.util.List;22import java.util.Map;23public class TestCaseExecutionQueueToTreatService {24 private static final org.apache.logging.log4j.Logger LOG = org.apache.logging.log4j.LogManager.getLogger(TestCaseExecutionQueueToTreatService.class);25 private IExecutionThreadPoolService executionThreadPoolService;26 private IQueueManagerService queueManagerService;27 public TestCaseExecutionQueueToTreatService() {28 executionThreadPoolService = new ExecutionThreadPoolService();29 queueManagerService = new QueueManagerService();30 }31 public TestCaseExecutionQueueToTreatService(IExecutionThreadPoolService executionThreadPoolService, IQueueManagerService queueManagerService) {32 this.executionThreadPoolService = executionThreadPoolService;33 this.queueManagerService = queueManagerService;34 }35 public AnswerItem<TestCaseExecutionQueueToTreat> getEnvironment(TestCaseExecutionQueueToTreat testCaseExecutionQueueToTreat) {36 AnswerItem<TestCaseExecutionQueueToTreat> answer = new AnswerItem<>();37 MessageEvent msg = new MessageEvent(MessageEventEnum.PROPERTY_SUCCESS_GETENVIRONMENT);38 msg.setDescription(msg.getDescription().replace("%ENV%", testCaseExecutionQueueToTreat.getEnvironment()));
getEnvironment
Using AI Code Generation
1package org.cerberus.engine.queuemanagement.entity;2import org.cerberus.engine.entity.MessageGeneral;3import org.cerberus.engine.entity.MessageEvent;4import org.cerberus.engine.entity.MessageEventEnum;5import java.util.List;6import java.util.Map;7import java.util.logging.Level;8import java.util.logging.Logger;9import org.cerberus.engine.entity.MessageGeneralEnum;10import org.cerberus.engine.execution.IExecutionHandler;11import org.cerberus.engine.execution.IExecutionThreadPool;12import org.cerberus.engine.execution.impl.ExecutionThreadPool;13import org.cerberus.engine.queuemanagement.IQueueManagerService;14import org.cerberus.engine.queuemanagement.IQueueService;15import org.cerberus.engine.queuemanagement.entity.TestCaseExecutionQueueToTreat;16import org.cerberus.engine.queuemanagement.impl.QueueManagerService;17import org.cerberus.engine.queuemanagement.impl.QueueService;18import org.cerberus.exception.CerberusException;19import org.cerberus.util.answer.AnswerItem;20import org.springframework.beans.factory.annotation.Autowired;21import org.springframework.stereotype.Service;22public class GetEnvironment {23 IQueueService queueService;24 IQueueManagerService queueManagerService;25 IExecutionThreadPool executionThreadPool;26 public MessageGeneral getEnvironment() {27 MessageGeneral result = new MessageGeneral(MessageGeneralEnum.EXECUTION_PEFORMED);28 try {29 AnswerItem<TestCaseExecutionQueueToTreat> answerItem = queueManagerService.getTestCaseExecutionInQueueToTreat();30 if (answerItem.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && (answerItem.getItem() != null)) {31 TestCaseExecutionQueueToTreat testCaseExecutionQueueToTreat = answerItem.getItem();32 IExecutionHandler executionHandler = executionThreadPool.getExecutionHandler(testCaseExecutionQueueToTreat.getId());33 if (executionHandler != null) {34 Map<String, String> environment = executionHandler.getEnvironment();35 if (environment != null) {36 result.setResultString(environment
getEnvironment
Using AI Code Generation
1package org.cerberus.engine.queuemanagement.entity;2import org.cerberus.engine.entity.MessageEvent;3public class TestCaseExecutionQueueToTreat {4 private TestCaseExecutionQueue testCaseExecutionQueue;5 private MessageEvent message;6 public TestCaseExecutionQueueToTreat(TestCaseExecutionQueue testCaseExecutionQueue) {7 this.testCaseExecutionQueue = testCaseExecutionQueue;8 }9 public TestCaseExecutionQueue getTestCaseExecutionQueue() {10 return testCaseExecutionQueue;11 }12 public void setTestCaseExecutionQueue(TestCaseExecutionQueue testCaseExecutionQueue) {13 this.testCaseExecutionQueue = testCaseExecutionQueue;14 }15 public MessageEvent getMessage() {16 return message;17 }18 public void setMessage(MessageEvent message) {19 this.message = message;20 }21}22package org.cerberus.engine.queuemanagement.entity;23import org.cerberus.engine.entity.MessageEvent;24public class TestCaseExecutionQueueToTreat {25 private TestCaseExecutionQueue testCaseExecutionQueue;26 private MessageEvent message;27 public TestCaseExecutionQueueToTreat(TestCaseExecutionQueue testCaseExecutionQueue) {28 this.testCaseExecutionQueue = testCaseExecutionQueue;29 }30 public TestCaseExecutionQueue getTestCaseExecutionQueue() {31 return testCaseExecutionQueue;32 }33 public void setTestCaseExecutionQueue(TestCaseExecutionQueue testCaseExecutionQueue) {34 this.testCaseExecutionQueue = testCaseExecutionQueue;35 }36 public MessageEvent getMessage() {37 return message;38 }39 public void setMessage(MessageEvent message) {40 this.message = message;41 }42}43package org.cerberus.engine.queuemanagement.entity;44import org.cerberus.engine.entity.MessageEvent;45public class TestCaseExecutionQueueToTreat {46 private TestCaseExecutionQueue testCaseExecutionQueue;47 private MessageEvent message;48 public TestCaseExecutionQueueToTreat(TestCaseExecutionQueue testCaseExecutionQueue) {49 this.testCaseExecutionQueue = testCaseExecutionQueue;50 }51 public TestCaseExecutionQueue getTestCaseExecutionQueue() {52 return testCaseExecutionQueue;53 }54 public void setTestCaseExecutionQueue(TestCaseExecutionQueue testCaseExecutionQueue) {
getEnvironment
Using AI Code Generation
1package org.cerberus.engine.queuemanagement.entity;2import org.cerberus.engine.entity.MessageGeneral;3public class TestCaseExecutionQueueToTreat extends TestCaseExecutionQueue {4 private String environment;5 public TestCaseExecutionQueueToTreat() {6 }7 public TestCaseExecutionQueueToTreat(String environment) {8 this.environment = environment;9 }10 public TestCaseExecutionQueueToTreat(String environment, String test, String testCase, String country, String environmentData, String browser, String browserVersion, String platform, String screenSize, String tag, String outputFormat, String verbose, String screenshot, String pageSource, String seleniumLog, String timeout, String retries, String manualURL, String manualExecution, String priority, String state, String usrCreated, String dateCreated, String usrModif, String dateModif, String usrId, String usrPwd, String usrTeam, String usrEmail, String usrPhone, String usrMobile, String usrToken, String usrLanguage, MessageGeneral message) {11 super(test, testCase, country, environmentData, browser, browserVersion, platform, screenSize, tag, outputFormat, verbose, screenshot, pageSource, seleniumLog, timeout, retries, manualURL, manualExecution, priority, state, usrCreated, dateCreated, usrModif, dateModif, usrId, usrPwd, usrTeam, usrEmail, usrPhone, usrMobile, usrToken, usrLanguage, message);12 this.environment = environment;13 }14 public String getEnvironment() {15 return environment;16 }17 public void setEnvironment(String environment) {18 this.environment = environment;19 }20}21package org.cerberus.engine.queuemanagement.entity;22import org.cerberus.engine.entity.MessageGeneral;23public class TestCaseExecutionQueueToTreat extends TestCaseExecutionQueue {24 private String environment;25 public TestCaseExecutionQueueToTreat() {26 }27 public TestCaseExecutionQueueToTreat(String environment) {28 this.environment = environment;29 }30 public TestCaseExecutionQueueToTreat(String environment, String test, String testCase, String country, String environmentData,
getEnvironment
Using AI Code Generation
1String environment = testCaseExecutionQueueToTreat.getEnvironment();2System.out.println(environment);3String testCaseToExecute = testCaseExecutionQueueToTreat.getTestCaseToExecute();4System.out.println(testCaseToExecute);5String country = testCaseExecutionQueueToTreat.getCountry();6System.out.println(country);7String robotExecutor = testCaseExecutionQueueToTreat.getRobotExecutor();8System.out.println(robotExecutor);9String robotHost = testCaseExecutionQueueToTreat.getRobotHost();10System.out.println(robotHost);
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!!