How to use export method of com.testsigma.service.RestStepService class

Best Testsigma code snippet using com.testsigma.service.RestStepService.export

Source:TestStepService.java Github

copy

Full Screen

...5 * ****************************************************************************6 */7package com.testsigma.service;8import com.testsigma.dto.BackupDTO;9import com.testsigma.dto.export.TestStepXMLDTO;10import com.testsigma.event.EventType;11import com.testsigma.event.TestStepEvent;12import com.testsigma.exception.ResourceNotFoundException;13import com.testsigma.mapper.RestStepMapper;14import com.testsigma.mapper.TestStepMapper;15import com.testsigma.model.*;16import com.testsigma.repository.TestStepRepository;17import com.testsigma.specification.SearchCriteria;18import com.testsigma.specification.SearchOperation;19import com.testsigma.specification.TestStepSpecificationsBuilder;20import lombok.RequiredArgsConstructor;21import lombok.extern.log4j.Log4j2;22import org.apache.commons.lang3.StringUtils;23import org.springframework.beans.factory.annotation.Autowired;24import org.springframework.context.ApplicationEventPublisher;25import org.springframework.context.annotation.Lazy;26import org.springframework.data.domain.Page;27import org.springframework.data.domain.PageRequest;28import org.springframework.data.domain.Pageable;29import org.springframework.data.jpa.domain.Specification;30import org.springframework.stereotype.Service;31import java.io.IOException;32import java.util.ArrayList;33import java.util.HashSet;34import java.util.List;35import java.util.Map;36import java.util.stream.Collectors;37@Service38@Log4j239@RequiredArgsConstructor(onConstructor = @__({@Autowired, @Lazy}))40public class TestStepService extends XMLExportService<TestStep> {41 private final TestStepRepository repository;42 private final RestStepService restStepService;43 private final RestStepMapper mapper;44 private final ProxyAddonService addonService;45 private final AddonNaturalTextActionService addonNaturalTextActionService;46 private final ApplicationEventPublisher applicationEventPublisher;47 private final TestCaseService testCaseService;48 private final TestStepMapper exportTestStepMapper;49 public List<TestStep> findAllByTestCaseId(Long testCaseId) {50 return this.repository.findAllByTestCaseIdOrderByPositionAsc(testCaseId);51 }52 public List<TestStep> findAllByTestCaseIdAndEnabled(Long testCaseId) {53 List<TestStep> testSteps = repository.findAllByTestCaseIdAndDisabledIsNotOrderByPositionAsc(testCaseId, true);54 List<TestStep> stepGroups = repository.findAllByTestCaseIdAndDisabledIsNotAndStepGroupIdIsNotNullOrderByPositionAsc(testCaseId, true);55 for (TestStep teststep : stepGroups) {56 if (teststep.getStepGroup() != null) {57 List<TestStep> groupsSteps = repository.findAllByTestCaseIdAndDisabledIsNotOrderByPositionAsc(teststep.getStepGroupId(), true);58 teststep.getStepGroup().setTestSteps(new HashSet<>(groupsSteps));59 }60 }61 return testSteps;62 }63 public List<String> findElementNamesByTestCaseIds(List<Long> testCaseIds) {64 List<String> ElementNames = repository.findTestStepsByTestCaseIdIn(testCaseIds);65 return ElementNames.stream().map(x -> StringUtils.strip(x, "\"")).collect(Collectors.toList());66 }67 public List<String> findAddonActionElementsByTestCaseIds(List<Long> testCaseIds) {68 List<String> elementsNames = new ArrayList<>();69 List<TestStep> testSteps = repository.findAllByTestCaseIdInAndAddonActionIdIsNotNull(testCaseIds);70 for (TestStep step : testSteps) {71 Map<String, AddonElementData> addonElementData = step.getAddonElements();72 for (AddonElementData elementData : addonElementData.values()) {73 elementsNames.add(elementData.getName());74 }75 }76 return elementsNames;77 }78 public Page<TestStep> findAll(Specification<TestStep> spec, Pageable pageable) {79 return this.repository.findAll(spec, pageable);80 }81 public void destroy(TestStep testStep) throws ResourceNotFoundException {82 repository.decrementPosition(testStep.getPosition(), testStep.getTestCaseId());83 repository.delete(testStep);84 if (testStep.getAddonActionId() != null) {85 AddonNaturalTextAction addonNaturalTextAction = addonNaturalTextActionService.findById(testStep.getAddonActionId());86 addonService.notifyActionNotUsing(addonNaturalTextAction);87 }88 publishEvent(testStep, EventType.DELETE);89 }90 public TestStep find(Long id) throws ResourceNotFoundException {91 return this.repository.findById(id).orElseThrow(() -> new ResourceNotFoundException("TestStep missing with id:" + id));92 }93 private TestStep updateDetails(TestStep testStep){94 RestStep restStep = testStep.getRestStep();95 testStep.setRestStep(null);96 testStep = this.repository.save(testStep);97 if (restStep != null) {98 restStep.setStepId(testStep.getId());99 restStep = this.restStepService.update(restStep);100 testStep.setRestStep(restStep);101 }102 return testStep;103 }104 public TestStep update(TestStep testStep) {105 testStep = updateDetails(testStep);106 this.updateDisablePropertyForChildSteps(testStep);107 publishEvent(testStep, EventType.UPDATE);108 return testStep;109 }110 private void updateDisablePropertyForChildSteps(TestStep testStep) {111 List<TestStep> childSteps = this.repository.findAllByParentIdOrderByPositionAsc(testStep.getId());112 if (childSteps.size() > 0) {113 for (TestStep childStep : childSteps) {114 childStep.setDisabled(testStep.getDisabled());115 this.update(childStep);116 }117 }118 }119 public TestStep create(TestStep testStep) throws ResourceNotFoundException {120 this.repository.incrementPosition(testStep.getPosition(), testStep.getTestCaseId());121 RestStep restStep = testStep.getRestStep();122 testStep.setRestStep(null);123 testStep = this.repository.save(testStep);124 if (restStep != null) {125 RestStep newRestStep = mapper.mapStep(restStep);126 newRestStep.setStepId(testStep.getId());127 newRestStep = this.restStepService.create(newRestStep);128 testStep.setRestStep(newRestStep);129 }130 if (testStep.getAddonActionId() != null) {131 AddonNaturalTextAction addonNaturalTextAction = addonNaturalTextActionService.findById(testStep.getAddonActionId());132 addonService.notifyActionUsing(addonNaturalTextAction);133 }134 publishEvent(testStep, EventType.CREATE);135 return testStep;136 }137 public void bulkUpdateProperties(Long[] ids, TestStepPriority testStepPriority, Integer waitTime, Boolean disabled, Boolean ignoreStepResult) {138 this.repository.bulkUpdateProperties(ids, testStepPriority != null ? testStepPriority.toString() : null, waitTime);139 if (disabled != null || ignoreStepResult != null)140 this.bulkUpdateDisableAndIgnoreResultProperties(ids, disabled, ignoreStepResult);141 }142 private void bulkUpdateDisableAndIgnoreResultProperties(Long[] ids, Boolean disabled, Boolean ignoreStepResult) {143 List<TestStep> testSteps = this.repository.findAllByIdInOrderByPositionAsc(ids);144 for (TestStep testStep : testSteps) {145 if (disabled != null) {146 if(!disabled && testStep.getParentStep() == null){147 testStep.setDisabled(false);148 } else if(!disabled && testStep.getParentStep() != null){149 testStep.setDisabled(testStep.getParentStep().getDisabled());150 } else {151 testStep.setDisabled(disabled);152 }153 }154 if (ignoreStepResult != null) {155 testStep.setIgnoreStepResult(ignoreStepResult);156 }157 this.updateDetails(testStep);158 }159 }160 public List<TestStep> findAllByTestCaseIdAndIdIn(Long testCaseId, List<Long> stepIds) {161 return this.repository.findAllByTestCaseIdAndIdInOrderByPosition(testCaseId, stepIds);162 }163 public void updateTestDataParameterName(Long testDataId, String parameter, String newParameterName) {164 this.repository.updateTopLevelTestDataParameter(newParameterName, parameter, testDataId);165 List<TestStep> topConditionalSteps = this.repository.getTopLevelConditionalStepsExceptLoop(testDataId);166 for (TestStep step : topConditionalSteps) {167 updateChildLoops(step.getId(), parameter, newParameterName);168 }169 List<TestStep> loopSteps = this.repository.getAllLoopSteps(testDataId);170 for (TestStep step : loopSteps) {171 updateChildLoops(step.getId(), parameter, newParameterName);172 }173 }174 public void updateElementName(String oldName, String newName) {175 this.repository.updateElementName(newName, oldName);176 }177 private void updateChildLoops(Long parentId, String parameter, String newParameterName) {178 this.repository.updateChildStepsTestDataParameter(newParameterName, parameter, parentId);179 List<TestStep> conditionalSteps = this.repository.getChildConditionalStepsExceptLoop(parentId);180 for (TestStep step : conditionalSteps) {181 updateChildLoops(step.getId(), parameter, newParameterName);182 }183 }184 public List<TestStep> findAllByTestCaseIdAndNaturalTextActionIds(Long id, List<Integer> ids) {185 return this.repository.findAllByTestCaseIdAndNaturalTextActionIdIn(id, ids);186 }187 public Integer countAllByAddonActionIdIn(List<Long> ids) {188 return this.repository.countAllByAddonActionIdIn(ids);189 }190 public void updateAddonElementsName(String oldName, String newName) {191 List<TestStep> testSteps = this.repository.findAddonElementsByName(oldName);192 testSteps.forEach(testStep -> {193 Map<String, AddonElementData> elements = testStep.getAddonElements();194 for (Map.Entry<String, AddonElementData> entry : elements.entrySet()) {195 if (entry.getValue().getName().equals(oldName)) {196 entry.getValue().setName(newName);197 }198 }199 testStep.setAddonElements(elements);200 this.repository.save(testStep);201 });202 }203 public void export(BackupDTO backupDTO) throws IOException, ResourceNotFoundException {204 if (!backupDTO.getIsTestStepEnabled()) return;205 log.debug("backup process for test step initiated");206 writeXML("test_steps", backupDTO, PageRequest.of(0, 25));207 log.debug("backup process for test step completed");208 }209 public Specification<TestStep> getExportXmlSpecification(BackupDTO backupDTO) {210 List<TestCase> testCaseList = testCaseService.findAllByWorkspaceVersionId(backupDTO.getWorkspaceVersionId());211 List<Long> testcaseIds = testCaseList.stream().map(testCase -> testCase.getId()).collect(Collectors.toList());212 SearchCriteria criteria = new SearchCriteria("testCaseId", SearchOperation.IN, testcaseIds);213 List<SearchCriteria> params = new ArrayList<>();214 params.add(criteria);215 TestStepSpecificationsBuilder testStepSpecificationsBuilder = new TestStepSpecificationsBuilder();216 testStepSpecificationsBuilder.params = params;217 return testStepSpecificationsBuilder.build();218 }219 @Override220 protected List<TestStepXMLDTO> mapToXMLDTOList(List<TestStep> list) {221 return exportTestStepMapper.mapTestSteps(list);222 }223 public void publishEvent(TestStep testSuite, EventType eventType) {224 TestStepEvent<TestStep> event = createEvent(testSuite, eventType);225 log.info("Publishing event - " + event.toString());226 applicationEventPublisher.publishEvent(event);227 }228 public TestStepEvent<TestStep> createEvent(TestStep testSuite, EventType eventType) {229 TestStepEvent<TestStep> event = new TestStepEvent<>();230 event.setEventData(testSuite);231 event.setEventType(eventType);232 return event;233 }234}...

Full Screen

Full Screen

Source:BackupDetailService.java Github

copy

Full Screen

...8import com.testsigma.config.StorageServiceFactory;9import com.testsigma.model.StorageAccessLevel;10import com.testsigma.constants.MessageConstants;11import com.testsigma.dto.BackupDTO;12import com.testsigma.dto.export.BaseXMLDTO;13import com.testsigma.exception.ResourceNotFoundException;14import com.testsigma.exception.TestsigmaException;15import com.testsigma.mapper.BackupDetailMapper;16import com.testsigma.model.BackupDetail;17import com.testsigma.model.BackupStatus;18import com.testsigma.repository.BackupDetailRepository;19import com.testsigma.web.request.BackupRequest;20import lombok.RequiredArgsConstructor;21import lombok.extern.log4j.Log4j2;22import org.springframework.beans.factory.annotation.Autowired;23import org.springframework.data.domain.Page;24import org.springframework.data.domain.Pageable;25import org.springframework.data.jpa.domain.Specification;26import org.springframework.stereotype.Service;27import java.io.IOException;28import java.net.URL;29import java.sql.Timestamp;30import java.util.List;31import java.util.Optional;32@Log4j233@Service34@RequiredArgsConstructor(onConstructor = @__({@Autowired}))35public class BackupDetailService extends XMLExportService<BackupDetail> {36 private final BackupDetailRepository repository;37 private final StorageServiceFactory storageServiceFactory;38 private final AgentService agentService;39 private final WorkspaceService workspaceService;40 private final AttachmentService attachmentService;41 private final TestDeviceService testDeviceService;42 private final TestPlanService testPlanService;43 private final RestStepService reststepService;44 private final TestCaseService testcaseService;45 private final TestCasePriorityService testCasePriorityService;46 private final TestCaseTypeService testCaseTypeService;47 private final TestDataProfileService testDataProfileService;48 private final TestStepService teststepService;49 private final ElementService elementService;50 private final WorkspaceVersionService versionService;51 private final ElementScreenService elementScreenService;52 private final UploadService uploadService;53 private final UploadVersionService uploadVersionService;54 private final BackupDetailMapper exportBackupEntityMapper;55 public BackupDetail find(Long id) throws ResourceNotFoundException {56 return repository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Backup is not found with id:" + id));57 }58 public Page<BackupDetail> findAll(Pageable pageable) {59 return repository.findAll(pageable);60 }61 public Optional<URL> downLoadURL(BackupDetail backupDetail) {62 return storageServiceFactory.getStorageService().generatePreSignedURLIfExists(63 "/backup/" + backupDetail.getName(), StorageAccessLevel.READ, 300);64 }65 public BackupDetail create(BackupDetail backupDetail) {66 backupDetail.setMessage(MessageConstants.BACKUP_IS_IN_PROGRESS);67 backupDetail.setStatus(BackupStatus.IN_PROGRESS);68 backupDetail.setCreatedDate(new Timestamp(System.currentTimeMillis()));69 backupDetail = this.repository.save(backupDetail);70 return backupDetail;71 }72 public BackupDetail save(BackupDetail backupDetail) {73 return this.repository.save(backupDetail);74 }75 public void destroy(Long id) throws ResourceNotFoundException {76 BackupDetail detail = this.find(id);77 this.repository.delete(detail);78 }79 @Override80 protected Page<BackupDetail> findAll(Specification<BackupDetail> specification, Pageable pageRequest) throws ResourceNotFoundException {81 return null;82 }83 @Override84 protected List<? extends BaseXMLDTO> mapToXMLDTOList(List<BackupDetail> list) {85 return null;86 }87 @Override88 public Specification<BackupDetail> getExportXmlSpecification(BackupDTO backupDTO) throws ResourceNotFoundException {89 return null;90 }91 public void export(BackupRequest request) throws IOException, TestsigmaException {92 BackupDTO backupDTORequest = exportBackupEntityMapper.map(request);93 BackupDetail backupDetailRequest = exportBackupEntityMapper.map(backupDTORequest);94 final BackupDetail backupDetail = create(backupDetailRequest);95 final BackupDTO backupDTO = exportBackupEntityMapper.mapTo(backupDetail);96 log.debug("initiating backup - " + backupDetail.getId());97 new Thread(() -> {98 try {99 log.debug("backup process started for ::" + backupDetail.getId());100 initExportFolder(backupDTO);101 workspaceService.export(backupDTO);102 versionService.export(backupDTO);103 testCasePriorityService.export(backupDTO);104 testCaseTypeService.export(backupDTO);105 elementScreenService.export(backupDTO);106 elementService.export(backupDTO);107 testDataProfileService.export(backupDTO);108 attachmentService.export(backupDTO);109 agentService.export(backupDTO);110 uploadService.export(backupDTO);111 uploadVersionService.export(backupDTO);112 testcaseService.export(backupDTO);113 teststepService.export(backupDTO);114 reststepService.export(backupDTO);115 testPlanService.export(backupDTO);116 testDeviceService.export(backupDTO);117 backupDetail.setSrcFiles(backupDTO.getSrcFiles());118 backupDetail.setDestFiles(backupDTO.getDestFiles());119 exportToStorage(backupDetail);120 log.debug("backup process export completed");121 } catch (Exception e) {122 log.error(e.getMessage(), e);123 backupDetail.setStatus(BackupStatus.FAILURE);124 backupDetail.setMessage(e.getMessage());125 repository.save(backupDetail);126 destroy(backupDTO);127 } catch (Error error) {128 log.error(error.getMessage(), error);129 } finally {130 destroy(backupDTO);131 log.debug("backup process for completed");132 }133 }).start();134 }...

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.RestStepService;2import com.testsigma.service.RestStepServiceFactory;3import com.testsigma.service.RestStepServiceFactoryImpl;4import com.testsigma.service.RestStepServiceFactoryImpl;5import com.testsigma.service.RestStepService;6import com.testsigma.service.RestStepServiceFactory;7import com.testsigma.service.RestStepServiceFactoryImpl;8import com.testsigma.service.RestStepServiceFactoryImpl;9import com.testsigma.service.RestStepService;10import com.testsigma.service.RestStepServiceFactory;11import com.testsigma.service.RestStepServiceFactoryImpl;12import com.testsigma.service.RestStepServiceFactoryImpl;13import com.testsigma.service.RestStepService;14import com.testsigma.service.RestStepServiceFactory;15import com.testsigma.service.RestStepServiceFactoryImpl;16import com.testsigma.service.RestStepServiceFactoryImpl;17import com.testsigma.service.RestStepService;18import com.testsigma.service.RestStepServiceFactory;19import com.testsigma.service.RestStepServiceFactoryImpl;20import com.testsigma.service.RestStepServiceFactoryImpl;21import com.testsigma.service.RestStepService;22import com.testsigma.service.RestStepServiceFactory;23import com.testsigma.service.RestStepServiceFactoryImpl;24import com.testsigma.service.RestStepServiceFactoryImpl;25import com.testsigma.service.RestStepService;26import com.testsigma.service.RestStepServiceFactory;27import com.testsigma.service.RestStepServiceFactoryImpl;28import com.testsigma.service.RestStepServiceFactoryImpl;29import com.testsigma.service.RestStepService;30import com.testsigma.service.RestStepServiceFactory;31import com.testsigma.service.RestStepServiceFactoryImpl;32import com.testsigma.service.RestStepServiceFactoryImpl;33import com.testsigma.service.RestStepService;34import com.testsigma.service.RestStepServiceFactory;35import com.testsigma.service.RestStepServiceFactoryImpl;36import com.testsigma.service.RestStepServiceFactoryImpl;37import com.testsigma.service.RestStepService;38import com.testsigma.service.RestStepServiceFactory;39import com.testsigma.service.RestStepServiceFactoryImpl;40import com.testsigma.service.RestStepServiceFactoryImpl;41import com.testsigma.service.RestStepService;42import com.testsigma.service.RestStepServiceFactory;43import com.testsigma.service.RestStepServiceFactoryImpl;44import com.testsigma.service.RestStepServiceFactoryImpl;45import com.testsigma.service.RestStepService;46import com.testsigma.service.RestStepServiceFactory;47import com.testsigma.service.RestStepServiceFactoryImpl;48import com.testsigma.service.RestStepServiceFactoryImpl;49import com.testsigma.service.Rest

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1package com.testsigma.service;2import com.testsigma.service.RestStepService;3public class RestStepServiceTest {4public static void main(String[] args) {5RestStepService restStepService = new RestStepService();6System.out.println(response);7}8}9To import the REST service, follow the steps given below:

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.RestStepService;2public class 2 {3 public static void main(String[] args) {4 RestStepService stepService = new RestStepService();5 String step = stepService.export("stepName", "stepType");6 System.out.println(step);7 }8}9import com.testsigma.service.RestStepService;10public class 3 {11 public static void main(String[] args) {12 RestStepService stepService = new RestStepService();13 String step = stepService.export("stepName", "stepType", "stepDescription");14 System.out.println(step);15 }16}17import com.testsigma.service.RestStepService;18public class 4 {19 public static void main(String[] args) {20 RestStepService stepService = new RestStepService();21 String step = stepService.export("stepName", "stepType", "stepDescription", "packageName");22 System.out.println(step);23 }24}25import com.testsigma.service.RestStepService;26public class 5 {27 public static void main(String[] args) {28 RestStepService stepService = new RestStepService();29 String step = stepService.export("stepName", "stepType", "stepDescription", "packageName", "stepDefinition");30 System.out.println(step);31 }32}33import com.testsigma.service.RestStepService;34public class 6 {35 public static void main(String[] args) {36 RestStepService stepService = new RestStepService();37 String step = stepService.export("stepName", "stepType", "stepDescription", "packageName", "stepDefinition", "stepDefinitionType");38 System.out.println(step);39 }40}

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1package com.testsigma.test;2import com.testsigma.service.RestStepService;3public class TestSigmaExport {4public static void main(String[] args) {5 RestStepService service = new RestStepService();6 service.export("C:\\Users\\TestSigma\\Documents\\TestSigma\\TestSigmaExport\\src\\test\\resources\\TestSigmaExport\\testcases\\2.java");7}8}9package com.testsigma.test;10import com.testsigma.service.RestStepService;11public class TestSigmaExport {12public static void main(String[] args) {13 RestStepService service = new RestStepService();14 service.export("C:\\Users\\TestSigma\\Documents\\TestSigma\\TestSigmaExport\\src\\test\\resources\\TestSigmaExport\\testcases\\3.java");15}16}17package com.testsigma.test;18import com.testsigma.service.RestStepService;19public class TestSigmaExport {20public static void main(String[] args) {21 RestStepService service = new RestStepService();22 service.export("C:\\Users\\TestSigma\\Documents\\TestSigma\\TestSigmaExport\\src\\test\\resources\\TestSigmaExport\\testcases\\4.java");23}24}25package com.testsigma.test;26import com.testsigma.service.RestStepService;27public class TestSigmaExport {28public static void main(String[] args) {29 RestStepService service = new RestStepService();30 service.export("C:\\Users\\TestSigma\\Documents\\TestSigma\\TestSigmaExport\\src\\test\\resources\\TestSigmaExport\\testcases\\5.java");31}32}33package com.testsigma.test;34import com.testsigma.service.RestStepService;35public class TestSigmaExport {36public static void main(String[] args) {

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.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful