How to use getReturnMessage method of org.cerberus.crud.entity.TestCaseStepActionExecution class

Best Cerberus-source code snippet using org.cerberus.crud.entity.TestCaseStepActionExecution.getReturnMessage

Source:ExecutionRunService.java Github

copy

Full Screen

...518 LOG.debug("Registering Step : " + testCaseStepExecution.getStep());519 // We change the Step message only if the Step is not executed due to condition.520 MessageEvent stepMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_NOTEXECUTED);521 testCaseStepExecution.setStepResultMessage(stepMes);522 testCaseStepExecution.setReturnMessage(testCaseStepExecution.getReturnMessage()523 .replace("%COND%", testCaseStepExecution.getConditionOper())524 .replace("%LOOP%", testCaseStepExecution.getLoop())525 .replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription())526 );527 testCaseStepExecution.setEnd(new Date().getTime());528 this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);529 LOG.debug("Registered Step");530 } else {531 // Not executed because decode error or failed condition.532 testCaseStepExecution.setEnd(new Date().getTime());533 testCaseStepExecution.setStopExecution(true);534 this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);535 LOG.debug("Registered Step");536 }537 /**538 * Log TestCaseStepExecution539 */540 if (tCExecution.getVerbose() > 0) {541 LOG.info(testCaseStepExecution.toJson(false, true));542 }543 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.544 if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {545 TestCaseExecutionEndPoint.getInstance().send(tCExecution, false);546 }547 step_index++;548 } while (execute_Next_Step && step_index <= maxloop);549 if (testCaseStepExecution.isStopExecution()) {550 break;551 }552 }553 /**554 * If at that time the execution is still PE, we move it to555 * OK. It means that no issue were met.556 */557 if ((tCExecution.getResultMessage() == null) || (tCExecution.getResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTSTARTED)))) {558 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK));559 }560 /**561 * We record Selenium log at the end of the execution.562 */563 try {564 tCExecution.addFileList(recorderService.recordSeleniumLog(tCExecution));565 } catch (Exception ex) {566 LOG.error(logPrefix + "Exception Getting Selenium Logs " + tCExecution.getId() + " Exception :" + ex.toString());567 }568 } else { // We don't execute the testcase linked with condition.569 MessageGeneral mes;570 /**571 * Update Execution status from condition572 */573 if (conditionAnswerTc.getResultMessage().getMessage().getCodeString().equals("PE")) {574 mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_NA_CONDITION);575 } else {576 mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);577 }578 mes.setDescription(mes.getDescription().replace("%COND%", tCExecution.getConditionOper())579 .replace("%MES%", conditionAnswerTc.getResultMessage().getDescription()));580 tCExecution.setResultMessage(mes);581 }582 }583 } catch (Exception ex) {584 /**585 * If an exception is found, set the execution to FA and print the586 * exception587 */588 tCExecution.setResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_FA));589 tCExecution.setControlMessage(tCExecution.getControlMessage() + " Exception: " + ex);590 LOG.error(logPrefix + "Exception found Executing Test " + tCExecution.getId() + " Exception :" + ex.toString());591 } finally {592 /**593 * We stop the server session here (selenium for ex.).594 */595 try {596 tCExecution = this.stopTestCase(tCExecution);597 } catch (Exception ex) {598 LOG.error(logPrefix + "Exception Stopping Test " + tCExecution.getId() + " Exception :" + ex.toString());599 }600 /**601 * Log Execution602 */603 LOG.info(tCExecution.toJson(false));604 /**605 * Clean memory606 */607 try {608 executionUUID.removeExecutionUUID(tCExecution.getExecutionUUID());609 LOG.debug("Clean ExecutionUUID");610 } catch (Exception ex) {611 LOG.error("Exception cleaning Memory: " + ex.toString());612 }613 /**614 * Log execution is finished615 */616 LOG.info("Execution Finished : UUID=" + tCExecution.getExecutionUUID()617 + "__ID=" + tCExecution.getId() + "__RC=" + tCExecution.getControlStatus() + "__"618 + "TestName=" + tCExecution.getEnvironment() + "." + tCExecution.getCountry() + "."619 + tCExecution.getBuild() + "." + tCExecution.getRevision() + "." + tCExecution.getTest() + "_"620 + tCExecution.getTestCase() + "_" + tCExecution.getTestCaseObj().getDescription().replace(".", ""));621 /**622 * Updating queue to done status only for execution from queue623 */624 if (tCExecution.getQueueID() != 0) {625 executionQueueService.updateToDone(tCExecution.getQueueID(), "", runID);626 }627 /**628 * Retry management, in case the result is not (OK or NE), we629 * execute the job again reducing the retry to 1.630 */631 if (tCExecution.getNumberOfRetries() > 0632 && !tCExecution.getResultMessage().getCodeString().equals("OK")633 && !tCExecution.getResultMessage().getCodeString().equals("NE")) {634 TestCaseExecutionQueue newExeQueue = new TestCaseExecutionQueue();635 if (tCExecution.getQueueID() > 0) {636 // If QueueId exist, we try to get the original execution queue.637 try {638 newExeQueue = executionQueueService.convert(executionQueueService.readByKey(tCExecution.getQueueID()));639 } catch (Exception e) {640 // Unfortunatly the execution no longuer exist so we pick initial value.641 newExeQueue = tCExecution.getTestCaseExecutionQueue();642 }643 } else {644 // Initial Execution does not come from the queue so we pick the value created at the beginning of the execution.645 newExeQueue = tCExecution.getTestCaseExecutionQueue();646 }647 // Forcing init value for that new queue execution : exeid=0, no debugflag and State = QUEUED648 int newRetry = tCExecution.getNumberOfRetries() - 1;649 newExeQueue.setId(0);650 newExeQueue.setDebugFlag("N");651 if (newRetry <= 0) {652 newExeQueue.setComment("Added from Retry. Last attempt to go.");653 } else {654 newExeQueue.setComment("Added from Retry. Still " + newRetry + " attempt(s) to go.");655 }656 newExeQueue.setState(TestCaseExecutionQueue.State.QUEUED);657 newExeQueue.setRetries(newRetry);658 // Insert execution to the Queue.659 executionQueueService.create(newExeQueue);660 }661 /**662 * After every execution finished, <br>663 * if the execution has a tag that has a campaign associated <br>664 * and no more executions are in the queue, <br>665 * we trigger : <br>666 * 1/ The update of the EndExeQueue of the tag <br>667 * 2/ We notify the Distribution List with execution report status668 */669 try {670 if (!StringUtil.isNullOrEmpty(tCExecution.getTag())) {671 Tag currentTag = tagService.convert(tagService.readByKey(tCExecution.getTag()));672 if ((currentTag != null)) {673 if (currentTag.getDateEndQueue().before(Timestamp.valueOf("1980-01-01 01:01:01.000000001"))) {674 AnswerList answerListQueue = new AnswerList();675 answerListQueue = executionQueueService.readQueueOpen(tCExecution.getTag());676 if (answerListQueue.isCodeEquals(MessageEventEnum.DATA_OPERATION_OK.getCode()) && (answerListQueue.getDataList().isEmpty())) {677 LOG.debug("No More executions in (queue) on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString() + " - ");678 tagService.updateDateEndQueue(tCExecution.getTag(), new Timestamp(new Date().getTime()));679 if (!StringUtil.isNullOrEmpty(currentTag.getCampaign())) {680 // We get the campaig here and potencially send the notification.681 emailService.generateAndSendNotifyEndTagExecution(tCExecution.getTag(), currentTag.getCampaign());682 }683 } else {684 LOG.debug("Still executions in queue on tag : " + tCExecution.getTag() + " - " + answerListQueue.getDataList().size() + " " + answerListQueue.getMessageCodeString());685 }686 } else {687 LOG.debug("Tag is already flaged with recent timstamp. " + currentTag.getDateEndQueue());688 }689 }690 }691 } catch (Exception e) {692 LOG.error(e);693 }694 //695 // After every execution finished we try to trigger more from the queue;-).696 executionThreadPoolService.executeNextInQueueAsynchroneously(false);697 }698 return tCExecution;699 }700 @Override701 public TestCaseExecution stopTestCase(TestCaseExecution tCExecution) {702 /**703 * Stop Execution704 */705 LOG.debug(tCExecution.getId() + " - Stop the execution " + tCExecution.getId() + " UUID:" + tCExecution.getExecutionUUID());706 try {707 //TODO:FN debug messages to be removed708 LOG.debug("[DEBUG] STOP " + "__ID=" + tCExecution.getId());709 this.stopRunTestCase(tCExecution);710 } catch (Exception ex) {711 LOG.warn("Exception Stopping Execution " + tCExecution.getId() + " Exception :" + ex.toString());712 }713 /**714 * Collecting and calculating Statistics.715 */716 try {717// this.collectExecutionStats(tCExecution);718 } catch (Exception ex) {719 LOG.warn("Exception collecting stats for execution " + tCExecution.getId() + " Exception:" + ex.toString());720 }721 /**722 * Saving TestCaseExecution object.723 */724 tCExecution.setEnd(new Date().getTime());725 try {726 testCaseExecutionService.updateTCExecution(tCExecution);727 } catch (CerberusException ex) {728 LOG.warn("Exception updating Execution :" + tCExecution.getId() + " Exception:" + ex.toString());729 }730 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.731 if (tCExecution.isCerberus_featureflipping_activatewebsocketpush()) {732 TestCaseExecutionEndPoint.getInstance().send(tCExecution, true);733 TestCaseExecutionEndPoint.getInstance().end(tCExecution);734 }735 return tCExecution;736 }737 private TestCaseStepExecution executeStep(TestCaseStepExecution testCaseStepExecution, TestCaseExecution tcExecution) {738 long runID = testCaseStepExecution.getId();739 String logPrefix = runID + " - ";740 AnswerItem<String> answerDecode = new AnswerItem();741 // Initialise the Step Data List.742 List<TestCaseExecutionData> myStepDataList = new ArrayList<TestCaseExecutionData>();743 testCaseStepExecution.setTestCaseExecutionDataList(myStepDataList);744 // Initialise the Data List used to enter the action.745 /**746 * Iterate Actions747 */748 List<TestCaseStepAction> testCaseStepActionList = testCaseStepExecution.getTestCaseStep().getTestCaseStepAction();749 LOG.debug("Getting list of actions of the step. " + testCaseStepActionList.size() + " action(s) to perform.");750 for (TestCaseStepAction testCaseStepAction : testCaseStepActionList) {751 /**752 * Start Execution of TestCaseStepAction753 */754 long startAction = new Date().getTime();755 /**756 * Create and Register TestCaseStepActionExecution.757 */758 TestCaseStepActionExecution testCaseStepActionExecution = factoryTestCaseStepActionExecution.create(759 testCaseStepExecution.getId(), testCaseStepAction.getTest(), testCaseStepAction.getTestCase(),760 testCaseStepAction.getStep(), testCaseStepExecution.getIndex(), testCaseStepAction.getSequence(), testCaseStepAction.getSort(), null, null,761 testCaseStepAction.getConditionOper(), testCaseStepAction.getConditionVal1(), testCaseStepAction.getConditionVal2(), testCaseStepAction.getConditionVal1(), testCaseStepAction.getConditionVal2(),762 testCaseStepAction.getAction(), testCaseStepAction.getValue1(), testCaseStepAction.getValue2(), testCaseStepAction.getValue1(), testCaseStepAction.getValue2(),763 testCaseStepAction.getForceExeStatus(), startAction, 0, startAction, 0, new MessageEvent(MessageEventEnum.ACTION_PENDING),764 testCaseStepAction.getDescription(), testCaseStepAction, testCaseStepExecution);765 this.testCaseStepActionExecutionService.insertTestCaseStepActionExecution(testCaseStepActionExecution);766 /**767 * We populate the TestCase Action List768 */769 testCaseStepExecution.addTestCaseStepActionExecutionList(testCaseStepActionExecution);770 /**771 * If execution is not manual, evaluate the condition at the action772 * level773 */774 AnswerItem<Boolean> conditionAnswer;775 boolean conditionDecodeError = false;776 if (!tcExecution.getManualExecution().equals("Y")) {777 try {778 answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getConditionVal1(), tcExecution, null, false);779 testCaseStepActionExecution.setConditionVal1((String) answerDecode.getItem());780 if (!(answerDecode.isCodeStringEquals("OK"))) {781 // If anything wrong with the decode --> we stop here with decode message in the action result.782 testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Condition Value1"));783 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));784 testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());785 testCaseStepActionExecution.setEnd(new Date().getTime());786 LOG.debug("Action interupted due to decode 'Action Condition Value1' Error.");787 conditionDecodeError = true;788 }789 } catch (CerberusEventException cex) {790 LOG.warn(cex);791 }792 try {793 answerDecode = variableService.decodeStringCompletly(testCaseStepActionExecution.getConditionVal2(), tcExecution, null, false);794 testCaseStepActionExecution.setConditionVal2((String) answerDecode.getItem());795 if (!(answerDecode.isCodeStringEquals("OK"))) {796 // If anything wrong with the decode --> we stop here with decode message in the action result.797 testCaseStepActionExecution.setActionResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Action Condition Value2"));798 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));799 testCaseStepActionExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());800 testCaseStepActionExecution.setEnd(new Date().getTime());801 LOG.debug("Action interupted due to decode 'Action Condition Value2' Error.");802 conditionDecodeError = true;803 }804 } catch (CerberusEventException cex) {805 LOG.warn(cex);806 }807 }808 if (!(conditionDecodeError)) {809 conditionAnswer = this.conditionService.evaluateCondition(testCaseStepActionExecution.getConditionOper(), testCaseStepActionExecution.getConditionVal1(), testCaseStepActionExecution.getConditionVal2(), tcExecution);810 boolean execute_Action = (boolean) conditionAnswer.getItem();811 /**812 * If condition OK or if manual execution, then execute the813 * action814 */815 if (conditionAnswer.getResultMessage().getMessage().getCodeString().equals("PE")816 || tcExecution.getManualExecution().equals("Y")) {817 // Execute or not the action here.818 if (execute_Action || tcExecution.getManualExecution().equals("Y")) {819 LOG.debug("Executing action : " + testCaseStepActionExecution.getAction() + " with val1 : " + testCaseStepActionExecution.getValue1()820 + " and val2 : " + testCaseStepActionExecution.getValue2());821 /**822 * We execute the Action823 */824 testCaseStepActionExecution = this.executeAction(testCaseStepActionExecution, tcExecution);825 /**826 * If Action or property reported to stop the testcase,827 * we stop it and update the step with the message.828 */829 testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());830 if ((!(testCaseStepActionExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_OK))))831 && (!(testCaseStepActionExecution.getExecutionResultMessage().equals(new MessageGeneral(MessageGeneralEnum.EXECUTION_PE_TESTEXECUTING))))) {832 testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());833 testCaseStepExecution.setStepResultMessage(testCaseStepActionExecution.getActionResultMessage());834 }835 if (testCaseStepActionExecution.isStopExecution()) {836 break;837 }838 } else { // We don't execute the action and record a generic execution.839 /**840 * Record Screenshot, PageSource841 */842 testCaseStepActionExecution.addFileList(recorderService.recordExecutionInformationAfterStepActionandControl(testCaseStepActionExecution, null));843 LOG.debug("Registering Action : " + testCaseStepActionExecution.getAction());844 // We change the Action message only if the action is not executed due to condition.845 MessageEvent actionMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASEACTION_NOTEXECUTED);846 testCaseStepActionExecution.setActionResultMessage(actionMes);847 testCaseStepActionExecution.setReturnMessage(testCaseStepActionExecution.getReturnMessage()848 .replace("%COND%", testCaseStepActionExecution.getConditionOper())849 .replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription())850 );851 testCaseStepActionExecution.setEnd(new Date().getTime());852 this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);853 LOG.debug("Registered Action");854 }855 } else {856 // Error when performing the condition evaluation. We force no execution (false)857 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);858 mes.setDescription(mes.getDescription()859 .replace("%COND%", testCaseStepActionExecution.getConditionOper())860 .replace("%AREA%", "action ")861 .replace("%MES%", conditionAnswer.getResultMessage().getDescription()));862 testCaseStepActionExecution.setExecutionResultMessage(mes);863 testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());864 testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());865 testCaseStepActionExecution.setActionResultMessage(new MessageEvent(MessageEventEnum.CONDITION_TESTCASEACTION_FAILED)866 .resolveDescription("AREA", "")867 .resolveDescription("COND", testCaseStepActionExecution.getConditionOper())868 .resolveDescription("MESSAGE", conditionAnswer.getResultMessage().getDescription()));869 testCaseStepExecution.setStepResultMessage(new MessageEvent(MessageEventEnum.CONDITION_TESTCASESTEP_FAILED)870 .resolveDescription("AREA", "action ")871 .resolveDescription("COND", testCaseStepActionExecution.getConditionOper())872 .resolveDescription("MESSAGE", conditionAnswer.getResultMessage().getDescription()));873 testCaseStepActionExecution.setEnd(new Date().getTime());874 this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);875 LOG.debug("Action interupted due to condition error.");876 // We stop any further Action execution.877 break;878 }879 } else {880 testCaseStepActionExecution.setEnd(new Date().getTime());881 testCaseStepExecution.setExecutionResultMessage(testCaseStepActionExecution.getExecutionResultMessage());882 testCaseStepExecution.setStepResultMessage(testCaseStepActionExecution.getActionResultMessage());883 testCaseStepExecution.setStopExecution(testCaseStepActionExecution.isStopExecution());884 this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);885 LOG.debug("Registered Action");886 if (testCaseStepActionExecution.isStopExecution()) {887 break;888 }889 }890 /**891 * Log TestCaseStepActionExecution892 */893 if (tcExecution.getVerbose() > 0) {894 LOG.info(testCaseStepActionExecution.toJson(false, true));895 }896 }897 testCaseStepExecution.setEnd(new Date().getTime());898 this.testCaseStepExecutionService.updateTestCaseStepExecution(testCaseStepExecution);899 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.900 if (tcExecution.isCerberus_featureflipping_activatewebsocketpush()) {901 TestCaseExecutionEndPoint.getInstance().send(tcExecution, false);902 }903 return testCaseStepExecution;904 }905 private TestCaseStepActionExecution executeAction(TestCaseStepActionExecution testCaseStepActionExecution, TestCaseExecution tcExecution) {906 LOG.debug("Starting execute Action : " + testCaseStepActionExecution.getAction());907 AnswerItem<String> answerDecode = new AnswerItem();908 /**909 * If execution is not manual, do action and record files910 */911 if (!tcExecution.getManualExecution().equals("Y")) {912 testCaseStepActionExecution = this.actionService.doAction(testCaseStepActionExecution);913 /**914 * Record Screenshot, PageSource915 */916 try {917 testCaseStepActionExecution.addFileList(recorderService.recordExecutionInformationAfterStepActionandControl(testCaseStepActionExecution, null));918 } catch (Exception ex) {919 LOG.warn("Unable to record Screenshot/PageSource : " + ex.toString());920 }921 } else {922 /**923 * If execution manual, set Action result message as notExecuted924 */925 testCaseStepActionExecution.setActionResultMessage(new MessageEvent(MessageEventEnum.ACTION_NOTEXECUTED));926 testCaseStepActionExecution.setExecutionResultMessage(new MessageGeneral(MessageGeneralEnum.EXECUTION_NE));927 testCaseStepActionExecution.setEnd(new Date().getTime());928 }929 /**930 * Register Action in database931 */932 LOG.debug("Registering Action : " + testCaseStepActionExecution.getAction());933 this.testCaseStepActionExecutionService.updateTestCaseStepActionExecution(testCaseStepActionExecution);934 LOG.debug("Registered Action");935 if (testCaseStepActionExecution.isStopExecution()) {936 return testCaseStepActionExecution;937 }938 //As controls are associated with an action, the current state for the action is stored in order to restore it939 //if some property is not defined for the country940 MessageEvent actionMessage = testCaseStepActionExecution.getActionResultMessage();941 MessageGeneral excutionResultMessage = testCaseStepActionExecution.getExecutionResultMessage();942 /**943 * Iterate Control944 */945 List<TestCaseStepActionControl> tcsacList = testCaseStepActionExecution.getTestCaseStepAction().getTestCaseStepActionControl();946 for (TestCaseStepActionControl testCaseStepActionControl : tcsacList) {947 /**948 * Start Execution of TestCAseStepActionControl949 */950 long startControl = new Date().getTime();951 /**952 * Create and Register TestCaseStepActionControlExecution953 */954 LOG.debug("Creating TestCaseStepActionControlExecution");955 TestCaseStepActionControlExecution testCaseStepActionControlExecution956 = factoryTestCaseStepActionControlExecution.create(testCaseStepActionExecution.getId(), testCaseStepActionControl.getTest(), testCaseStepActionControl.getTestCase(),957 testCaseStepActionControl.getStep(), testCaseStepActionExecution.getIndex(), testCaseStepActionControl.getSequence(), testCaseStepActionControl.getControlSequence(), testCaseStepActionControl.getSort(),958 null, null,959 testCaseStepActionControl.getConditionOper(), testCaseStepActionControl.getConditionVal1(), testCaseStepActionControl.getConditionVal2(), testCaseStepActionControl.getConditionVal1(), testCaseStepActionControl.getConditionVal2(),960 testCaseStepActionControl.getControl(), testCaseStepActionControl.getValue1(), testCaseStepActionControl.getValue2(), testCaseStepActionControl.getValue1(), testCaseStepActionControl.getValue2(),961 testCaseStepActionControl.getFatal(), startControl, 0, 0, 0,962 testCaseStepActionControl.getDescription(), testCaseStepActionExecution, new MessageEvent(MessageEventEnum.CONTROL_PENDING));963 this.testCaseStepActionControlExecutionService.insertTestCaseStepActionControlExecution(testCaseStepActionControlExecution);964 LOG.debug("Executing control : " + testCaseStepActionControlExecution.getControlSequence() + " type : " + testCaseStepActionControlExecution.getControl());965 /**966 * We populate the TestCase Control List967 */968 testCaseStepActionExecution.addTestCaseStepActionExecutionList(testCaseStepActionControlExecution);969 // Evaluate the condition at the control level.970 AnswerItem<Boolean> conditionAnswer;971 boolean conditionDecodeError = false;972 if (!tcExecution.getManualExecution().equals("Y")) {973 try {974 answerDecode = variableService.decodeStringCompletly(testCaseStepActionControlExecution.getConditionVal1(), tcExecution, null, false);975 testCaseStepActionControlExecution.setConditionVal1((String) answerDecode.getItem());976 if (!(answerDecode.isCodeStringEquals("OK"))) {977 // If anything wrong with the decode --> we stop here with decode message in the action result.978 testCaseStepActionControlExecution.setControlResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Control Condition Value1"));979 testCaseStepActionControlExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));980 testCaseStepActionControlExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());981 testCaseStepActionControlExecution.setEnd(new Date().getTime());982 LOG.debug("Control interupted due to decode 'Control Condition Value1' Error.");983 conditionDecodeError = true;984 }985 } catch (CerberusEventException cex) {986 LOG.warn(cex);987 }988 try {989 answerDecode = variableService.decodeStringCompletly(testCaseStepActionControlExecution.getConditionVal2(), tcExecution, null, false);990 testCaseStepActionControlExecution.setConditionVal2((String) answerDecode.getItem());991 if (!(answerDecode.isCodeStringEquals("OK"))) {992 // If anything wrong with the decode --> we stop here with decode message in the action result.993 testCaseStepActionControlExecution.setControlResultMessage(answerDecode.getResultMessage().resolveDescription("FIELD", "Control Condition Value2"));994 testCaseStepActionControlExecution.setExecutionResultMessage(new MessageGeneral(answerDecode.getResultMessage().getMessage()));995 testCaseStepActionControlExecution.setStopExecution(answerDecode.getResultMessage().isStopTest());996 testCaseStepActionControlExecution.setEnd(new Date().getTime());997 LOG.debug("Control interupted due to decode 'Control Condition Value2' Error.");998 conditionDecodeError = true;999 }1000 } catch (CerberusEventException cex) {1001 LOG.warn(cex);1002 }1003 }1004 if (!(conditionDecodeError)) {1005 conditionAnswer = this.conditionService.evaluateCondition(testCaseStepActionControlExecution.getConditionOper(), testCaseStepActionControlExecution.getConditionVal1(), testCaseStepActionControlExecution.getConditionVal2(), tcExecution);1006 boolean execute_Control = (boolean) conditionAnswer.getItem();1007 /**1008 * If condition OK or if manual execution, then execute the1009 * control1010 */1011 if (conditionAnswer.getResultMessage().getMessage().getCodeString().equals("PE")1012 || tcExecution.getManualExecution().equals("Y")) {1013 if (execute_Control || tcExecution.getManualExecution().equals("Y")) {1014 /**1015 * We execute the control1016 */1017 testCaseStepActionControlExecution = executeControl(testCaseStepActionControlExecution, tcExecution);1018 /**1019 * We update the Action with the execution message and1020 * stop flag from the control. We update the status only1021 * if the control is not OK. This is to prevent moving1022 * the status to OK when it should stay KO when a1023 * control failed previously.1024 */1025 testCaseStepActionExecution.setStopExecution(testCaseStepActionControlExecution.isStopExecution());1026 if (!(testCaseStepActionControlExecution.getControlResultMessage().equals(new MessageEvent(MessageEventEnum.CONTROL_SUCCESS)))) {1027 //NA is a special case of not having success while calculating the property; the action shouldn't be stopped1028 if (testCaseStepActionControlExecution.getControlResultMessage().equals(new MessageEvent(MessageEventEnum.PROPERTY_FAILED_NO_PROPERTY_DEFINITION))) {1029 //restores the messages information if the property is not defined for the country1030 testCaseStepActionExecution.setActionResultMessage(actionMessage);1031 testCaseStepActionExecution.setExecutionResultMessage(excutionResultMessage);1032 } else {1033 testCaseStepActionExecution.setExecutionResultMessage(testCaseStepActionControlExecution.getExecutionResultMessage());1034 testCaseStepActionExecution.setActionResultMessage(testCaseStepActionControlExecution.getControlResultMessage());1035 }1036 }1037 /**1038 * If Control reported to stop the testcase, we stop it.1039 */1040 if (testCaseStepActionControlExecution.isStopExecution()) {1041 break;1042 }1043 } else { // We don't execute the control and record a generic execution.1044 /**1045 * Record Screenshot, PageSource1046 */1047 testCaseStepActionControlExecution.addFileList(recorderService.recordExecutionInformationAfterStepActionandControl(testCaseStepActionControlExecution.getTestCaseStepActionExecution(), testCaseStepActionControlExecution));1048 /**1049 * Register Control in database1050 */1051 LOG.debug("Registering Control : " + testCaseStepActionControlExecution.getControlSequence());1052 // We change the Action message only if the action is not executed due to condition.1053 MessageEvent controlMes = new MessageEvent(MessageEventEnum.CONDITION_TESTCASECONTROL_NOTEXECUTED);1054 testCaseStepActionControlExecution.setControlResultMessage(controlMes);1055 testCaseStepActionControlExecution.setReturnMessage(testCaseStepActionControlExecution.getReturnMessage()1056 .replace("%COND%", testCaseStepActionControlExecution.getConditionOper())1057 .replace("%MESSAGE%", conditionAnswer.getResultMessage().getDescription())1058 );1059 testCaseStepActionControlExecution.setEnd(new Date().getTime());1060 this.testCaseStepActionControlExecutionService.updateTestCaseStepActionControlExecution(testCaseStepActionControlExecution);1061 LOG.debug("Registered Control");1062 // Websocket --> we refresh the corresponding Detail Execution pages attached to this execution.1063 if (tcExecution.isCerberus_featureflipping_activatewebsocketpush()) {1064 TestCaseExecutionEndPoint.getInstance().send(tcExecution, false);1065 }1066 }1067 } else {1068 // Error when performing the condition evaluation. We force no execution (false)1069 MessageGeneral mes = new MessageGeneral(MessageGeneralEnum.EXECUTION_FA_CONDITION);...

Full Screen

Full Screen

Source:TestCaseStepActionControlExecution.java Github

copy

Full Screen

...197 }198 public void setReturnCode(String returnCode) {199 this.returnCode = returnCode;200 }201 public String getReturnMessage() {202 return returnMessage;203 }204 public void setReturnMessage(String returnMessage) {205 this.returnMessage = returnMessage;206 }207 public int getSequence() {208 return sequence;209 }210 public void setSequence(int sequence) {211 this.sequence = sequence;212 }213 public long getStart() {214 return start;215 }216 public void setStart(long start) {217 this.start = start;218 }219 public long getStartLong() {220 return startLong;221 }222 public void setStartLong(long startLong) {223 this.startLong = startLong;224 }225 public int getStep() {226 return step;227 }228 public void setStep(int step) {229 this.step = step;230 }231 public String getTest() {232 return test;233 }234 public int getIndex() {235 return index;236 }237 public void setIndex(int index) {238 this.index = index;239 }240 public void setTest(String test) {241 this.test = test;242 }243 public String getTestCase() {244 return testCase;245 }246 public void setTestCase(String testCase) {247 this.testCase = testCase;248 }249 public String getDescription() {250 return description;251 }252 public void setDescription(String description) {253 this.description = description;254 }255 public String getValue1Init() {256 return value1Init;257 }258 public void setValue1Init(String value1Init) {259 this.value1Init = value1Init;260 }261 public String getValue2Init() {262 return value2Init;263 }264 public void setValue2Init(String value2Init) {265 this.value2Init = value2Init;266 }267 /**268 * Convert the current TestCaseStepActionControlExecution into JSON format269 * Note that if withChilds and withParents are both set to true, only the270 * child will be included to avoid loop.271 *272 * @param withChilds boolean that define if childs should be included273 * @param withParents boolean that define if parents should be included274 * @return TestCaseStepActionControlExecution in JSONObject format275 */276 public JSONObject toJson(boolean withChilds, boolean withParents) {277 JSONObject result = new JSONObject();278 // Check if both parameter are not set to true279 if (withChilds == true && withParents == true) {280 withParents = false;281 }282 try {283 result.put("type", "testCaseStepActionControlExecution");284 result.put("id", this.getId());285 result.put("test", this.getTest());286 result.put("testcase", this.getTestCase());287 result.put("step", this.getStep());288 result.put("index", this.getIndex());289 result.put("sequence", this.getSequence());290 result.put("control", this.getControlSequence());291 result.put("sort", this.getSort());292 result.put("conditionOper", this.getConditionOper());293 result.put("conditionVal1Init", this.getConditionVal1Init());294 result.put("conditionVal2Init", this.getConditionVal2Init());295 result.put("conditionVal1", this.getConditionVal1());296 result.put("conditionVal2", this.getConditionVal2());297 result.put("controlType", this.getControl());298 result.put("controlProperty", this.getValue1());299 result.put("controlPropertyInit", this.getValue1Init());300 result.put("controlValue", this.getValue2());301 result.put("controlValueInit", this.getValue2Init());302 result.put("fatal", this.getFatal());303 result.put("start", this.getStart());304 result.put("end", this.getEnd());305 result.put("startlong", this.getStartLong());306 result.put("endlong", this.getEndLong());307 result.put("description", this.getDescription());308 result.put("returnCode", this.getReturnCode());309 result.put("returnMessage", this.getReturnMessage());310 if (withChilds) {311 JSONArray array = new JSONArray();312 if (this.getFileList() != null) {313 for (Object actionFileList : this.getFileList()) {314 array.put(((TestCaseExecutionFile) actionFileList).toJson());315 }316 }317 result.put("fileList", array);318 }319 if (withParents) {320 result.put("testCaseStepActionExecution", this.getTestCaseStepActionExecution().toJson(false, true));321 }322 } catch (JSONException ex) {323 Logger LOG = LogManager.getLogger(TestCaseStepActionControlExecution.class);...

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1import org.cerberus.crud.entity.TestCaseStepActionExecution;2public class 3 {3 public static void main(String[] args) {4 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();5 testCaseStepActionExecution.setReturnMessage("This is a return message");6 System.out.println(testCaseStepActionExecution.getReturnMessage());7 }8}9import org.cerberus.crud.entity.TestCaseStepActionExecution;10public class 4 {11 public static void main(String[] args) {12 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();13 testCaseStepActionExecution.setReturnCode("This is a return code");14 System.out.println(testCaseStepActionExecution.getReturnCode());15 }16}17import org.cerberus.crud.entity.TestCaseStepActionExecution;18public class 5 {19 public static void main(String[] args) {20 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();21 testCaseStepActionExecution.setReturnMessage("This is a return message");22 System.out.println(testCaseStepActionExecution.getReturnMessage());23 }24}25import org.cerberus.crud.entity.TestCaseStepActionExecution;26public class 6 {27 public static void main(String[] args) {28 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();29 testCaseStepActionExecution.setControlStatus("This is a control status");30 System.out.println(testCaseStepActionExecution.getControlStatus());31 }32}33import org.cerberus.crud.entity.TestCaseStepActionExecution;34public class 7 {35 public static void main(String[] args) {36 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1public String getReturnMessage() {2 return returnMessage;3}4public void setReturnMessage(String returnMessage) {5 this.returnMessage = returnMessage;6}7public String getReturnMessage() {8 return returnMessage;9}10public void setReturnMessage(String returnMessage) {11 this.returnMessage = returnMessage;12}13public String getReturnMessage() {14 return returnMessage;15}16public void setReturnMessage(String returnMessage) {17 this.returnMessage = returnMessage;18}19public String getReturnMessage() {20 return returnMessage;21}22public void setReturnMessage(String returnMessage) {23 this.returnMessage = returnMessage;24}25public String getReturnMessage() {26 return returnMessage;27}28public void setReturnMessage(String returnMessage) {29 this.returnMessage = returnMessage;30}31public String getReturnMessage() {32 return returnMessage;33}34public void setReturnMessage(String returnMessage) {35 this.returnMessage = returnMessage;36}

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseStepActionExecution;3public class TestCaseStepActionExecution {4 public String getReturnMessage() {5 return "Hello World";6 }7}8package com.example;9import org.cerberus.crud.entity.TestCaseStepActionExecution;10public class Test {11 public static void main(String[] args) {12 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();13 System.out.println(testCaseStepActionExecution.getReturnMessage());14 }15}16package com.example;17import org.cerberus.crud.entity.TestCaseExecution;18public class Test {19 public static void main(String[] args) {20 TestCaseExecution testCaseExecution = new TestCaseExecution();21 System.out.println(testCaseExecution.getReturnMessage());22 }23}24 at com.example.Test.main(Test.java:6)25 at java.net.URLClassLoader.findClass(URLClassLoader.java:381)26 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)27 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2public class TestCaseStepActionExecution {3 public String getReturnMessage() {4 return "returnMessage";5 }6}7package org.cerberus.crud.entity;8public class TestCaseStepActionExecution {9 public String getReturnMessage() {10 return "returnMessage";11 }12}13package org.cerberus.crud.entity;14public class TestCaseStepActionExecution {15 public String getReturnMessage() {16 return "returnMessage";17 }18}19package org.cerberus.crud.entity;20public class TestCaseStepActionExecution {21 public String getReturnMessage() {22 return "returnMessage";23 }24}25package org.cerberus.crud.entity;26public class TestCaseStepActionExecution {27 public String getReturnMessage() {28 return "returnMessage";29 }30}31package org.cerberus.crud.entity;32public class TestCaseStepActionExecution {33 public String getReturnMessage() {34 return "returnMessage";35 }36}37package org.cerberus.crud.entity;38public class TestCaseStepActionExecution {39 public String getReturnMessage() {40 return "returnMessage";41 }42}43package org.cerberus.crud.entity;44public class TestCaseStepActionExecution {45 public String getReturnMessage() {46 return "returnMessage";47 }48}

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import java.util.logging.Level;3import java.util.logging.Logger;4public class TestCaseStepActionExecution {5 private String returnCode;6 private String returnMessage;7 private String returnObj;8 private String returnScreenshot;9 private String returnVideo;10 private String returnFile;11 private String returnString;12 private String returnInteger;13 private String returnDecimal;14 private String returnDate;15 private String returnProperty;16 private String returnDatabase;17 private String returnXml;18 private String returnJson;19 private String returnSoapXml;20 private String returnService;21 private String returnFromLib;22 private String returnFromService;23 private String returnFromDataLib;24 private String returnFromPageSource;25 private String returnFromHtml;26 private String returnFromHtmlClick;27 private String returnFromHtmlVisible;28 private String returnFromHtmlEditable;29 private String returnFromHtmlExist;30 private String returnFromHtmlAttribute;31 private String returnFromHtmlText;32 private String returnFromHtmlSelect;33 private String returnFromHtmlInput;34 private String returnFromHtmlLink;35 private String returnFromHtmlImage;36 private String returnFromHtmlTable;37 private String returnFromHtmlArea;38 private String returnFromHtmlAreaClick;39 private String returnFromHtmlAreaVisible;40 private String returnFromHtmlAreaEditable;41 private String returnFromHtmlAreaExist;42 private String returnFromHtmlAreaAttribute;43 private String returnFromHtmlAreaText;44 private String returnFromHtmlAreaSelect;45 private String returnFromHtmlAreaInput;46 private String returnFromHtmlAreaLink;47 private String returnFromHtmlAreaImage;48 private String returnFromHtmlAreaTable;49 private String returnFromHtmlAreaArea;50 private String returnFromHtmlAreaAreaClick;51 private String returnFromHtmlAreaAreaVisible;52 private String returnFromHtmlAreaAreaEditable;53 private String returnFromHtmlAreaAreaExist;54 private String returnFromHtmlAreaAreaAttribute;55 private String returnFromHtmlAreaAreaText;56 private String returnFromHtmlAreaAreaSelect;57 private String returnFromHtmlAreaAreaInput;58 private String returnFromHtmlAreaAreaLink;59 private String returnFromHtmlAreaAreaImage;60 private String returnFromHtmlAreaAreaTable;61 private String returnFromHtmlAreaAreaArea;

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package org.cerberus.crud.entity;2import org.cerberus.crud.entity.TestCaseStepActionExecution;3import org.cerberus.crud.entity.TestCaseStepActionExecution;4public class TestCaseStepActionExecution {5 private int id;6 private int test;7 private int testCase;8 private int step;9 private int index;10 private String returnCode;11 private String returnMessage;12 private String controlStatus;13 private String controlMessage;14 private String controlProperty;15 private String controlValue;16 private String screenshotFilename;17 private String verbose;18 private String description;19 private String fatal;20 private int sequence;21 private String useStep;22 private String useStepTest;23 private String useStepTestCase;24 private int useStepStep;25 private String loop;26 private String conditionOper;27 private String conditionVal1;28 private String conditionVal2;29 private String conditionVal3;30 private String conditionOptions;31 private String conditionVal1Init;32 private String conditionVal2Init;33 private String conditionVal3Init;34 private String conditionVal1Target;35 private String conditionVal2Target;36 private String conditionVal3Target;37 private String conditionVal1TargetInit;38 private String conditionVal2TargetInit;39 private String conditionVal3TargetInit;40 private String conditionVal1TargetEnd;41 private String conditionVal2TargetEnd;42 private String conditionVal3TargetEnd;43 private int retries;44 private int timeOut;45 private String pageSource;46 private String pageSourceOnFailure;47 private String seleniumLog;48 private String manualURL;49 private String manualExecution;50 private String robot;51 private String robotExecutor;52 private String robotHost;53 private String robotPort;54 private String robotPlatform;55 private String robotBrowser;56 private String robotBrowserVersion;57 private String robotDevice;58 private String robotVersion;59 private String robotUrl;60 private String robotSeleniumLog;61 private String robotOutputVideo;62 private String robotOutputFile;63 private String robotOutputResultFile;64 private String robotOutputResultMessage;65 private String application;66 private String start;67 private String end;68 private String usrCreated;69 private String dateCreated;70 private String usrModif;71 private String dateModif;72 private String testBattery;

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package com.mycompany.myproject.testcases;2import org.cerberus.crud.entity.TestCaseStepActionExecution;3import org.cerberus.crud.entity.TestCaseStepExecution;4import org.cerberus.engine.entity.MessageEvent;5import org.cerberus.engine.entity.MessageGeneral;6import org.cerberus.engine.execution.IExecutionManagerService;7import org.cerberus.engine.execution.impl.ExecutionManagerService;8import org.cerberus.engine.execution.impl.TestExecutionService;9import org.cerberus.engine.queuemanagement.IExecutionThreadPoolService;10import org.cerberus.engine.queuemanagement.impl.ExecutionThreadPoolService;11import org.cerberus.engine.threadpoolpool.IExecutionThreadPoolServiceFactory;12import org.cerberus.engine.threadpoolpool.impl.ExecutionThreadPoolServiceFactory;13import org.cerberus.engine.threadpoolpool.impl.ExecutionThreadPoolServiceFactoryImpl;14import org.cerberus.exception.CerberusException;15import org.cerberus.util.answer.AnswerItem;16import org.springframework.context.ApplicationContext;17import org.springframework.context.support.ClassPathXmlApplicationContext;18public class GetReturnMessage {19 public static void main(String[] args) throws CerberusException, InterruptedException {20 ApplicationContext appContext = new ClassPathXmlApplicationContext("applicationContext.xml");21 IExecutionThreadPoolServiceFactory executionThreadPoolServiceFactory = appContext.getBean(ExecutionThreadPoolServiceFactoryImpl.class);22 IExecutionThreadPoolService executionThreadPoolService = appContext.getBean(ExecutionThreadPoolService.class);23 IExecutionManagerService executionManagerService = appContext.getBean(ExecutionManagerService.class);24 TestExecutionService testExecutionService = appContext.getBean(TestExecutionService.class);25 String test = "TEST";26 String testCase = "TESTCASE";27 String country = "US";28 String environment = "QA";29 String robot = "ROBOT";30 String robotDecli = "ROBOTDECLI";31 String robotIP = "ROBOTIP";32 String robotPort = "ROBOTPORT";33 String browser = "FIREFOX";34 String browserVersion = "45";35 String platform = "WIN";36 String screenSize = "1024x768";37 String tag = "TAG";38 String outputFormat = "HTML";39 String screenshot = "N";40 String pageSource = "N";41 String seleniumLog = "N";

Full Screen

Full Screen

getReturnMessage

Using AI Code Generation

copy

Full Screen

1package com.cerberus.myproject;2import org.cerberus.crud.entity.TestCaseStepActionExecution;3public class 3 {4 public static void main(String[] args) {5 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();6 testCaseStepActionExecution.setReturnMessage("This is a return message");7 System.out.println(testCaseStepActionExecution.getReturnMessage());8 }9}10package com.cerberus.myproject;11import org.cerberus.crud.entity.TestCaseStepActionExecution;12public class 4 {13 public static void main(String[] args) {14 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();15 testCaseStepActionExecution.setReturnMessage("This is a return message");16 System.out.println(testCaseStepActionExecution.getReturnMessage());17 }18}19package com.cerberus.myproject;20import org.cerberus.crud.entity.TestCaseStepActionExecution;21public class 5 {22 public static void main(String[] args) {23 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();24 testCaseStepActionExecution.setReturnMessage("This is a return message");25 System.out.println(testCaseStepActionExecution.getReturnMessage());26 }27}28package com.cerberus.myproject;29import org.cerberus.crud.entity.TestCaseStepActionExecution;30public class 6 {31 public static void main(String[] args) {32 TestCaseStepActionExecution testCaseStepActionExecution = new TestCaseStepActionExecution();33 testCaseStepActionExecution.setReturnMessage("This is a return message");34 System.out.println(testCaseStepActionExecution.getReturnMessage());

Full Screen

Full Screen

Automation Testing Tutorials

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

LambdaTest Learning Hubs:

YouTube

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

Run Cerberus-source automation tests on LambdaTest cloud grid

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

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful