Best Testsigma code snippet using com.testsigma.service.AgentExecutionService.isWaitingOnEnvironmentPrerequisite
Source:AgentExecutionService.java
...578 testDeviceResultService.updateExecutionConsolidatedResults(this.testPlanResult.getId(),579 Boolean.TRUE);580 }581 public void processEnvironmentResultOnSuccessfulChecks(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {582 if (!isWaitingOnEnvironmentPrerequisite(testDeviceResult)) {583 if (testDeviceResult.getPrerequisiteTestDeviceResultId() == null || isEnvironmentPrerequisiteResultSuccessful(testDeviceResult)) {584 processEnvironmentResult(testDeviceResult, inStatus);585 } else {586 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.MSG_EXECUTION_NOT_EXECUTED, StatusConstant.STATUS_QUEUED);587 }588 } else {589 testDeviceResultService.markEnvironmentResultAsQueued(testDeviceResult, inStatus, true);590 }591 }592 private void processEnvironmentResult(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {593 testDeviceResultService.markEnvironmentResultAsInPreFlight(testDeviceResult, inStatus);594 if (!testDeviceResult.getTestPlanLabType().isHybrid()) {595 EnvironmentEntityDTO environmentEntityDTO = loadEnvironment(testDeviceResult,596 StatusConstant.STATUS_PRE_FLIGHT);597 try {598 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);599 } catch (Exception e) {600 log.error(e.getMessage(), e);601 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, e.getMessage(),602 StatusConstant.STATUS_PRE_FLIGHT);603 }604 }605 }606 public void processEnvironmentResultInParallel(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {607 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(608 testDeviceResult, inStatus);609 testDeviceResult.setSuiteResults(testSuiteResults);610 for (TestSuiteResult testSuiteResult : testSuiteResults) {611 if(!isWaitingOnEnvironmentPrerequisite(testDeviceResult)) {612 testSuiteResultService.markTestSuiteResultAsInFlight(testSuiteResult, inStatus);613 if (!testDeviceResult.getTestPlanLabType().isHybrid()) {614 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);615 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, StatusConstant.STATUS_PRE_FLIGHT));616 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();617 testSuiteEntityDTOS.add(testSuiteEntity);618 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);619 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);620 try {621 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);622 } catch (Exception e) {623 log.error(e.getMessage(), e);624 testSuiteResultService.markTestSuiteResultAsFailed(testSuiteResult, e.getMessage(),625 StatusConstant.STATUS_PRE_FLIGHT);626 }627 }628 }629 }630 testDeviceResultService.updateEnvironmentConsolidatedResults(testDeviceResult);631 }632 public EnvironmentEntityDTO loadEnvironment(TestDeviceResult testDeviceResult, StatusConstant inStatus)633 throws Exception {634 List<TestSuiteEntityDTO> testSuiteEntityDTOS = loadTestSuites(testDeviceResult, inStatus);635 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);636 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);637 return environmentEntityDTO;638 }639 public EnvironmentEntityDTO loadEnvironmentDetails(TestDeviceResult testDeviceResult) throws Exception {640 TestPlanSettingEntityDTO testPlanSettingEntityDTO = this.testPlanMapper.mapSettings(this.testPlan);641 EnvironmentEntityDTO environmentEntityDTO = this.testDeviceResultMapper.map(testDeviceResult);642 TestDevice testDevice = testDeviceResult.getTestDevice();643 if (testDevice.getDeviceId() != null) {644 AgentDevice agentDevice = agentDeviceService.find(testDevice.getDeviceId());645 environmentEntityDTO.setAgentDeviceUuid(agentDevice.getUniqueId());646 }647 environmentEntityDTO.setStorageType(storageServiceFactory.getStorageService().getStorageType());648 testDevice.setWorkspaceVersion(workspaceVersionService.find(testDevice.getWorkspaceVersionId()));649 environmentEntityDTO.setWorkspaceType(testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType());650 environmentEntityDTO.setExecutionLabType(testDevice.getTestPlanLabType());651 environmentEntityDTO.setTestPlanSettings(testPlanSettingEntityDTO);652 environmentEntityDTO.setMatchBrowserVersion(testDevice.getMatchBrowserVersion());653 environmentEntityDTO.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());654 TestDeviceSettings settings = getExecutionTestDeviceSettings(testDevice);655 settings.setExecutionName(testPlan.getName());656 settings.setEnvironmentParamId(this.testPlan.getEnvironmentId());657 settings.setEnvRunId(testDeviceResult.getId());658 setTestLabDetails(testDevice, settings,environmentEntityDTO);659 environmentEntityDTO.setEnvSettings(this.testPlanMapper.mapToDTO(settings));660 Agent agent = null;661 if (testDevice.getAgentId() != null)662 agent = this.agentService.find(testDevice.getAgentId());663 setAgentJWTApiKey(environmentEntityDTO, agent);664 setAvailableFeatures(environmentEntityDTO);665 return environmentEntityDTO;666 }667 private List<TestSuiteEntityDTO> loadTestSuites(TestDeviceResult testDeviceResult, StatusConstant inStatus) {668 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();669 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(testDeviceResult,670 inStatus);671 for (TestSuiteResult testSuiteResult : testSuiteResults) {672 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);673 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, inStatus));674 testSuiteEntityDTOS.add(testSuiteEntity);675 }676 return testSuiteEntityDTOS;677 }678 private List<TestCaseEntityDTO> loadTestCases(TestSuiteResult testSuiteResult, StatusConstant inStatus) {679 List<TestCaseResult> testCaseResults = this.testCaseResultService.findActiveSuiteTestCaseResults(680 testSuiteResult.getId(), inStatus);681 List<TestCaseEntityDTO> testCases = new ArrayList<>();682 for (TestCaseResult testCaseResult : testCaseResults) {683 TestCaseEntityDTO testCaseEntity = this.testCaseResultMapper.map(testCaseResult);684 testCaseEntity.setDataDrivenTestCases(loadDataDrivenTestCases(testCaseResult, inStatus));685 testCases.add(testCaseEntity);686 }687 return testCases;688 }689 private List<TestCaseEntityDTO> loadDataDrivenTestCases(TestCaseResult testCaseResult, StatusConstant inStatus) {690 List<TestCaseResult> dataDrivenTestCaseResults =691 this.testCaseResultService.findAllByParentIdAndStatus(testCaseResult.getId(), inStatus);692 return this.testCaseResultMapper.map(dataDrivenTestCaseResults);693 }694 private void setAgentJWTApiKey(EnvironmentEntityDTO environmentEntityDTO, com.testsigma.model.Agent id) throws ResourceNotFoundException {695 TestDeviceSettingsDTO envSettings = environmentEntityDTO.getEnvSettings();696 if (id != null) {697 Agent agent = this.agentService.find(id.getId());698 envSettings.setJwtApiKey(agent.generateJwtApiKey(jwtTokenService.getServerUuid()));699 }700 environmentEntityDTO.setEnvSettings(envSettings);701 }702 private void setAvailableFeatures(EnvironmentEntityDTO dto) throws ResourceNotFoundException, SQLException {703 dto.getTestPlanSettings().setHasSuggestionFeature(true);704 }705 private void pushEnvironmentToLab(TestDeviceResult testDeviceResult, EnvironmentEntityDTO environmentEntityDTO) throws Exception {706 ObjectMapper objectMapper = new ObjectMapper();707 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);708 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);709 TestDeviceEntity testDeviceEntity = objectMapper.readValue(objectMapper.writeValueAsString(environmentEntityDTO),710 TestDeviceEntity.class);711 try {712 testDeviceResultService.markEnvironmentResultAsInProgress(testDeviceResult, StatusConstant.STATUS_PRE_FLIGHT,713 Boolean.TRUE);714 new TestPlanRunTask(testDeviceEntity).start();715 log.info("Successfully pushed Execution Environment[" + testDeviceEntity.getEnvironmentResultId()716 + "] to Testsigma Lab");717 } catch (Exception e) {718 log.error(e.getMessage(), e);719 String message = "Error while pushing environment to agent - " + e.getMessage();720 throw new TestsigmaException(message, message);721 }722 }723 private void saveRunTimeData() {724 JSONObject runtimeJSONObj = this.getRunTimeData();725 if (runtimeJSONObj != null && runtimeJSONObj.has("runtime_data")) {726 RunTimeData runTimeData = new RunTimeData();727 runTimeData.setTestPlanRunId(this.getTestPlanResult().getId());728 if (runtimeJSONObj.has("runtime_data")) {729 runTimeData.setData(runtimeJSONObj.getJSONObject("runtime_data"));730 }731 this.runTimeDataService.create(runTimeData);732 }733 }734 public void checkTestCaseIsInReadyState(TestCase testCase) throws TestsigmaException {735 if (!testCase.getStatus().equals(TestCaseStatus.READY) && testPlan.getEntityType()=="TEST_PLAN") {736 String message = testCase.getIsStepGroup() ? com.testsigma.constants.MessageConstants.getMessage(MessageConstants.STEP_GROUP_NOT_READY, testCase.getName()) :737 MessageConstants.TESTCASE_NOT_READY;738 throw new TestsigmaException(message, message);739 }740 }741 private void fetchEnvironmentResultsReRunList() {742 testDeviceResultsReRunList = new ArrayList<>();743 if (getReRunType() == ReRunType.ALL_TESTS) {744 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultId(this.getParentTestPlanResultId());745 } else if (ReRunType.runFailedTestCases(getReRunType())) {746 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultIdAndResultIsNot747 (this.getParentTestPlanResultId(), ResultConstant.SUCCESS);748 }749 }750 private void fetchTestSuitesResultsReRunList(Long parentEnvironmentResultId) {751 testSuiteResultsReRunList = new ArrayList<>();752 try {753 TestDeviceResult parentTestDeviceResult = testDeviceResultService.find(parentEnvironmentResultId);754 List<TestSuiteResult> failedTestSuites;755 if (parentTestDeviceResult != null) {756 if (getReRunType() == ReRunType.ALL_TESTS) {757 testSuiteResultsReRunList = testSuiteResultService.findAllByEnvironmentResultId(parentTestDeviceResult.getId());758 } else if (ReRunType.runFailedTestCases(getReRunType())) {759 failedTestSuites = testSuiteResultService.findAllByEnvironmentResultIdAndResultIsNot760 (parentTestDeviceResult.getId(), ResultConstant.SUCCESS);761 if (failedTestSuites.size() > 0) {762 for (TestSuiteResult testSuiteResult : failedTestSuites) {763 List<Long> testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(testSuiteResult, new ArrayList<>(), 0);764 if (testSuitePreRequisiteIds.size() > 0) {765 List<TestSuiteResult> preRequisiteResults = testSuiteResultService.findBySuiteResultIds(testSuitePreRequisiteIds);766 testSuiteResultsReRunList.addAll(preRequisiteResults);767 }768 testSuiteResultsReRunList.add(testSuiteResult);769 }770 }771 }772 }773 } catch (Exception e) {774 log.error(e.getMessage(), e);775 }776 }777 private List<Long> findTestSuitePreRequisiteIds(TestSuiteResult testSuiteResult, List<Long> testSuitePreRequisiteIds,778 int depth) {779 if (depth < PRE_REQUISITE_DEPTH) {780 TestSuiteResult preReqTestSuiteResult;781 try {782 TestSuite testSuite = testSuiteResult.getTestSuite();783 if (testSuite.getPreRequisite() != null) {784 preReqTestSuiteResult = testSuiteResultService.findByEnvironmentResultIdAndSuiteId(785 testSuiteResult.getEnvironmentResultId(), testSuite.getPreRequisite());786 if (preReqTestSuiteResult != null) {787 testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(preReqTestSuiteResult, testSuitePreRequisiteIds,788 depth + 1);789 testSuitePreRequisiteIds.add(preReqTestSuiteResult.getId());790 }791 }792 } catch (Exception e) {793 log.error(e.getMessage(), e);794 }795 }796 return testSuitePreRequisiteIds;797 }798 private void fetchTestCaseResultsReRunList(Long parentTestSuiteResultId) {799 testCaseResultsReRunList = new ArrayList<>();800 try {801 TestSuiteResult parentTestSuiteResult = testSuiteResultService.find(parentTestSuiteResultId);802 List<TestCaseResult> failedTestCases = new ArrayList<>();803 if (parentTestSuiteResult != null) {804 if (getReRunType() == ReRunType.ALL_TESTS || isTestSuiteAPrerequisite(parentTestSuiteResult)) {805 testCaseResultsReRunList = testCaseResultService.findAllBySuiteResultId(parentTestSuiteResult.getId());806 } else if (ReRunType.runFailedTestCases(getReRunType())) {807 if(getReRunType() == ReRunType.ALL_ITERATIONS) {808 log.info("Fetching all iterations in failed data driven test case results for suite result id - " + parentTestSuiteResult.getId());809 List<TestCaseResult> failedTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndIsDataDrivenTrueAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);810 for (TestCaseResult testCaseResult : failedTestCaseResults) {811 failedTestCases.addAll(testCaseResultService.findAllBySuiteResultIdAndTestCaseId(parentTestSuiteResult.getId(), testCaseResult.getTestCaseId()));812 }813 }814 else if(getReRunType() == ReRunType.ONLY_FAILED_ITERATIONS_IN_FAILED_TESTS) {815 log.info("Fetching all failed data driven test case results re run list for suite result id - " + parentTestSuiteResult.getId());816 List<TestCaseResult> failedTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndIsDataDrivenTrueAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);817 for (TestCaseResult testCaseResult : failedTestCaseResults) {818 failedTestCases.addAll(testCaseResultService.findAllBySuiteResultIdAndTestCaseIdAndResultIsNot(parentTestSuiteResult.getId(), testCaseResult.getTestCaseId(), ResultConstant.SUCCESS));819 }820 }821 else {822 log.info("Fetching all failed test case results re run list for suite result id - " + parentTestSuiteResult.getId());823 failedTestCases = testCaseResultService.findAllBySuiteResultIdAndResultIsNot(parentTestSuiteResult.getId(), ResultConstant.SUCCESS);824 }825 if (failedTestCases.size() > 0) {826 for (TestCaseResult testCaseResult : failedTestCases) {827 List<Long> testCasePreRequisiteIds = findTestCasePreRequisiteIds(testCaseResult, new ArrayList<>(), 0);828 //If a prerequisite is failed, it will be already available in failedTestCases. So we need to add only prerequisites with SUCCESS status.829 List<TestCaseResult> preRequisiteResults = fetchPreRequisiteTestCaseResultsWithSuccessStatus(testCasePreRequisiteIds);830 testCaseResultsReRunList.addAll(preRequisiteResults);831 testCaseResultsReRunList.add(testCaseResult);832 }833 }834 }835 }836 } catch (Exception e) {837 log.error(e.getMessage(), e);838 }839 }840 private List<TestCaseResult> fetchPreRequisiteTestCaseResultsWithSuccessStatus(List<Long> testCasePreRequisiteIds) {841 List<TestCaseResult> preRequisitesWithSuccessStatus = new ArrayList<>();842 List<TestCaseResult> preRequisiteResults = testCaseResultService.findByTestCaseResultIds(testCasePreRequisiteIds);843 for (TestCaseResult testCaseResult : preRequisiteResults) {844 if (testCaseResult.getResult() == ResultConstant.SUCCESS) {845 preRequisitesWithSuccessStatus.add(testCaseResult);846 }847 }848 return preRequisitesWithSuccessStatus;849 }850 private boolean isTestSuiteAPrerequisite(TestSuiteResult testSuiteResult) {851 List<TestSuite> testSuites = testSuiteService.findByPrerequisiteId(testSuiteResult.getSuiteId());852 for (TestSuite testSuite : testSuites) {853 TestSuiteResult baseTestSuiteResult = testSuiteResultService.findByEnvironmentResultIdAndSuiteId(testSuiteResult.getEnvironmentResultId(), testSuite.getId());854 if (baseTestSuiteResult != null) {855 return true;856 }857 }858 return false;859 }860 private List<Long> findTestCasePreRequisiteIds(TestCaseResult testCaseResult, List<Long> testCasePreRequisiteIds,861 int depth) {862 if (depth < PRE_REQUISITE_DEPTH) {863 List<TestCaseResult> preReqTestCaseResults;864 try {865 TestCase testCase = testCaseResult.getTestCase();866 if (testCase.getPreRequisite() != null) {867 //In case of data-driven tests, we have multiple rows in TestCaseResult table for each dataset(each row in testdata profile)868 preReqTestCaseResults = testCaseResultService.findAllBySuiteResultIdAndTestCaseId(869 testCaseResult.getSuiteResultId(), testCase.getPreRequisite());870 if (preReqTestCaseResults != null) {871 for (TestCaseResult preReqTestCaseResult : preReqTestCaseResults) {872 testCasePreRequisiteIds = findTestCasePreRequisiteIds(preReqTestCaseResult, testCasePreRequisiteIds,873 depth + 1);874 testCasePreRequisiteIds.add(preReqTestCaseResult.getId());875 }876 }877 }878 } catch (Exception e) {879 log.error(e.getMessage(), e);880 }881 }882 return testCasePreRequisiteIds;883 }884 // ################################################ AFTER START ###################################################885 private void afterStart() throws Exception {886 setInitialCounts();887 }888 private void setInitialCounts() {889 List<TestDeviceResult> executionEnvironmentsResults890 = testDeviceResultService.findAllByTestPlanResultId(this.getTestPlanResult().getId());891 for (TestDeviceResult executionTestDeviceResult : executionEnvironmentsResults) {892 List<TestCaseResult> testCaseResults = testCaseResultService.findAllByEnvironmentResultId(executionTestDeviceResult.getId());893 for (TestCaseResult testCaseResult : testCaseResults) {894 testCaseResultService.updateResultCounts(testCaseResult);895 }896 List<TestSuiteResult> testSuitesResults = testSuiteResultService.findAllByEnvironmentResultId(executionTestDeviceResult.getId());897 for (TestSuiteResult testSuiteResult : testSuitesResults) {898 testSuiteResultService.updateResultCounts(testSuiteResult.getId());899 }900 testDeviceResultService.updateResultCounts(executionTestDeviceResult.getId());901 }902 }903 // ################################################ STOP ###################################################904 public void stop() throws Exception {905 beforeStop();906 stopQueuedEnvironments(AutomatorMessages.MSG_USER_ABORTED_EXECUTION, Boolean.TRUE);907 afterStop();908 }909 private void beforeStop() throws TestsigmaException {910 TestPlanResult testPlanResult = this.testPlanResultService.findByTestPlanIdAndStatusIsNot(this.testPlan.getId(),911 StatusConstant.STATUS_COMPLETED);912 if (testPlanResult == null) {913 throw new TestsigmaException("No Queued executions for test plan - " + this.getTestPlan().getName());914 }915 this.setTestPlanResult(testPlanResult);916 }917 private void stopQueuedEnvironments(String errorMessage, Boolean sendPendingExecutions) {918 List<TestDeviceResult> testDeviceResults = this.testDeviceResultService919 .findAllByTestPlanResultIdAndStatusIsNot(this.testPlanResult.getId(), StatusConstant.STATUS_COMPLETED);920 for (TestDeviceResult testDeviceResult : testDeviceResults) {921 testDeviceResultService.markEnvironmentResultAsStopped(testDeviceResult, errorMessage);922 testDeviceResultService.updateResultCounts(testDeviceResult.getId());923 }924 Timestamp currentTime = new Timestamp(java.lang.System.currentTimeMillis());925 TestPlanResult testPlanResult = this.testPlanResult;926 testPlanResult.setResult(ResultConstant.STOPPED);927 testPlanResult.setStatus(StatusConstant.STATUS_COMPLETED);928 testPlanResult.setMessage(errorMessage);929 testPlanResult.setEndTime(currentTime);930 testPlanResult.setDuration(testPlanResult.getEndTime().getTime() - testPlanResult.getStartTime().getTime());931 this.testPlanResultService.update(testPlanResult);932 try {933 if (sendPendingExecutions) {934 testDeviceResultService.sendPendingTestPlans();935 }936 } catch (Exception e) {937 log.error(e.getMessage(), e);938 }939 }940 private void afterStop() {941 }942 protected void setTestLabDetails(TestDevice testDevice, TestDeviceSettings settings,EnvironmentEntityDTO environmentEntityDTO)943 throws Exception {944 if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isRest())945 return;946 TestPlanLabType exeLabType = testDevice.getTestPlanLabType();947 setPlatformDetails(testDevice, settings, exeLabType, testDevice.getAgent(), environmentEntityDTO);948 }949 public void loadTestCase(String testDataSetName, TestCaseEntityDTO testCaseEntityDTO, AbstractTestPlan testPlan, TestDevice testDevice,950 Workspace workspace) throws Exception {951 String profileName = null;952 String environmentProfileName = null;953 Map<String, String> environmentParameters = null;954 List<com.testsigma.model.TestDataSet> databank = new ArrayList<>();955 com.testsigma.model.TestDataSet dataSet = null;956 if (testPlan.getEnvironmentId() != null) {957 Environment environment = testPlan.getEnvironment();958 environmentParameters = environment.getData();959 environmentProfileName = environment.getName();960 }961 List<TestStep> testSteps = testStepService.findAllByTestCaseIdAndEnabled(testCaseEntityDTO.getId());962 List<TestStepDTO> testStepDTOS = testStepMapper.mapDTOs(testSteps);963 Long testDataId = testCaseEntityDTO.getTestDataId();964 if (testDataId != null) {965 TestData testData = testDataProfileService.find(testCaseEntityDTO.getTestDataId());966 testCaseEntityDTO.setTestDataProfileName(testData.getTestDataName());967 databank = testData.getData();968 profileName = testData.getTestDataName();969 }970 if (!testCaseEntityDTO.getIsDataDriven()) {971 if (!databank.isEmpty()) {972 log.info("Test case is not data driven. but has associated test data id");973 int currentIndex = testCaseEntityDTO.getTestDataStartIndex();974 dataSet = databank.get(currentIndex);975 testCaseEntityDTO.setTestDataSetName(dataSet.getName());976 testCaseEntityDTO.setTestDataIndex(currentIndex);977 }978 } else {979 log.info("Test case is data driven...Matching data set with - " + testDataSetName);980 for (int i = 0; i < databank.size(); i++) {981 TestDataSet data = databank.get(i);982 if (data.getName().equals(testDataSetName)) {983 dataSet = data;984 testCaseEntityDTO.setTestDataIndex(i);985 break;986 }987 }988 testCaseEntityDTO.setTestDataSetName(dataSet.getName());989 testCaseEntityDTO.setExpectedToFail(dataSet.getExpectedToFail());990 }991 List<Long> testCaseIds = new ArrayList<>();992 testCaseIds.add(testCaseEntityDTO.getId());993 for (TestStepDTO testStepDTO : testStepDTOS) {994 if (testStepDTO.getStepGroupId() != null) {995 TestCase testCase = testCaseService.find(testStepDTO.getStepGroupId());996 checkTestCaseIsInReadyState(testCase);997 List<TestStep> childSteps;998 childSteps = testStepService.findAllByTestCaseIdAndEnabled(testStepDTO.getStepGroupId());999 List<TestStepDTO> childStepsDTOs = testStepMapper.mapDTOs(childSteps);1000 testStepDTO.setTestStepDTOS(childStepsDTOs);1001 testCaseIds.add(testStepDTO.getStepGroupId());1002 }1003 if (testStepDTO.getAddonActionId() != null) {1004 if (!testDevice.getTestPlanLabType().isHybrid()) {1005 AddonNaturalTextAction addonNaturalTextAction = addonNaturalTextActionService.findById(testStepDTO.getAddonActionId());1006 Addon addon = addonService.findById(addonNaturalTextAction.getAddonId());1007 if (addon.getStatus() == AddonStatus.DRAFT) {1008 throw new TestsigmaException(MessageConstants.DRAFT_PLUGIN_ALLOWED_IN_HYBRID_ONLY,1009 MessageConstants.DRAFT_PLUGIN_ALLOWED_IN_HYBRID_ONLY);1010 }1011 }1012 }1013 }1014 List<String> elementNames = testStepService.findElementNamesByTestCaseIds(testCaseIds);1015 elementNames.addAll(testStepService.findAddonActionElementsByTestCaseIds(testCaseIds));1016 List<Element> elementList = elementService.findByNameInAndWorkspaceVersionId(elementNames,1017 testDevice.getWorkspaceVersionId());1018 Map<String, Element> elements = new HashMap<>();1019 for (Element element : elementList) {1020 elements.put(element.getName().toLowerCase(), element);1021 }1022 if (!testCaseEntityDTO.getIsDataDriven()) {1023 if (!databank.isEmpty()) {1024 dataSet = databank.get(testCaseEntityDTO.getTestDataStartIndex());1025 testCaseEntityDTO.setTestDataSetName(dataSet.getName());1026 }1027 } else {1028 for (TestDataSet data : databank) {1029 if (data.getName().equals(testDataSetName)) {1030 dataSet = data;1031 break;1032 }1033 }1034 testCaseEntityDTO.setTestDataSetName(dataSet.getName());1035 testCaseEntityDTO.setExpectedToFail(dataSet.getExpectedToFail());1036 }1037 List<TestCaseStepEntityDTO> executableList = getExecutableTestSteps(1038 workspace.getWorkspaceType(), testStepDTOS,1039 elements, dataSet, testPlan.getId(),1040 environmentParameters, testCaseEntityDTO, environmentProfileName,1041 profileName,getStepGroupParentForLoopStepIdIndexes(testCaseEntityDTO));1042 appendPreSignedURLs(executableList, testCaseEntityDTO, testDevice,false, null, null);1043 testCaseEntityDTO.setTestSteps(executableList);1044 TestCaseResult testCaseResult = testCaseResultService.find(testCaseEntityDTO.getTestCaseResultId());1045 testCaseResultService.markTestCaseResultAsInProgress(testCaseResult);1046 }1047 private Map<Long, Integer> getStepGroupParentForLoopStepIdIndexes(TestCaseEntityDTO testCaseEntityDTO){1048 Map<Long, Integer> dataIndex = testCaseEntityDTO.getStepGroupParentForLoopStepIdIndexes();1049 if(!testCaseEntityDTO.getIsStepGroup()){1050 dataIndex.put(ParameterTestDataProcessor.OVERRIDE_STEP_GROUP_STEP_WITH_TEST_CASE_PROFILE_ID,1051 testCaseEntityDTO.getTestDataIndex() == null ? 0 : testCaseEntityDTO.getTestDataIndex());1052 }1053 return dataIndex;1054 }1055 private boolean isStepInsideForLoop(TestCaseStepEntityDTO testCaseStepEntity) throws ResourceNotFoundException {1056 if (testCaseStepEntity.getParentId() != null) {1057 TestStep testStep = testStepService.find(testCaseStepEntity.getParentId());1058 return (testStep.getType() == TestStepType.FOR_LOOP);1059 }1060 return false;1061 }1062 protected void appendPreSignedURLs(List<TestCaseStepEntityDTO> executableList, TestCaseEntityDTO testCaseEntity,1063 TestDevice testDevice, boolean isWhileLoop, Long stepGroupStepID, TestCaseStepEntityDTO parentGroupEntity)1064 throws ResourceNotFoundException {1065 Calendar cal = Calendar.getInstance();1066 cal.add(Calendar.HOUR, 10);1067 stepGroupStepID = (stepGroupStepID == null) ? 0 : stepGroupStepID;1068 StorageService storageService = this.storageServiceFactory.getStorageService();1069 for (TestCaseStepEntityDTO testCaseStepEntity : executableList) {1070 Integer index;1071 Long parentId = testCaseStepEntity.getParentId();1072 if(parentId == null)1073 parentId = 0L;1074 int rand =0;1075 if (parentGroupEntity != null && !isStepInsideForLoop(testCaseStepEntity)) {1076 index = (parentGroupEntity.getIndex() == null) ? 0 : parentGroupEntity.getIndex();1077 } else {1078 rand = new Random().ints(1, 100).findFirst().getAsInt();1079 index = (testCaseStepEntity.getIndex() == null) ? 0 : testCaseStepEntity.getIndex();1080 }1081 String screenShotPath = String.format("/executions/%s/%s_%s_%s_%s_%s_%s.%s", testCaseEntity.getTestCaseResultId(),1082 testCaseStepEntity.getId(), stepGroupStepID, parentId, testCaseStepEntity.getPosition(), index, rand ,"jpeg");1083 URL presignedURL = storageService.generatePreSignedURL(screenShotPath, StorageAccessLevel.WRITE, 600);1084 testCaseStepEntity.setScreenshotPath(presignedURL.toString());1085 handleUploadActionStep(testCaseStepEntity,storageService, testDevice);1086 handleInstallApp(testCaseStepEntity,storageService, testDevice);1087 if ((testCaseStepEntity.getTestCaseSteps() != null) && !testCaseStepEntity.getTestCaseSteps().isEmpty()) {1088 if (testCaseStepEntity.getConditionType() == TestStepConditionType.LOOP_WHILE) {1089 addScreenshotPresignedURLsForWhileLoop(testCaseStepEntity, testCaseEntity, stepGroupStepID, parentGroupEntity,storageService);1090 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice,true, stepGroupStepID, parentGroupEntity);1091 } else if (testCaseStepEntity.getType() == TestStepType.STEP_GROUP) {1092 Long parentGroupStepId = (stepGroupStepID != 0) ? stepGroupStepID : testCaseStepEntity.getId();1093 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice, isWhileLoop, parentGroupStepId, testCaseStepEntity);1094 } else {1095 appendPreSignedURLs(testCaseStepEntity.getTestCaseSteps(), testCaseEntity, testDevice, isWhileLoop, stepGroupStepID, parentGroupEntity);1096 }1097 }1098 if (isWhileLoop && !(testCaseStepEntity.getType() == TestStepType.STEP_GROUP)) {1099 addScreenshotPresignedURLsForWhileLoop(testCaseStepEntity, testCaseEntity, stepGroupStepID, parentGroupEntity,storageService);1100 }1101 }1102 }1103 private void addScreenshotPresignedURLsForWhileLoop(TestCaseStepEntityDTO testCaseStep, TestCaseEntityDTO testCaseEntity,1104 Long parentGroupStepId, TestCaseStepEntityDTO parentGroupEntity, StorageService storageService) {1105 parentGroupStepId = (parentGroupStepId == null) ? 0 : parentGroupStepId;1106 Map<String, String> additionalScreenshotPaths = new HashMap<>();1107 for (int iteration = 1; iteration <= NaturalTextActionConstants.WHILE_LOOP_MAX_LIMIT; iteration++) {1108 Calendar cal = Calendar.getInstance();1109 cal.add(Calendar.HOUR, 10);1110 Integer index = null;1111 if (parentGroupEntity != null) {1112 index = (parentGroupEntity.getIndex() == null) ? 0 : parentGroupEntity.getIndex();1113 } else {1114 index = (testCaseStep.getIndex() == null) ? 0 : testCaseStep.getIndex();1115 }1116 String screenShotPath = String.format("/executions/%s/%s_%s_%s_%s_%s.%s", testCaseEntity.getTestCaseResultId(),1117 testCaseStep.getId(), parentGroupStepId, iteration, testCaseStep.getPosition(), index, "jpeg");1118 URL preSignedURL = storageService.generatePreSignedURL(screenShotPath, StorageAccessLevel.WRITE, 600);1119 String iterationKey = String.format("%s_%s", iteration, testCaseStep.getIndex());1120 additionalScreenshotPaths.put(iterationKey, preSignedURL.toString());1121 }1122 testCaseStep.setAdditionalScreenshotPaths(additionalScreenshotPaths);1123 }1124 private void handleUploadActionStep(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1125 if (testCaseStepEntity.getAction() != null && testCaseStepEntity.getAction().toLowerCase().contains("upload")1126 && testCaseStepEntity.getNaturalTextActionId() != null && (testCaseStepEntity.getNaturalTextActionId().equals(969)1127 || testCaseStepEntity.getNaturalTextActionId().equals(10150))) {1128 handleFileActionStep(testCaseStepEntity,storageService, testDevice);1129 }1130 }1131 private void handleInstallApp(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1132 if (testCaseStepEntity.getAction() != null && testCaseStepEntity.getAction()1133 .toLowerCase().contains("installApp".toLowerCase()) && (testCaseStepEntity.getNaturalTextActionId() != null)1134 && (testCaseStepEntity.getNaturalTextActionId().equals(20003) || testCaseStepEntity.getNaturalTextActionId().equals(30003))) {1135 handleFileActionStep(testCaseStepEntity,storageService, testDevice);1136 }1137 }1138 private void handleFileActionStep(TestCaseStepEntityDTO testCaseStepEntity, StorageService storageService, TestDevice testDevice) {1139 com.testsigma.automator.entity.TestDataPropertiesEntity testDataPropertiesEntity = testCaseStepEntity.getTestDataMap().get(1140 testCaseStepEntity.getTestDataMap().keySet().stream().findFirst().get());1141 String fileUrl = testDataPropertiesEntity.getTestDataValue().replace("testsigma-storage://", "");1142 URL newUrl = storageService.generatePreSignedURL(fileUrl, StorageAccessLevel.READ, 180);1143 if(TestPlanLabType.TestsigmaLab == testDevice.getTestPlanLabType()) {1144 try {1145 newUrl = new URL(newUrl.toString().replace(applicationConfig.getServerUrl(), applicationConfig.getServerLocalUrl()));1146 } catch (MalformedURLException ignore) {}1147 }1148 testDataPropertiesEntity.setTestDataValuePreSignedURL(newUrl.toString());1149 }1150 private void setPlatformDetails(TestDevice testDevice, TestDeviceSettings settings,1151 TestPlanLabType testPlanLabType, Agent agent,EnvironmentEntityDTO environmentEntityDTO) throws TestsigmaException {1152 populatePlatformOsDetails(testDevice, settings, testPlanLabType, agent);1153 if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isWeb()) {1154 populatePlatformBrowserDetails(testDevice, settings, testPlanLabType, agent,environmentEntityDTO);1155 }1156 }1157 protected void populatePlatformOsDetails(TestDevice testDevice, TestDeviceSettings settings,1158 TestPlanLabType testPlanLabType, Agent agent)1159 throws TestsigmaException {1160 PlatformOsVersion platformOsVersion = null;1161 if (testPlanLabType == TestPlanLabType.Hybrid) {1162 Platform platform = null;1163 String osVersion = null;1164 if ((testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isWeb()) && agent != null) {1165 platform = agent.getOsType().getPlatform();1166 osVersion = agent.getPlatformOsVersion(agent.getOsType().getPlatform());1167 } else if (testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isMobile() && testDevice.getDeviceId() != null) {1168 AgentDevice agentDevice = this.agentDeviceService.find(testDevice.getDeviceId());1169 osVersion = agentDevice.getPlatformOsVersion();1170 platform = agentDevice.getOsName().getPlatform();1171 }1172 platformOsVersion = platformsService.getPlatformOsVersion(platform, osVersion, testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType(), testPlanLabType);1173 }1174 else {1175 platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), testPlanLabType);1176 }1177 if (testPlanLabType != TestPlanLabType.PrivateGrid)1178 settings.setPlatform(platformOsVersion.getPlatform());1179 else1180 settings.setPlatform(testDevice.getPlatform());1181 if (TestPlanLabType.Hybrid == testPlanLabType) {1182 settings.setOsVersion(platformOsVersion.getVersion());1183 }1184 }1185 protected void populatePlatformBrowserDetails(TestDevice testDevice, TestDeviceSettings settings,1186 TestPlanLabType testPlanLabType, Agent agent,EnvironmentEntityDTO environmentEntityDTO)1187 throws TestsigmaException {1188 PlatformBrowserVersion platformBrowserVersion = null;1189 if (agent != null && testPlanLabType == TestPlanLabType.Hybrid) {1190 Platform platform = agent.getOsType().getPlatform();1191 String osVersion = agent.getPlatformOsVersion(platform);1192 Browsers browser = OSBrowserType.getBrowser(testDevice.getBrowser());1193 String browserVersion = agent.getBrowserVersion(browser.toString());1194 platformBrowserVersion = platformsService.getPlatformBrowserVersion(platform, osVersion, browser, browserVersion, testPlanLabType);1195 } else {1196 platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), testPlanLabType);1197 }1198 if (testPlanLabType.isHybrid()) {1199 matchHybridBrowserVersion(agent, platformBrowserVersion, testDevice, platformBrowserVersion.getName(),environmentEntityDTO);1200 }1201 if (testPlanLabType != TestPlanLabType.PrivateGrid)1202 settings.setBrowser(platformBrowserVersion.getName().name());1203 else settings.setBrowser(Browsers.getBrowser(testDevice.getBrowser()).name());1204 if (testPlanLabType == TestPlanLabType.Hybrid) {1205 settings.setBrowserVersion(platformBrowserVersion.getVersion());1206 settings.setHybridBrowserDriverPath(1207 platformsService.getDriverPath(platformBrowserVersion.getPlatform(),1208 platformBrowserVersion.getVersion(), platformBrowserVersion.getName(),1209 platformBrowserVersion.getDriverVersion()));1210 } else {1211 if (testPlanLabType != TestPlanLabType.PrivateGrid)1212 settings.setBrowserVersion(platformBrowserVersion.getVersion());1213 else settings.setBrowserVersion(testDevice.getBrowserVersion());1214 }1215 }1216 private void matchHybridBrowserVersion(Agent agent1, PlatformBrowserVersion platformBrowserVersion,1217 TestDevice testDevice, Browsers browser,EnvironmentEntityDTO environmentEntityDTO)1218 throws TestsigmaException {1219 if ((agent1 != null) && (platformBrowserVersion != null)) {1220 Agent agent = agentService.find(agent1.getId());1221 for (AgentBrowser agentBrowser : agent.getBrowserList()) {1222 Browsers aBrowser = Browsers.getBrowser(agentBrowser.getName().getBrowserName());1223 if ((browser == aBrowser) &&1224 (Boolean.TRUE == testDevice.getMatchBrowserVersion()) &&1225 !platformBrowserVersion.getVersion().equals("" + agentBrowser.getMajorVersion())) {1226 environmentEntityDTO.setErrorCode(ExceptionErrorCodes.BROWSER_VERSION_NOT_AVAILABLE);1227 log.info("Local agent browser version[" + agentBrowser.getMajorVersion()1228 + "] doesn't match selected browser version[" + platformBrowserVersion.getVersion() + "]");1229 }1230 }1231 }1232 }1233 public List<TestCaseStepEntityDTO> getExecutableTestSteps(WorkspaceType workspaceType,1234 List<TestStepDTO> testStepDTOS,1235 Map<String, Element> elementMap,1236 com.testsigma.model.TestDataSet testDataSet,1237 Long testPlanId, Map<String, String> environmentParams,1238 TestCaseEntityDTO testCaseEntityDTO, String environmentParamSetName,1239 String dataProfile, Map<Long, Integer> dataSetIndex) throws Exception {1240 List<Long> loopIds = new ArrayList<>();1241 List<TestCaseStepEntityDTO> toReturn = new ArrayList<>();1242 for (TestStepDTO testStepDTO : testStepDTOS) {1243 if (loopIds.contains(testStepDTO.getParentId())) {1244 continue;1245 }1246 if (testStepDTO.getType() == TestStepType.FOR_LOOP) {1247 loopIds.add(testStepDTO.getId());1248 new ForLoopStepProcessor(webApplicationContext, toReturn, workspaceType, elementMap, testStepDTO,1249 testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName, dataProfile, dataSetIndex).processLoop(testStepDTOS, loopIds);1250 continue;1251 } else if (testStepDTO.getType() == TestStepType.WHILE_LOOP) {1252 loopIds.add(testStepDTO.getId());1253 new WhileLoopStepProcessor(webApplicationContext, toReturn, workspaceType, elementMap, testStepDTO,1254 testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName, dataProfile, dataSetIndex).processWhileLoop(testStepDTOS, loopIds);1255 continue;1256 } else if (testStepDTO.getType() == TestStepType.REST_STEP) {1257 new RestStepProcessor(webApplicationContext, toReturn, workspaceType, elementMap, testStepDTO,1258 testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName, dataProfile, dataSetIndex).process();1259 continue;1260 }1261 TestCaseStepEntityDTO stepEntity = new StepProcessor(webApplicationContext, toReturn, workspaceType,1262 elementMap, testStepDTO, testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName,1263 dataProfile, dataSetIndex).processStep();1264 stepEntity.setStepGroupId(testStepDTO.getStepGroupId());1265 stepEntity.setParentId(testStepDTO.getParentId());1266 stepEntity.setConditionType(testStepDTO.getConditionType());1267 stepEntity.setVisualEnabled(testStepDTO.getVisualEnabled());1268 if (testStepDTO.getTestStepDTOS() != null) {1269 for (TestStepDTO subTestStepDTO : testStepDTO.getTestStepDTOS()) {1270 List<TestCaseStepEntityDTO> stepGroupSpecialSteps = new ArrayList<>();1271 if (stepEntity.getTestCaseSteps() == null) {1272 stepEntity.setTestCaseSteps(new ArrayList<>());1273 }1274 //TODO: check logic for test step key Generation and recursive logic for step group generation1275 if (loopIds.contains(subTestStepDTO.getParentId())) {1276 continue;1277 }1278 if (subTestStepDTO.getType() == TestStepType.FOR_LOOP) {1279 loopIds.add(subTestStepDTO.getId());1280 new ForLoopStepProcessor(webApplicationContext, stepGroupSpecialSteps, workspaceType, elementMap, subTestStepDTO,1281 testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName, dataProfile, dataSetIndex)1282 .processLoop(testStepDTO.getTestStepDTOS(), loopIds);1283 stepEntity.getTestCaseSteps().addAll(stepGroupSpecialSteps);1284 continue;1285 } else if (subTestStepDTO.getType() == TestStepType.WHILE_LOOP) {1286 loopIds.add(subTestStepDTO.getId());1287 new WhileLoopStepProcessor(webApplicationContext, stepGroupSpecialSteps, workspaceType, elementMap,1288 subTestStepDTO, testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName,1289 dataProfile, dataSetIndex).processWhileLoop(testStepDTO.getTestStepDTOS(), loopIds);1290 stepEntity.getTestCaseSteps().addAll(stepGroupSpecialSteps);1291 continue;1292 } else if (subTestStepDTO.getType() == TestStepType.REST_STEP) {1293 new RestStepProcessor(webApplicationContext, stepGroupSpecialSteps, workspaceType, elementMap, subTestStepDTO,1294 testPlanId, testDataSet, environmentParams, testCaseEntityDTO, environmentParamSetName, dataProfile, dataSetIndex).process();1295 stepEntity.getTestCaseSteps().addAll(stepGroupSpecialSteps);1296 continue;1297 }1298 TestCaseStepEntityDTO cstepEntity = new StepProcessor(webApplicationContext, toReturn, workspaceType,1299 elementMap, subTestStepDTO, testPlanId, testDataSet, environmentParams, testCaseEntityDTO,1300 environmentParamSetName, dataProfile, dataSetIndex).processStep();1301 cstepEntity.setParentId(subTestStepDTO.getParentId());1302 cstepEntity.setConditionType(subTestStepDTO.getConditionType());1303 stepEntity.getTestCaseSteps().add(cstepEntity);1304 }1305 }1306 toReturn.add(stepEntity);1307 }1308 return toReturn;1309 }1310 private WorkspaceType getAppType() {1311 return this.testPlan.getWorkspaceVersion().getWorkspace().getWorkspaceType();1312 }1313 protected void populatePreRequisiteEnvironmentResultIds(TestPlanResult executionResult){1314 List<TestDeviceResult> environmentResults = testDeviceResultService.findAllByTestPlanResultId(executionResult.getId());1315 for(TestDeviceResult environmentResult: environmentResults){1316 Long executionEnvironmentPreRequisiteId = environmentResult.getTestDevice().getPrerequisiteTestDevicesId();1317 if(executionEnvironmentPreRequisiteId != null){1318 TestDeviceResult preRequisiteEnvironmentResult = testDeviceResultService.findByTestPlanResultIdAndTestDeviceId(executionResult.getId(),executionEnvironmentPreRequisiteId);1319 environmentResult.setPrerequisiteTestDeviceResultId(preRequisiteEnvironmentResult.getId());1320 testDeviceResultService.update(environmentResult);1321 }1322 }1323 }1324 protected boolean isWaitingOnEnvironmentPrerequisite(TestDeviceResult environmentResult) throws ResourceNotFoundException {1325 Long preRequisiteEnvironmentResultId = environmentResult.getPrerequisiteTestDeviceResultId();1326 if(preRequisiteEnvironmentResultId != null){1327 TestDeviceResult preRequisiteEnvironmentResult = testDeviceResultService.find(preRequisiteEnvironmentResultId);1328 if(preRequisiteEnvironmentResult.getStatus() != StatusConstant.STATUS_COMPLETED){1329 return true;1330 }1331 }1332 return false;1333 }1334 protected boolean isEnvironmentPrerequisiteResultSuccessful(TestDeviceResult environmentResult) throws ResourceNotFoundException {1335 Long preRequisiteEnvironmentResultId = environmentResult.getPrerequisiteTestDeviceResultId();1336 if(preRequisiteEnvironmentResultId != null){1337 TestDeviceResult preRequisiteEnvironmentResult = testDeviceResultService.find(preRequisiteEnvironmentResultId);1338 if(preRequisiteEnvironmentResult.getResult() == ResultConstant.SUCCESS){...
isWaitingOnEnvironmentPrerequisite
Using AI Code Generation
1import com.testsigma.service.AgentExecutionService2import com.testsigma.service.EnvironmentService3def agentExecutionService = new AgentExecutionService()4def environmentService = new EnvironmentService()5def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite()6def isEnvironmentAvailable = environmentService.isEnvironmentAvailable()7if (isWaitingOnEnvironmentPrerequisite) {8 if (!isEnvironmentAvailable) {9 throw new Exception("Environment is not available")10 }11}12import com.testsigma.service.AgentExecutionService13import com.testsigma.service.EnvironmentService14def agentExecutionService = new AgentExecutionService()15def environmentService = new EnvironmentService()16def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite()17def isEnvironmentAvailable = environmentService.isEnvironmentAvailable()18if (isWaitingOnEnvironmentPrerequisite) {19 if (!isEnvironmentAvailable) {20 throw new Exception("Environment is not available")21 }22}
isWaitingOnEnvironmentPrerequisite
Using AI Code Generation
1import com.testsigma.service.AgentExecutionService;2def agentExecutionService = new AgentExecutionService();3def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite();4import com.testsigma.service.AgentExecutionService;5def agentExecutionService = new AgentExecutionService();6def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite();7public class AgentExecutionService {8 public boolean isWaitingOnEnvironmentPrerequisite() {9 return AgentExecutionManager.getInstance().isWaitingOnEnvironmentPrerequisite();10 }11}12public class AgentExecutionService {13 public boolean isWaitingOnEnvironmentPrerequisite() {14 return AgentExecutionManager.getInstance().isWaitingOnEnvironmentPrerequisite();15 }16}
isWaitingOnEnvironmentPrerequisite
Using AI Code Generation
1import com.testsigma.service.AgentExecutionService2import com.testsigma.service.AgentExecutionServiceFactory3def agentExecutionService = AgentExecutionServiceFactory.getAgentExecutionService()4def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite(agentName, environmentName, environmentPrerequisiteName)5println("isWaitingOnEnvironmentPrerequisite: $isWaitingOnEnvironmentPrerequisite")6import com.testsigma.service.AgentExecutionService7import com.testsigma.service.AgentExecutionServiceFactory8def agentExecutionService = AgentExecutionServiceFactory.getAgentExecutionService()9def isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite(agentName, environmentName, environmentPrerequisiteName)10println("isWaitingOnEnvironmentPrerequisite: $isWaitingOnEnvironmentPrerequisite")
isWaitingOnEnvironmentPrerequisite
Using AI Code Generation
1import com.testsigma.service.AgentExecutionService;2AgentExecutionService agentExecutionService = new AgentExecutionService();3boolean isWaitingOnEnvironmentPrerequisite = agentExecutionService.isWaitingOnEnvironmentPrerequisite("agent_name", "environment_name");4if(isWaitingOnEnvironmentPrerequisite){5}else{6}
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!!