How to use getTestDataStart method of com.testsigma.model.TestCase class

Best Testsigma code snippet using com.testsigma.model.TestCase.getTestDataStart

Source:AgentExecutionService.java Github

copy

Full Screen

...191 TestDeviceResult testDeviceResult) throws TestsigmaException {192 List<TestCase> testCases = this.testCaseService.findAllBySuiteId(testSuiteResult.getSuiteId());193 int testDataStartIndex;194 for (TestCase testCase : testCases) {195 testDataStartIndex = testCase.getTestDataStartIndex();196 TestCaseResult testCaseResult = createTestCaseResult(testSuite, testCase, testDeviceResult, testSuiteResult,197 null);198 if (testCaseResult != null && testPlan instanceof TestPlan) {199 testCase.setLastRunId(testCaseResult.getId());200 testCase.setTestDataStartIndex(testDataStartIndex);201 testCaseService.update(testCase);202 }203 }204 }205 protected void populateStepGroupTestStepResults(TestStep testStep, TestCaseResult testCaseResult,206 TestDeviceResult testDeviceResult,207 TestStepResult parentTestStepResult) {208 List<TestStep> testSteps = this.testStepService.findAllByTestCaseId(testStep.getStepGroupId());209 for (TestStep step : testSteps) {210 createTestStepResult(step, testDeviceResult, testCaseResult, parentTestStepResult);211 }212 }213 protected void createTestStepResult(TestStep testStep,214 TestDeviceResult testDeviceResult,215 TestCaseResult testCaseResult,216 TestStepResult parentTestStepResult) {217 log.info("Creating TestStepResult for:" + testStep);218 TestStepResult testStepResult = new TestStepResult();219 testStepResult.setEnvRunId(testDeviceResult.getId());220 testStepResult.setResult(ResultConstant.QUEUED);221 testStepResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);222 testStepResult.setStepId(testStep.getId());223 testStepResult.setTestCaseId(testCaseResult.getTestCaseId());224 testStepResult.setStepGroupId(testStep.getStepGroupId());225 testStepResult.setGroupResultId((parentTestStepResult != null) ? parentTestStepResult.getId() : null);226 testStepResult.setTestCaseResultId(testCaseResult.getId());227 testStepResult.setPriority(testStep.getPriority());228 StepDetails stepDetails = new StepDetails();229 stepDetails.setNaturalTextActionId(testStep.getNaturalTextActionId());230 stepDetails.setAction(testStep.getAction());231 stepDetails.setPriority(testStep.getPriority());232 stepDetails.setPreRequisiteStepId(testStep.getPreRequisiteStepId());233 stepDetails.setConditionType(testStep.getConditionType());234 stepDetails.setParentId(testStep.getParentId());235 stepDetails.setType(testStep.getType());236 stepDetails.setStepGroupId(testStep.getStepGroupId());237 stepDetails.setAction(testStep.getAction());238 stepDetails.setPosition(testStep.getPosition());239 stepDetails.setTestDataName(testCaseResult.getTestDataSetName());240 stepDetails.setDataMap(testStep.getDataMapBean());241 testStepResult.setStepDetails(stepDetails);242 if (parentTestStepResult != null) {243 testStepResult.setParentResultId(parentTestStepResult.getId());244 }245 testStepResult = this.testStepResultService.create(testStepResult);246 if (TestStepType.STEP_GROUP.equals(testStep.getType())) {247 populateStepGroupTestStepResults(testStep, testCaseResult, testDeviceResult, testStepResult);248 }249 }250 private void populateDataDrivenTestCaseResults(AbstractTestSuite testSuite,251 TestCase testCase,252 TestDeviceResult testDeviceResult,253 TestSuiteResult testSuiteResult,254 TestCaseResult parentTestCaseResult) throws TestsigmaException {255 log.info("Creating Data driven TestcaseResult for testcase:" + testCase.getName());256 TestPlanResult testPlanResult = testPlanResultService.find(testDeviceResult.getTestPlanResultId());257 isDataDrivenRerun = testDeviceResult.getReRunParentId() != null;258 TestData testData = testCase.getTestData();259 List<TestDataSet> testDataSets = testData.getData();260 if(isDataDrivenRerun && !parentTestCaseResult.getIsStepGroup()){261 log.info("Creating data driven re run iteration results for test case - " + parentTestCaseResult.getId());262 this.createTestCaseDataDrivenReRunResult(testPlanResult, testDataSets, testCase, testSuite, testDeviceResult,263 testSuiteResult, parentTestCaseResult);264 } else {265 int start = testCase.getTestDataStart();266 int end = testCase.getTestDataEnd(testDataSets.size());267 for (int i = start; i <= end && i < testDataSets.size(); i++) {268 TestDataSet testDataSet = testDataSets.get(i);269 this.createTestCaseIterationResult(testDataSets, testDataSet, testCase, testSuite, testDeviceResult,270 testSuiteResult, parentTestCaseResult);271 }272 testCase.setTestDataStartIndex(start);273 }274 testCase.setIsDataDriven(true);275 }276 private TestCaseDataDrivenResult createTestCaseDataDrivenResult(TestDataSet testDataSet, TestCaseResult testCaseResult) {277 TestCaseDataDrivenResult testCaseDataDrivenResult = new TestCaseDataDrivenResult();278 testCaseDataDrivenResult.setEnvRunId(testCaseResult.getEnvironmentResultId());279 testCaseDataDrivenResult.setTestData(new ObjectMapperService().convertToJson(testDataSet));280 testCaseDataDrivenResult.setTestDataName(testDataSet.getName());281 testCaseDataDrivenResult.setTestCaseId(testCaseResult.getTestCaseId());282 testCaseDataDrivenResult.setTestCaseResultId(testCaseResult.getParentId());283 testCaseDataDrivenResult.setIterationResultId(testCaseResult.getId());284 return testCaseDataDrivenResultService.create(testCaseDataDrivenResult);285 }286 private TestCaseResult createTestCaseResult(AbstractTestSuite testSuite,287 TestCase testCase,288 TestDeviceResult testDeviceResult,289 TestSuiteResult testSuiteResult,290 TestCaseResult parentTestCaseResult) throws TestsigmaException {291 log.info("Creating TestcaseResult for:" + testCase);292 checkForDataDrivenIntegrity(testCase);293 TestCaseResult testCaseResult = new TestCaseResult();294 testCaseResult = setReRunParentId(testSuiteResult, testCase, testCaseResult, parentTestCaseResult);295 if (testCaseResult == null)296 return null;297 testCaseResult.setEnvironmentResultId(testDeviceResult.getId());298 testCaseResult.setTestPlanResultId(testDeviceResult.getTestPlanResultId());299 testCaseResult.setTestCaseId(testCase.getId());300 testCaseResult.setSuiteId(testSuiteResult.getSuiteId());301 testCaseResult.setSuiteResultId(testSuiteResult.getId());302 testCaseResult.setResult(ResultConstant.QUEUED);303 testCaseResult.setStatus(StatusConstant.STATUS_CREATED);304 testCaseResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);305 testCaseResult.setIsStepGroup(testCase.getIsStepGroup());306 if (parentTestCaseResult != null) {307 testCaseResult.setParentId(parentTestCaseResult.getId());308 }309 if (!testCase.getIsDataDriven()) {310 TestData testData = testCase.getTestData();311 if (testData != null) {312 TestDataSet testDataSet = testData.getData().get(testCase.getTestDataStartIndex());313 testCaseResult.setTestDataSetName(testDataSet.getName());314 if (parentTestCaseResult != null) {315 testCaseResult.setIteration(testDataSet.getName());316 }317 }318 }319 Optional<SuiteTestCaseMapping> suiteTestCaseMapping =320 suiteTestCaseMappingService.findFirstByTestSuiteAndTestCase(testSuite, testCase);321 TestCaseResult finalTestCaseResult = testCaseResult;322 suiteTestCaseMapping323 .ifPresent(suiteMapping -> finalTestCaseResult.setPosition(suiteMapping.getPosition().longValue()));324 if (suiteTestCaseMapping.isPresent()) {325 testCaseResult.setPosition(suiteTestCaseMapping.get().getPosition().longValue());326 }327 testCaseResult.setTestCaseTypeId(testCase.getType());328 testCaseResult.setTestCaseStatus(testCase.getStatus());329 testCaseResult.setPriorityId(testCase.getPriority());330 testCaseResult.setIsDataDriven(testCase.getIsDataDriven());331 testCaseResult.setTestDataId(testCase.getTestDataId());332 testCaseResult.setTestCaseDetails(testCaseDetails(testCaseResult, testCase));333 testCaseResult = this.testCaseResultService.create(testCaseResult);334 if (testCase.getIsDataDriven()) {335 populateDataDrivenTestCaseResults(testSuite, testCase, testDeviceResult, testSuiteResult, testCaseResult);336 }337 return testCaseResult;338 }339 private TestCaseResult setReRunParentId(TestSuiteResult testSuiteResult, TestCase testCase, TestCaseResult testCaseResult, TestCaseResult parentTestCaseResult) {340 if (getIsReRun() && (testSuiteResult.getReRunParentId() != null)) {341 TestCaseResult reRunParentTestCaseResult = testCaseResultsReRunList.stream().filter(342 er -> er.getTestCaseId().equals(testCase.getId()) && er.getIteration() == null).findAny().orElse(null);343 if(getReRunType() == ReRunType.ALL_TESTS)344 reRunParentTestCaseResult = testCaseResultService.getLastReRunResult(reRunParentTestCaseResult);345 if (reRunParentTestCaseResult != null) {346 testCaseResult.setReRunParentId(reRunParentTestCaseResult.getId());347 } else {348 log.info("Test Case (" + testCase.getId() + ") is not eligible for Re-run. Skipping...");349 return null;350 }351 }352 if (!testCase.getIsDataDriven() && testCase.getTestData() != null && parentTestCaseResult != null) {353 TestData testData = testCase.getTestData();354 TestDataSet testDataSet = testData.getData().get(testCase.getTestDataStartIndex());355 if (getIsReRun() && (testSuiteResult.getReRunParentId() != null)) {356 TestCaseResult reRunParentTestCaseResult = testCaseResultsReRunList.stream().filter(357 er -> er.getTestCaseId().equals(testCase.getId()) && er.getIteration() != null && er.getIteration().equals(testDataSet.getName())).findAny().orElse(null);358 if (reRunParentTestCaseResult != null) {359 testCaseResult.setReRunParentId(reRunParentTestCaseResult.getId());360 } else {361 log.info("Test Case (" + testCase.getId() + ") is not eligible for Re-run. Skipping...");362 return null;363 }364 }365 }366 return testCaseResult;367 }368 private TestCaseDetails testCaseDetails(TestCaseResult testCaseResult, TestCase testCase) {369 TestCaseDetails testCaseDetails = new TestCaseDetails();370 testCaseDetails.setName(testCase.getName());371 testCaseDetails.setTestData(testCaseResult.getIteration());372 testCaseDetails.setTestDataSetName(testCaseResult.getTestDataSetName());373 testCaseDetails.setPrerequisite(testCase.getPreRequisite());374 return testCaseDetails;375 }376 private TestSuiteResult createTestSuiteResult(AbstractTestSuite testSuite, TestDeviceResult testDeviceResult,377 TestDevice testDevice) {378 TestSuiteResult testSuiteResult = new TestSuiteResult();379 if (getIsReRun() && (testDeviceResult.getReRunParentId() != null)) {380 TestSuiteResult parentTestSuiteResult = testSuiteResultsReRunList.stream().filter(381 er -> er.getSuiteId().equals(testSuite.getId())).findAny().orElse(null);382 if (parentTestSuiteResult != null) {383 testSuiteResult.setReRunParentId(parentTestSuiteResult.getId());384 fetchTestCaseResultsReRunList(parentTestSuiteResult.getId());385 } else {386 log.info("Test Suite (" + testSuite.getId() + ") is not eligible for Re-run. Skipping...");387 return null;388 }389 }390 testSuiteResult.setEnvironmentResultId(testDeviceResult.getId());391 testSuiteResult.setResult(ResultConstant.QUEUED);392 testSuiteResult.setStatus(StatusConstant.STATUS_CREATED);393 testSuiteResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);394 testSuiteResult.setSuiteId(testSuite.getId());395 testSuiteResult.setStartTime(new Timestamp(System.currentTimeMillis()));396 testSuiteResult.setTestPlanResultId(testDeviceResult.getTestPlanResultId());397 Optional<TestDeviceSuite> environmentSuiteMapping =398 testDeviceSuiteService.findFirstByTestDeviceAndTestSuite(testDevice, testSuite);399 environmentSuiteMapping400 .ifPresent(suiteMapping -> testSuiteResult.setPosition(suiteMapping.getPosition().longValue()));401 TestSuiteResultSuiteDetails suiteDetails = new TestSuiteResultSuiteDetails();402 suiteDetails.setName(testSuite.getName());403 suiteDetails.setPreRequisite(testSuite.getPreRequisite());404 testSuiteResult.setSuiteDetails(suiteDetails);405 return this.testSuiteResultService.create(testSuiteResult);406 }407 private TestDeviceResult createEnvironmentResult(TestPlanResult testPlanResult,408 TestDevice testDevice) throws TestsigmaException {409 TestDeviceResult testDeviceResult = new TestDeviceResult();410 TestPlanResult parentExecutionResult = testPlanResultService.getFirstParentResult(testPlanResult);411 if (getIsReRun() && (parentExecutionResult.getId() != null)) {412 TestDeviceResult parentTestDeviceResult = testDeviceResultsReRunList.stream().filter(413 er -> er.getTestDeviceId().equals(testDevice.getId())).findAny().orElse(null);414 if (parentTestDeviceResult != null) {415 TestDeviceResult childTestDevResult = testDeviceResultService.getLastReRunResult(parentTestDeviceResult);416 testDeviceResult.setReRunParentId(childTestDevResult.getId());417 fetchTestSuitesResultsReRunList(parentTestDeviceResult.getId());418 } else {419 log.info("Execution Environment (" + testDevice.getId() + ") is not eligible for Re-run. Skipping...");420 return null;421 }422 }423 testDeviceResult.setTestPlanResultId(testPlanResult.getId());424 testDeviceResult.setResult(ResultConstant.QUEUED);425 testDeviceResult.setStatus(StatusConstant.STATUS_CREATED);426 testDeviceResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);427 testDeviceResult.setStartTime(new Timestamp(System.currentTimeMillis()));428 testDeviceResult.setTestDeviceId(testDevice.getId());429 testDeviceResult.setAppUploadVersionId(getUploadVersionId(testDevice));430 testDeviceResult.setTestDeviceSettings(getExecutionTestDeviceSettings(testDevice));431 testDeviceResult.setTestPlanLabType(testDevice.getTestPlanLabType());432 testDeviceResult.setWorkspaceVersionId(testDevice.getWorkspaceVersionId());433 testDeviceResult = testDeviceResultService.create(testDeviceResult);434 testDeviceResult.setTestDevice(testDevice);435 return testDeviceResult;436 }437 private Long getUploadVersionId(TestDevice testDevice) throws ResourceNotFoundException {438 Long uploadVersionId = getUploadVersionIdFromRuntime(testDevice.getId());439 if (uploadVersionId != null) {440 log.debug("Got uploadVersionId from runTimeData ", uploadVersionId, testDevice.getId());441 uploadVersionId = this.uploadVersionService.find(uploadVersionId).getId();442 } else {443 uploadVersionId = testDevice.getAppUploadVersionId();444 if (uploadVersionId == null && testDevice.getAppUploadId() != null)445 uploadVersionId = uploadService.find(testDevice.getAppUploadId()).getLatestVersionId();446 }447 return uploadVersionId;448 }449 private Long getUploadVersionIdFromRuntime(Long environmentId) {450 log.debug("Fetching uploadVersionId from runTimeData for EnvironmentId::"+environmentId);451 if (getRunTimeData() != null) {452 JSONObject uploadVersions = getRunTimeData().optJSONObject("uploadVersions");453 log.debug("Fetching uploadVersionId from runTimeData for uploadVersions::", uploadVersions);454 if (uploadVersions != null) {455 log.debug("Fetching uploadVersionId from runTimeData for uploadVersions::", uploadVersions);456 return uploadVersions.optLong(environmentId+"");457 }458 }459 return null;460 }461 private TestPlanResult createTestPlanResult() throws ResourceNotFoundException {462 TestPlanResult testPlanResult = new TestPlanResult();463 if (getIsReRun()) {464 if (this.getParentTestPlanResultId() != null) {465 testPlanResult.setReRunParentId(this.getParentTestPlanResultId());466 } else {467 testPlanResult.setReRunParentId(testPlan.getLastRunId());468 }469 testPlanResult.setReRunType(getReRunType());470 fetchEnvironmentResultsReRunList();471 }472 if ((this.getRunTimeData() != null) && (this.getRunTimeData().has("build_number"))) {473 testPlanResult.setBuildNo(this.getRunTimeData().getString("build_number"));474 }475 testPlanResult.setResult(ResultConstant.QUEUED);476 testPlanResult.setStatus(StatusConstant.STATUS_CREATED);477 testPlanResult.setMessage(AutomatorMessages.MSG_EXECUTION_CREATED);478 testPlanResult.setTestPlanId(this.getTestPlan().getId());479 testPlanResult.setStartTime(new Timestamp(System.currentTimeMillis()));480 testPlanResult.setTriggeredType(this.triggeredType);481 testPlanResult.setScheduleId(this.scheduleId);482 TestPlanDetails testPlanDetails = new TestPlanDetails();483 testPlanDetails.setElementTimeout(testPlan.getElementTimeOut());484 testPlanDetails.setPageTimeout(testPlan.getPageTimeOut());485 testPlanDetails.setOnAbortedAction(testPlan.getOnAbortedAction());486 testPlanDetails.setRecoveryAction(testPlan.getRecoveryAction());487 testPlanDetails.setGroupPrerequisiteFail(testPlan.getOnSuitePreRequisiteFail());488 testPlanDetails.setTestCasePrerequisiteFail(testPlan.getOnTestcasePreRequisiteFail());489 testPlanDetails.setTestStepPrerequisiteFail(testPlan.getOnStepPreRequisiteFail());490 testPlanDetails.setScreenshotOption(testPlan.getScreenshot());491 if (this.getTestPlan().getEnvironmentId() != null) {492 Environment environment = environmentService.find(this.getTestPlan().getEnvironmentId());493 testPlanResult.setEnvironmentId(environment.getId());494 testPlanDetails.setEnvironmentParamName(environment.getName());495 }496 testPlanResult.setTestPlanDetails(testPlanDetails);497 return testPlanResultService.create(testPlanResult);498 }499 private void checkForDataDrivenIntegrity(TestCase testCase) throws TestsigmaException {500 TestData testData = testCase.getTestData();501 if (testData == null && testCase.getIsDataDriven()) {502 String errorMessage = com.testsigma.constants.MessageConstants.getMessage(503 MessageConstants.MSG_UNKNOWN_TEST_DATA_DATA_DRIVEN_CASE,504 testCase.getName()505 );506 throw new TestsigmaException(errorMessage);507 }508 }509 private TestDeviceSettings getExecutionTestDeviceSettings(TestDevice testDevice) throws TestsigmaException {510 TestDeviceSettings settings = new TestDeviceSettings();511 TestPlanLabType exeLabType = testDevice.getTestPlanLabType();512 if (!(testDevice.getTestPlanLabType().isHybrid() && testDevice.getWorkspaceVersion().getWorkspace().getWorkspaceType().isMobile()) && testDevice.getPlatformDeviceId() != null) {513 settings.setDeviceName(platformsService.getPlatformDevice(testDevice.getPlatformDeviceId(), exeLabType).getName());514 }515 if (testDevice.getPlatformBrowserVersionId() != null) {516 PlatformBrowserVersion platformBrowserVersion = platformsService.getPlatformBrowserVersion(testDevice.getPlatformBrowserVersionId(), exeLabType);517 settings.setBrowserVersion(platformBrowserVersion.getVersion());518 settings.setBrowser(platformBrowserVersion.getName().name());519 }520 if (testDevice.getPlatformScreenResolutionId() != null) {521 settings.setResolution(platformsService.getPlatformScreenResolution(testDevice.getPlatformScreenResolutionId(), exeLabType).getResolution());522 }523 if (testDevice.getPlatformOsVersionId() != null) {524 PlatformOsVersion platformOsVersion = platformsService.getPlatformOsVersion(testDevice.getPlatformOsVersionId(), exeLabType);525 settings.setPlatform(platformOsVersion.getPlatform());526 settings.setOsVersion(platformOsVersion.getPlatformVersion());527 }528 if (exeLabType == TestPlanLabType.Hybrid || exeLabType == TestPlanLabType.PrivateGrid) {529 settings.setBrowser(testDevice.getBrowser());530 }531 settings.setAppActivity(testDevice.getAppActivity());532 settings.setAppPackage(testDevice.getAppPackage());533 settings.setAppPathType(testDevice.getAppPathType());534 settings.setAppUrl(testDevice.getAppUrl());535 settings.setAppUploadId(testDevice.getAppUploadId());536 settings.setTitle(testDevice.getTitle());537 settings.setCreateSessionAtCaseLevel(testDevice.getCreateSessionAtCaseLevel());538 return settings;539 }540 private Boolean isScheduledExecution() {541 return this.triggeredType.equals(ExecutionTriggeredType.SCHEDULED);542 }543 // ############################################ RESULT ENTRIES PROCESSING ###########################################544 private void processResultEntries() throws Exception {545 List<TestDeviceResult> testDeviceResults = testDeviceResultService.findAllByTestPlanResultId(546 this.testPlanResult.getId());547 for(TestDeviceResult testDeviceResult : testDeviceResults) {548 if (canPushToLabAgent(testDeviceResult)) {549 processResultEntriesForLabAgent(testDeviceResult);550 } else if (canPushToHybridAgent(testDeviceResult)) {551 processResultEntriesForHybridAgent(testDeviceResult);552 }553 }554 }555 private Boolean canPushToLabAgent(TestDeviceResult testDeviceResult) throws IntegrationNotFoundException {556 return !testDeviceResult.getTestPlanLabType().equals(TestPlanLabType.Hybrid) && this.integrationsService.findByApplication(Integration.TestsigmaLab) != null;557 }558 private Boolean canPushToHybridAgent(TestDeviceResult testDeviceResult) {559 return testDeviceResult.getTestPlanLabType().equals(TestPlanLabType.Hybrid);560 }561 private void processResultEntriesForLabAgent(TestDeviceResult testDeviceResult) throws Exception {562 processResultEntries(testDeviceResult, StatusConstant.STATUS_CREATED);563 }564 private void processResultEntriesForHybridAgent(TestDeviceResult testDeviceResult) throws Exception {565 processResultEntries(testDeviceResult, StatusConstant.STATUS_CREATED);566 }567 public void processResultEntries(TestDeviceResult testDeviceResult, StatusConstant inStatus)568 throws Exception {569 if (testDeviceResult.getTestDevice().getAgent() == null && testDeviceResult.getTestPlanLabType().isHybrid()) {570 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.AGENT_HAS_BEEN_REMOVED, StatusConstant.STATUS_CREATED);571 } else if (testDeviceResult.getTestPlanLabType().isHybrid() && !agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId())) {572 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, AutomatorMessages.AGENT_INACTIVE, StatusConstant.STATUS_CREATED);573 } else if(testDeviceResult.getTestPlanLabType().isHybrid() && testDeviceResult.getTestDevice().getDeviceId()!=null && agentService.isAgentActive(testDeviceResult.getTestDevice().getAgentId()) && !agentDeviceService.isDeviceOnline(testDeviceResult.getTestDevice().getDeviceId())){574 testDeviceResultService.markEnvironmentResultAsFailed(testDeviceResult, agentDeviceService.find(testDeviceResult.getTestDevice().getDeviceId()).getName()+ " "+AutomatorMessages.DEVICE_NOT_ONLINE, StatusConstant.STATUS_CREATED);575 } else {576 processEnvironmentResultOnSuccessfulChecks(testDeviceResult, inStatus);577 }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,...

Full Screen

Full Screen

Source:TestCase.java Github

copy

Full Screen

...143 @Transient144 private List<String> tagNames;145 @Transient146 private Integer testDataStart;147 public Integer getTestDataStart(){148 return testDataStart != null && testDataStart > -1 ? testDataStart :149 this.getTestDataStartIndex() != null && this.getTestDataStartIndex() > -1 ? this.getTestDataStartIndex(): 0;150 }151 @Transient152 private Integer testDataEnd;153 public Integer getTestDataEnd(Integer testDataSize){154 return testDataEnd!= null && testDataEnd >-1 ? testDataEnd : this.getTestDataEndIndex() != null && this.getTestDataEndIndex() > -1 ? this.getTestDataEndIndex()155 : testDataSize-1;156 }157 public Boolean getIsDataDriven() {158 return isDataDriven != null && isDataDriven;159 }160 public Calendar getCalendarTimeFromTimestamp(Timestamp time) {161 if (time == null) {162 return null;163 }...

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.TestCase;2public class 2 {3public static void main(String[] args) {4TestCase tc = new TestCase();5System.out.println(tc.getTestDataStart());6}7}8import com.testsigma.model.TestCase;9public class 3 {10public static void main(String[] args) {11TestCase tc = new TestCase();12System.out.println(tc.getTestDataEnd());13}14}15import com.testsigma.model.TestCase;16public class 4 {17public static void main(String[] args) {18TestCase tc = new TestCase();19System.out.println(tc.getTestData());20}21}22import com.testsigma.model.TestCase;23public class 5 {24public static void main(String[] args) {25TestCase tc = new TestCase();26System.out.println(tc.getTestCaseName());27}28}29import com.testsigma.model.TestCase;30public class 6 {31public static void main(String[] args) {32TestCase tc = new TestCase();33System.out.println(tc.getTestCaseId());34}35}36import com.testsigma.model.TestCase;37public class 7 {38public static void main(String[] args) {39TestCase tc = new TestCase();40System.out.println(tc.getTestSuiteName());41}42}43import com.testsigma.model.TestCase;44public class 8 {45public static void main(String[] args) {46TestCase tc = new TestCase();47System.out.println(tc.getTestSuiteId());48}49}50import com.testsigma.model.TestCase;51public class 9 {52public static void main(String[] args) {53TestCase tc = new TestCase();54System.out.println(tc.getTestPlanName());55}56}57import com.testsigma.model.TestCase;58public class 10 {

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.TestCase;2import com.testsigma.model.TestData;3public class 2 {4 public static void main(String[] args) {5 TestCase testCase = new TestCase();6 String testDataStart = testCase.getTestDataStart();7 System.out.println("testDataStart = " + testDataStart);8 }9}10import com.testsigma.model.TestCase;11import com.testsigma.model.TestData;12public class 3 {13 public static void main(String[] args) {14 TestCase testCase = new TestCase();15 String testDataEnd = testCase.getTestDataEnd();16 System.out.println("testDataEnd = " + testDataEnd);17 }18}19import com.testsigma.model.TestCase;20import com.testsigma.model.TestData;21public class 4 {22 public static void main(String[] args) {23 TestCase testCase = new TestCase();24 TestData testData = testCase.getTestData();25 System.out.println("testData = " + testData);26 }27}28import com.testsigma.model.TestCase;29import com.testsigma.model.TestData;30public class 5 {31 public static void main(String[] args) {32 TestCase testCase = new TestCase();33 TestData testData = testCase.getTestData();34 System.out.println("testData = " + testData);35 }36}37import com.testsigma.model.TestCase;38import com.testsigma.model.TestData;39public class 6 {40 public static void main(String[] args) {41 TestCase testCase = new TestCase();42 TestData testData = testCase.getTestData();43 System.out.println("testData = " + testData);44 }45}46import com.testsigma.model.TestCase;47import com.testsigma.model.TestData;48public class 7 {49 public static void main(String[] args) {50 TestCase testCase = new TestCase();51 TestData testData = testCase.getTestData();52 System.out.println("testData = " + testData);53 }54}

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1package com.testsigma.model;2public class TestCase {3public String getTestDataStart() {4return "TestDataStart";5}6}7package com.testsigma.model;8public class TestCase {9public String getTestDataEnd() {10return "TestDataEnd";11}12}13package com.testsigma.model;14public class TestCase {15public String getTestDataStart() {16return "TestDataStart";17}18}19package com.testsigma.model;20public class TestCase {21public String getTestDataEnd() {22return "TestDataEnd";23}24}25package com.testsigma.model;26public class TestCase {27public String getTestDataStart() {28return "TestDataStart";29}30}31package com.testsigma.model;32public class TestCase {33public String getTestDataEnd() {34return "TestDataEnd";35}36}37package com.testsigma.model;38public class TestCase {39public String getTestDataStart() {40return "TestDataStart";41}42}43package com.testsigma.model;44public class TestCase {45public String getTestDataEnd() {46return "TestDataEnd";47}48}49package com.testsigma.model;50public class TestCase {51public String getTestDataStart() {52return "TestDataStart";53}54}55package com.testsigma.model;56public class TestCase {57public String getTestDataEnd() {58return "TestDataEnd";59}60}61package com.testsigma.model;62public class TestCase {63public String getTestDataStart() {64return "TestDataStart";65}66}

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.TestCase;2import com.testsigma.model.TestSuite;3import com.testsigma.model.TestData;4import com.testsigma.model.TestDataList;5import com.testsigma.model.TestDataValue;6import com.testsigma.model.TestDataValueList;7public class 2 {8 public static void main(String[] args) {9 TestCase tc = new TestCase();10 TestSuite ts = new TestSuite();11 TestData td = new TestData();12 TestDataList tdl = new TestDataList();13 TestDataValue tdv = new TestDataValue();14 TestDataValueList tdvl = new TestDataValueList();15 tc.setName("TestCase1");16 tc.setStartTime("2019-10-03 12:00:00");17 tc.setEndTime("2019-10-03 12:30:00");18 ts.setName("TestSuite1");19 ts.setStartTime("2019-10-03 12:00:00");20 ts.setEndTime("2019-10-03 12:30:00");21 td.setName("TestData1");22 td.setStartTime("2019-10-03 12:00:00");23 td.setEndTime("2019-10-03 12:30:00");24 tdv.setName("TestDataValue1");25 tdv.setValue("TestDataValue1");26 tdvl.add(tdv);27 td.setTestDataValueList(tdvl);28 tdl.add(td);29 ts.setTestDataList(tdl);30 tc.setTestSuite(ts);31 System.out.println(tc.getStartTime());32 System.out.println(tc.getEndTime());

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.TestCase;2import com.testsigma.model.TestData;3import com.testsigma.model.TestSuite;4public class 2 {5 public static void main(String[] args) {6 TestCase tc = new TestCase();7 System.out.println(tc.getTestDataStart());8 }9}10import com.testsigma.model.TestCase;11import com.testsigma.model.TestData;12import com.testsigma.model.TestSuite;13public class 3 {14 public static void main(String[] args) {15 TestCase tc = new TestCase();16 System.out.println(tc.getTestDataEnd());17 }18}19import com.testsigma.model.TestCase;20import com.testsigma.model.TestData;21import com.testsigma.model.TestSuite;22public class 4 {23 public static void main(String[] args) {24 TestCase tc = new TestCase();25 System.out.println(tc.getTestDataDuration());26 }27}28import com.testsigma.model.TestCase;29import com.testsigma.model.TestData;30import com.testsigma.model.TestSuite;31public class 5 {32 public static void main(String[] args) {33 TestCase tc = new TestCase();34 System.out.println(tc.getTestDataElapsedTime());35 }36}37import com.testsigma.model.TestCase;38import com.testsigma.model.TestData;39import com.testsigma.model.TestSuite;40public class 6 {41 public static void main(String[] args) {42 TestCase tc = new TestCase();43 System.out.println(tc.getTestDataStatus());44 }45}

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import com.testsigma.model.TestCase;2import com.testsigma.model.TestData;3import com.testsigma.model.TestStep;4public class 2 extends TestCase{5 public void test() throws Exception{6 TestData data = getTestDataStart();7 TestStep step = data.getTestStep();8 String name = data.getTestDataName();9 }10}11import com.testsigma.model.TestCase;12import com.testsigma.model.TestData;13import com.testsigma.model.TestStep;14public class 3 extends TestCase{15 public void test() throws Exception{16 TestData data = getTestDataStart();17 TestStep step = data.getTestStep();18 String name = data.getTestDataName();19 }20}21import com.testsigma.model.TestCase;22import com.testsigma.model.TestData;23import com.testsigma.model.TestStep;24public class 4 extends TestCase{25 public void test() throws Exception{26 TestData data = getTestDataStart();27 TestStep step = data.getTestStep();28 String name = data.getTestDataName();29 }30}31import com.testsigma.model.TestCase;32import com.testsigma.model.TestData;33import com.testsigma.model.TestStep;34public class 5 extends TestCase{35 public void test() throws Exception{36 TestData data = getTestDataStart();37 TestStep step = data.getTestStep();38 String name = data.getTestDataName();39 }40}41import com.testsigma.model.TestCase;42import com.testsigma.model.TestData;43import com.testsigma.model.TestStep;44public class 6 extends TestCase{45 public void test() throws Exception{46 TestData data = getTestDataStart();47 TestStep step = data.getTestStep();48 String name = data.getTestDataName();49 }50}51import com.testsigma.model.TestCase;52import com.testsigma.model.TestData;53import com.testsigma.model.TestStep;54public class 7 extends TestCase{55 public void test() throws Exception{

Full Screen

Full Screen

getTestDataStart

Using AI Code Generation

copy

Full Screen

1import java.io.*;2import java.util.*;3import com.testsigma.model.TestCase;4public class 2{5public static void main(String[] args) throws Exception{6TestCase tc = new TestCase();7int dataStart = tc.getTestDataStart();8System.out.println("Data start line number is: " + dataStart);9}10}

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful