How to use fetchTestCaseResultsReRunList method of com.testsigma.service.AgentExecutionService class

Best Testsigma code snippet using com.testsigma.service.AgentExecutionService.fetchTestCaseResultsReRunList

Source:AgentExecutionService.java Github

copy

Full Screen

...369 TestSuiteResult parentTestSuiteResult = testSuiteResultsReRunList.stream().filter(370 er -> er.getSuiteId().equals(testSuite.getId())).findAny().orElse(null);371 if (parentTestSuiteResult != null) {372 testSuiteResult.setReRunParentId(parentTestSuiteResult.getId());373 fetchTestCaseResultsReRunList(parentTestSuiteResult.getId());374 } else {375 log.info("Test Suite (" + testSuite.getId() + ") is not eligible for Re-run. Skipping...");376 return null;377 }378 }379 testSuiteResult.setEnvironmentResultId(testDeviceResult.getId());380 testSuiteResult.setResult(ResultConstant.QUEUED);381 testSuiteResult.setStatus(StatusConstant.STATUS_CREATED);382 testSuiteResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);383 testSuiteResult.setSuiteId(testSuite.getId());384 testSuiteResult.setStartTime(new Timestamp(System.currentTimeMillis()));385 testSuiteResult.setTestPlanResultId(testDeviceResult.getTestPlanResultId());386 Optional<TestDeviceSuite> environmentSuiteMapping =387 testDeviceSuiteService.findFirstByTestDeviceAndTestSuite(testDevice, testSuite);388 environmentSuiteMapping389 .ifPresent(suiteMapping -> testSuiteResult.setPosition(suiteMapping.getPosition().longValue()));390 TestSuiteResultSuiteDetails suiteDetails = new TestSuiteResultSuiteDetails();391 suiteDetails.setName(testSuite.getName());392 suiteDetails.setPreRequisite(testSuite.getPreRequisite());393 testSuiteResult.setSuiteDetails(suiteDetails);394 return this.testSuiteResultService.create(testSuiteResult);395 }396 private TestDeviceResult createEnvironmentResult(TestPlanResult testPlanResult,397 TestDevice testDevice) throws TestsigmaException {398 TestDeviceResult testDeviceResult = new TestDeviceResult();399 if (getIsReRun() && (testPlanResult.getReRunParentId() != null)) {400 TestDeviceResult parentTestDeviceResult = testDeviceResultsReRunList.stream().filter(401 er -> er.getTestDeviceId().equals(testDevice.getId())).findAny().orElse(null);402 if (parentTestDeviceResult != null) {403 testDeviceResult.setReRunParentId(parentTestDeviceResult.getId());404 fetchTestSuitesResultsReRunList(parentTestDeviceResult.getId());405 } else {406 log.info("Execution Environment (" + testDevice.getId() + ") is not eligible for Re-run. Skipping...");407 return null;408 }409 }410 testDeviceResult.setTestPlanResultId(testPlanResult.getId());411 testDeviceResult.setResult(ResultConstant.QUEUED);412 testDeviceResult.setStatus(StatusConstant.STATUS_CREATED);413 testDeviceResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);414 testDeviceResult.setStartTime(new Timestamp(System.currentTimeMillis()));415 testDeviceResult.setTestDeviceId(testDevice.getId());416 testDeviceResult.setAppUploadVersionId(getUploadVersionId(testDevice));417 testDeviceResult.setTestDeviceSettings(getExecutionTestDeviceSettings(testDevice));418 testDeviceResult = testDeviceResultService.create(testDeviceResult);419 testDeviceResult.setTestDevice(testDevice);420 return testDeviceResult;421 }422 private Long getUploadVersionId(TestDevice testDevice) throws ResourceNotFoundException {423 Long uploadVersionId = getUploadVersionIdFromRuntime(testDevice.getId());424 if (uploadVersionId != null) {425 log.debug("Got uploadVersionId from runTimeData ", uploadVersionId, testDevice.getId());426 uploadVersionId = this.uploadVersionService.find(uploadVersionId).getId();427 } else {428 uploadVersionId = testDevice.getAppUploadVersionId();429 if (uploadVersionId == null && testDevice.getAppUploadId() != null)430 uploadVersionId = uploadService.find(testDevice.getAppUploadId()).getLatestVersionId();431 }432 return uploadVersionId;433 }434 private Long getUploadVersionIdFromRuntime(Long environmentId) {435 log.debug("Fetching uploadVersionId from runTimeData for EnvironmentId::"+environmentId);436 if (getRunTimeData() != null) {437 JSONObject uploadVersions = getRunTimeData().optJSONObject("uploadVersions");438 log.debug("Fetching uploadVersionId from runTimeData for uploadVersions::", uploadVersions);439 if (uploadVersions != null) {440 log.debug("Fetching uploadVersionId from runTimeData for uploadVersions::", uploadVersions);441 return uploadVersions.optLong(environmentId+"");442 }443 }444 return null;445 }446 private TestPlanResult createTestPlanResult() throws ResourceNotFoundException {447 TestPlanResult testPlanResult = new TestPlanResult();448 if (getIsReRun()) {449 if (this.getParentTestPlanResultId() != null) {450 testPlanResult.setReRunParentId(this.getParentTestPlanResultId());451 } else {452 testPlanResult.setReRunParentId(testPlan.getLastRunId());453 }454 testPlanResult.setReRunType(getReRunType());455 fetchEnvironmentResultsReRunList();456 }457 if ((this.getRunTimeData() != null) && (this.getRunTimeData().has("build_number"))) {458 testPlanResult.setBuildNo(this.getRunTimeData().getString("build_number"));459 }460 testPlanResult.setResult(ResultConstant.QUEUED);461 testPlanResult.setStatus(StatusConstant.STATUS_CREATED);462 testPlanResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);463 testPlanResult.setTestPlanId(this.getTestPlan().getId());464 testPlanResult.setStartTime(new Timestamp(System.currentTimeMillis()));465 testPlanResult.setTriggeredType(this.triggeredType);466 testPlanResult.setScheduleId(this.scheduleId);467 TestPlanDetails testPlanDetails = new TestPlanDetails();468 testPlanDetails.setElementTimeout(testPlan.getElementTimeOut());469 testPlanDetails.setPageTimeout(testPlan.getPageTimeOut());470 testPlanDetails.setOnAbortedAction(testPlan.getOnAbortedAction());471 testPlanDetails.setRecoveryAction(testPlan.getRecoveryAction());472 testPlanDetails.setGroupPrerequisiteFail(testPlan.getOnSuitePreRequisiteFail());473 testPlanDetails.setTestCasePrerequisiteFail(testPlan.getOnTestcasePreRequisiteFail());474 testPlanDetails.setTestStepPrerequisiteFail(testPlan.getOnStepPreRequisiteFail());475 testPlanDetails.setScreenshotOption(testPlan.getScreenshot());476 if (this.getTestPlan().getEnvironmentId() != null) {477 Environment environment = environmentService.find(this.getTestPlan().getEnvironmentId());478 testPlanResult.setEnvironmentId(environment.getId());479 testPlanDetails.setEnvironmentParamName(environment.getName());480 }481 testPlanResult.setTestPlanDetails(testPlanDetails);482 return testPlanResultService.create(testPlanResult);483 }484 private void checkForDataDrivenIntegrity(TestCase testCase) throws TestsigmaException {485 TestData testData = testCase.getTestData();486 if (testData == null && testCase.getIsDataDriven()) {487 String errorMessage = com.testsigma.constants.MessageConstants.getMessage(488 MessageConstants.MSG_UNKNOWN_TEST_DATA_DATA_DRIVEN_CASE,489 testCase.getName()490 );491 throw new TestsigmaException(errorMessage);492 }493 }494 private TestDeviceSettings getExecutionTestDeviceSettings(TestDevice testDevice) throws TestsigmaException {495 TestDeviceSettings settings = new TestDeviceSettings();496 TestPlanLabType exeLabType = this.getTestPlan().getTestPlanLabType();497 if (testDevice.getPlatformDeviceId() != null) {498 settings.setDeviceName(platformsService.getPlatformDevice(testDevice.getPlatformDeviceId(), exeLabType).getName());499 }500 if (testDevice.getPlatformBrowserVersionId() != null) {501 PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), exeLabType);502 settings.setBrowserVersion(platformBrowserVersion.getVersion());503 settings.setBrowser(platformBrowserVersion.getName().name());504 }505 if (testDevice.getPlatformScreenResolutionId() != null) {506 settings.setResolution(platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), exeLabType).getResolution());507 }508 if (testDevice.getPlatformOsVersionId() != null) {509 PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), exeLabType);510 settings.setPlatform(platformOsVersion.getPlatform());511 settings.setOsVersion(platformOsVersion.getPlatformVersion());512 }513 if (exeLabType == TestPlanLabType.Hybrid) {514 settings.setBrowser(testDevice.getBrowser());515 }516 settings.setAppActivity(testDevice.getAppActivity());517 settings.setAppPackage(testDevice.getAppPackage());518 settings.setAppPathType(testDevice.getAppPathType());519 settings.setAppUrl(testDevice.getAppUrl());520 settings.setAppUploadId(testDevice.getAppUploadId());521 settings.setTitle(testDevice.getTitle());522 settings.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());523 return settings;524 }525 private Boolean isScheduledExecution() {526 return this.triggeredType.equals(ExecutionTriggeredType.SCHEDULED);527 }528 // ############################################ RESULT ENTRIES PROCESSING ###########################################529 private void processResultEntries() throws Exception {530 if (canPushToLabAgent()) {531 processResultEntriesForLabAgent();532 } else if (canPushToHybridAgent()) {533 processResultEntriesForHybridAgent();534 }535 }536 private Boolean canPushToLabAgent() throws IntegrationNotFoundException {537 return !this.testPlan.getTestPlanLabType().equals(TestPlanLabType.Hybrid) && this.integrationsService.findByApplication(Integration.TestsigmaLab) != null;538 }539 private Boolean canPushToHybridAgent() {540 return this.testPlan.getTestPlanLabType().equals(TestPlanLabType.Hybrid);541 }542 private void processResultEntriesForLabAgent() throws Exception {543 List<TestDeviceResult> testDeviceResults = testDeviceResultService.findAllByTestPlanResultId(544 this.testPlanResult.getId());545 processResultEntries(testDeviceResults, StatusConstant.STATUS_CREATED);546 }547 private void processResultEntriesForHybridAgent() throws Exception {548 List<TestDeviceResult> testDeviceResults = testDeviceResultService.findAllByTestPlanResultId(549 this.testPlanResult.getId());550 processResultEntries(testDeviceResults, StatusConstant.STATUS_CREATED);551 }552 public void processResultEntries(List<TestDeviceResult> testDeviceResults, StatusConstant inStatus)553 throws Exception {554 for (TestDeviceResult testDeviceResult : testDeviceResults) {555 if (testDeviceResult.getTestDevice().getAgent() == null && this.getTestPlan().getTestPlanLabType().isHybrid()) {556 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.AGENT_HAS_BEEN_REMOVED, StatusConstant.STATUS_CREATED);557 } else if (this.getTestPlan().getTestPlanLabType().isHybrid() && !agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId())) {558 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult,559 AutomatorMessages.AGENT_INACTIVE, StatusConstant.STATUS_CREATED);560 } else if(this.getTestPlan().getTestPlanLabType().isHybrid() && testDeviceResult.getTestDevice().getDeviceId()!=null &&561 agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId()) && !agentDeviceService.isDeviceOnline(testDeviceResult.getTestDevice().getDeviceId())){562 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult,563 agentDeviceService.find(testDeviceResult.getTestDevice().getDeviceId()).getName()+ " "+AutomatorMessages.DEVICE_NOT_ONLINE, StatusConstant.STATUS_CREATED);564 }565 else {566 processEnvironmentResult(testDeviceResult, inStatus);567 }568 }569 testDeviceResultService.updateExecutionConsolidatedResults(this.testPlanResult.getId(),570 Boolean.TRUE);571 }572 public void processEnvironmentResult(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {573 testDeviceResultService.markEnvironmentResultAsInPreFlight(testDeviceResult, inStatus);574 if (!this.getTestPlan().getTestPlanLabType().isHybrid()) {575 EnvironmentEntityDTO environmentEntityDTO = loadEnvironment(testDeviceResult,576 StatusConstant.STATUS_PRE_FLIGHT);577 try {578 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);579 } catch (Exception e) {580 log.error(e.getMessage(), e);581 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, e.getMessage(),582 StatusConstant.STATUS_PRE_FLIGHT);583 }584 }585 }586 public void processEnvironmentResultInParallel(TestDeviceResult testDeviceResult, StatusConstant inStatus) throws Exception {587 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(588 testDeviceResult, inStatus);589 testDeviceResult.setSuiteResults(testSuiteResults);590 for (TestSuiteResult testSuiteResult : testSuiteResults) {591 testSuiteResultService.markTestSuiteResultAsInFlight(testSuiteResult, inStatus);592 if (!this.getTestPlan().getTestPlanLabType().isHybrid()) {593 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);594 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, StatusConstant.STATUS_PRE_FLIGHT));595 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();596 testSuiteEntityDTOS.add(testSuiteEntity);597 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);598 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);599 try {600 pushEnvironmentToLab(testDeviceResult, environmentEntityDTO);601 } catch (Exception e) {602 log.error(e.getMessage(), e);603 testSuiteResultService.markTestSuiteResultAsFailed(testSuiteResult, e.getMessage(),604 StatusConstant.STATUS_PRE_FLIGHT);605 }606 }607 }608 testDeviceResultService.updateEnvironmentConsolidatedResults(testDeviceResult);609 }610 public EnvironmentEntityDTO loadEnvironment(TestDeviceResult testDeviceResult, StatusConstant inStatus)611 throws Exception {612 List<TestSuiteEntityDTO> testSuiteEntityDTOS = loadTestSuites(testDeviceResult, inStatus);613 EnvironmentEntityDTO environmentEntityDTO = loadEnvironmentDetails(testDeviceResult);614 environmentEntityDTO.setTestSuites(testSuiteEntityDTOS);615 return environmentEntityDTO;616 }617 public EnvironmentEntityDTO loadEnvironmentDetails(TestDeviceResult testDeviceResult) throws Exception {618 TestPlanSettingEntityDTO testPlanSettingEntityDTO = this.testPlanMapper.mapSettings(this.testPlan);619 EnvironmentEntityDTO environmentEntityDTO = this.testDeviceResultMapper.map(testDeviceResult);620 TestDevice testDevice = testDeviceResult.getTestDevice();621 if (testDevice.getDeviceId() != null) {622 AgentDevice agentDevice = agentDeviceService.find(testDevice.getDeviceId());623 environmentEntityDTO.setAgentDeviceUuid(agentDevice.getUniqueId());624 }625 environmentEntityDTO.setStorageType(storageServiceFactory.getStorageService().getStorageType());626 environmentEntityDTO.setWorkspaceType(this.getAppType());627 environmentEntityDTO.setTestPlanSettings(testPlanSettingEntityDTO);628 environmentEntityDTO.setMatchBrowserVersion(testDevice.getMatchBrowserVersion());629 environmentEntityDTO.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());630 TestDeviceSettings settings = getExecutionTestDeviceSettings(testDevice);631 settings.setExecutionName(testPlan.getName());632 settings.setEnvironmentParamId(this.testPlan.getEnvironmentId());633 settings.setEnvRunId(testDeviceResult.getId());634 setTestLabDetails(testDevice, settings,environmentEntityDTO);635 environmentEntityDTO.setEnvSettings(this.testPlanMapper.mapToDTO(settings));636 Agent agent = null;637 if (testDevice.getAgentId() != null)638 agent = this.agentService.find(testDevice.getAgentId());639 setAgentJWTApiKey(environmentEntityDTO, agent);640 setAvailableFeatures(environmentEntityDTO);641 return environmentEntityDTO;642 }643 private List<TestSuiteEntityDTO> loadTestSuites(TestDeviceResult testDeviceResult, StatusConstant inStatus) {644 List<TestSuiteEntityDTO> testSuiteEntityDTOS = new ArrayList<>();645 List<TestSuiteResult> testSuiteResults = this.testSuiteResultService.findPendingTestSuiteResults(testDeviceResult,646 inStatus);647 for (TestSuiteResult testSuiteResult : testSuiteResults) {648 TestSuiteEntityDTO testSuiteEntity = this.testSuiteResultMapper.map(testSuiteResult);649 testSuiteEntity.setTestCases(loadTestCases(testSuiteResult, inStatus));650 testSuiteEntityDTOS.add(testSuiteEntity);651 }652 return testSuiteEntityDTOS;653 }654 private List<TestCaseEntityDTO> loadTestCases(TestSuiteResult testSuiteResult, StatusConstant inStatus) {655 List<TestCaseResult> testCaseResults = this.testCaseResultService.findActiveSuiteTestCaseResults(656 testSuiteResult.getId(), inStatus);657 List<TestCaseEntityDTO> testCases = new ArrayList<>();658 for (TestCaseResult testCaseResult : testCaseResults) {659 TestCaseEntityDTO testCaseEntity = this.testCaseResultMapper.map(testCaseResult);660 testCaseEntity.setDataDrivenTestCases(loadDataDrivenTestCases(testCaseResult, inStatus));661 testCases.add(testCaseEntity);662 }663 return testCases;664 }665 private List<TestCaseEntityDTO> loadDataDrivenTestCases(TestCaseResult testCaseResult, StatusConstant inStatus) {666 List<TestCaseResult> dataDrivenTestCaseResults =667 this.testCaseResultService.findAllByParentIdAndStatus(testCaseResult.getId(), inStatus);668 return this.testCaseResultMapper.map(dataDrivenTestCaseResults);669 }670 private void setAgentJWTApiKey(EnvironmentEntityDTO environmentEntityDTO, com.testsigma.model.Agent id) throws ResourceNotFoundException {671 TestDeviceSettingsDTO envSettings = environmentEntityDTO.getEnvSettings();672 if (id != null) {673 Agent agent = this.agentService.find(id.getId());674 envSettings.setJwtApiKey(agent.generateJwtApiKey(jwtTokenService.getServerUuid()));675 }676 environmentEntityDTO.setEnvSettings(envSettings);677 }678 private void setAvailableFeatures(EnvironmentEntityDTO dto) throws ResourceNotFoundException, SQLException {679 dto.getTestPlanSettings().setHasSuggestionFeature(true);680 }681 private void pushEnvironmentToLab(TestDeviceResult testDeviceResult, EnvironmentEntityDTO environmentEntityDTO) throws Exception {682 ObjectMapper objectMapper = new ObjectMapper();683 objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);684 objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);685 TestDeviceEntity testDeviceEntity = objectMapper.readValue(objectMapper.writeValueAsString(environmentEntityDTO),686 TestDeviceEntity.class);687 try {688 testDeviceResultService.markEnvironmentResultAsInProgress(testDeviceResult, StatusConstant.STATUS_PRE_FLIGHT,689 Boolean.TRUE);690 new TestPlanRunTask(testDeviceEntity).start();691 log.info("Successfully pushed Execution Environment[" + testDeviceEntity.getEnvironmentResultId()692 + "] to Testsigma Lab");693 } catch (Exception e) {694 log.error(e.getMessage(), e);695 String message = "Error while pushing environment to agent - " + e.getMessage();696 throw new TestsigmaException(message, message);697 }698 }699 private void saveRunTimeData() {700 JSONObject runtimeJSONObj = this.getRunTimeData();701 if (runtimeJSONObj != null && runtimeJSONObj.has("runtime_data")) {702 RunTimeData runTimeData = new RunTimeData();703 runTimeData.setTestPlanRunId(this.getTestPlanResult().getId());704 if (runtimeJSONObj.has("runtime_data")) {705 runTimeData.setData(runtimeJSONObj.getJSONObject("runtime_data"));706 }707 this.runTimeDataService.create(runTimeData);708 }709 }710 public void checkTestCaseIsInReadyState(TestCase testCase) throws TestsigmaException {711 if (!testCase.getStatus().equals(TestCaseStatus.READY) && testPlan.getEntityType()=="TEST_PLAN") {712 String message = testCase.getIsStepGroup() ? com.testsigma.constants.MessageConstants.getMessage(MessageConstants.STEP_GROUP_NOT_READY, testCase.getName()) :713 MessageConstants.TESTCASE_NOT_READY;714 throw new TestsigmaException(message, message);715 }716 }717 private void fetchEnvironmentResultsReRunList() {718 testDeviceResultsReRunList = new ArrayList<>();719 if (getReRunType() == ReRunType.ALL_TESTS) {720 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultId(this.getParentTestPlanResultId());721 } else if (getReRunType() == ReRunType.ONLY_FAILED_TESTS) {722 testDeviceResultsReRunList = testDeviceResultService.findAllByTestPlanResultIdAndResultIsNot723 (this.getParentTestPlanResultId(), ResultConstant.SUCCESS);724 }725 }726 private void fetchTestSuitesResultsReRunList(Long parentEnvironmentResultId) {727 testSuiteResultsReRunList = new ArrayList<>();728 try {729 TestDeviceResult parentTestDeviceResult = testDeviceResultService.find(parentEnvironmentResultId);730 List<TestSuiteResult> failedTestSuites;731 if (parentTestDeviceResult != null) {732 if (getReRunType() == ReRunType.ALL_TESTS) {733 testSuiteResultsReRunList = testSuiteResultService.findAllByEnvironmentResultId(parentTestDeviceResult.getId());734 } else if (getReRunType() == ReRunType.ONLY_FAILED_TESTS) {735 failedTestSuites = testSuiteResultService.findAllByEnvironmentResultIdAndResultIsNot736 (parentTestDeviceResult.getId(), ResultConstant.SUCCESS);737 if (failedTestSuites.size() > 0) {738 for (TestSuiteResult testSuiteResult : failedTestSuites) {739 List<Long> testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(testSuiteResult, new ArrayList<>(), 0);740 if (testSuitePreRequisiteIds.size() > 0) {741 List<TestSuiteResult> preRequisiteResults = testSuiteResultService.findBySuiteResultIds(testSuitePreRequisiteIds);742 testSuiteResultsReRunList.addAll(preRequisiteResults);743 }744 testSuiteResultsReRunList.add(testSuiteResult);745 }746 }747 }748 }749 } catch (Exception e) {750 log.error(e.getMessage(), e);751 }752 }753 private List<Long> findTestSuitePreRequisiteIds(TestSuiteResult testSuiteResult, List<Long> testSuitePreRequisiteIds,754 int depth) {755 if (depth < PRE_REQUISITE_DEPTH) {756 TestSuiteResult preReqTestSuiteResult;757 try {758 TestSuite testSuite = testSuiteResult.getTestSuite();759 if (testSuite.getPreRequisite() != null) {760 preReqTestSuiteResult = testSuiteResultService.findByEnvironmentResultIdAndSuiteId(761 testSuiteResult.getEnvironmentResultId(), testSuite.getPreRequisite());762 if (preReqTestSuiteResult != null) {763 testSuitePreRequisiteIds = findTestSuitePreRequisiteIds(preReqTestSuiteResult, testSuitePreRequisiteIds,764 depth + 1);765 testSuitePreRequisiteIds.add(preReqTestSuiteResult.getId());766 }767 }768 } catch (Exception e) {769 log.error(e.getMessage(), e);770 }771 }772 return testSuitePreRequisiteIds;773 }774 private void fetchTestCaseResultsReRunList(Long parentTestSuiteResultId) {775 testCaseResultsReRunList = new ArrayList<>();776 try {777 TestSuiteResult parentTestSuiteResult = testSuiteResultService.find(parentTestSuiteResultId);778 List<TestCaseResult> failedTestCases;779 if (parentTestSuiteResult != null) {780 if (getReRunType() == ReRunType.ALL_TESTS || isTestSuiteAPrerequisite(parentTestSuiteResult)) {781 testCaseResultsReRunList = testCaseResultService.findAllBySuiteResultId(parentTestSuiteResult.getId());782 } else if (getReRunType() == ReRunType.ONLY_FAILED_TESTS) {783 failedTestCases = testCaseResultService.findAllBySuiteResultIdAndResultIsNot784 (parentTestSuiteResult.getId(), ResultConstant.SUCCESS);785 if (failedTestCases.size() > 0) {786 for (TestCaseResult testCaseResult : failedTestCases) {787 List<Long> testCasePreRequisiteIds = findTestCasePreRequisiteIds(testCaseResult, new ArrayList<>(), 0);788 //If a prerequisite is failed, it will be already available in failedTestCases. So we need to add only prerequisites with SUCCESS status....

Full Screen

Full Screen

fetchTestCaseResultsReRunList

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.AgentExecutionService;2import com.testsigma.service.AgentExecutionServiceLocator;3import com.testsigma.service.TestCaseResult;4import com.testsigma.service.TestCaseResultList;5import java.io.File;6import java.io.FileOutputStream;7import java.io.IOException;8import java.io.InputStream;9import java.io.OutputStream;10import java.rmi.RemoteException;11import java.util.ArrayList;12import java.util.Arrays;13import java.util.HashMap;14import java.util.List;15import java.util.Map;16import java.util.stream.Collectors;17import org.apache.commons.io.IOUtils;18import org.apache.commons.lang3.StringUtils;19public class FetchTestCaseResultsReRunList {20public static void main(String[] args) throws Exception {21 AgentExecutionService agentExecutionService = new AgentExecutionServiceLocator();

Full Screen

Full Screen

fetchTestCaseResultsReRunList

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.AgentExecutionService;2AgentExecutionService agentExecutionService = new AgentExecutionService();3List<TestRun> testCaseResultsReRunList = agentExecutionService.fetchTestCaseResultsReRunList(testcaseId, executionId, testSuiteId, agentId);4int totalTestRuns = testCaseResultsReRunList.size();5int testRunId = testCaseResultsReRunList.get(0).getTestRunId();6String testRunName = testCaseResultsReRunList.get(0).getTestRunName();7String testRunResult = testCaseResultsReRunList.get(0).getTestRunResult();8String testRunStartTime = testCaseResultsReRunList.get(0).getTestRunStartTime();9String testRunEndTime = testCaseResultsReRunList.get(0).getTestRunEndTime();10String testRunStatus = testCaseResultsReRunList.get(0).getTestRunStatus();11String testRunExecutionTime = testCaseResultsReRunList.get(0).getTestRunExecutionTime();12int testRunExecutionTimeInSeconds = testCaseResultsReRunList.get(0).getTestRunExecutionTimeInSeconds();13long testRunExecutionTimeInMilliSeconds = testCaseResultsReRunList.get(0).getTestRunExecutionTimeInMilliSeconds();14int testRunExecutionTimeInMinutes = testCaseResultsReRunList.get(0).getTestRunExecutionTimeInMinutes();

Full Screen

Full Screen

fetchTestCaseResultsReRunList

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.AgentExecutionService;2import java.util.List;3String testPlanId = "5d5e7f5b3e3a9d002a0c5f1f";4String executionId = "5d5e7f5b3e3a9d002a0c5f20";5List<String> testCaseIds = AgentExecutionService.fetchTestCaseResultsReRunList(testPlanId, executionId);6System.out.println(testCaseIds);

Full Screen

Full Screen

fetchTestCaseResultsReRunList

Using AI Code Generation

copy

Full Screen

1import com.testsigma.common.model.TestCase2import com.testsigma.service.AgentExecutionService3import java.util.List4def tcList = AgentExecutionService.fetchTestCaseResultsReRunList()5import com.testsigma.common.model.TestCase6import com.testsigma.service.AgentExecutionService7import java.util.List8def tcList = AgentExecutionService.fetchTestCaseResultsReRunList()9import com.testsigma.common.model.TestCase10import com.testsigma.service.AgentExecutionService11import java.util.List12def tcList = AgentExecutionService.fetchTestCaseResultsReRunList()13import com.testsigma.common.model.TestCase14import com.testsigma.service.AgentExecutionService15import java.util.List16def tcList = AgentExecutionService.fetchTestCaseResultsReRunList()

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 Testsigma automation tests on LambdaTest cloud grid

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

Most used method in AgentExecutionService

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful