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

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

Source:TestCaseService.java Github

copy

Full Screen

...7 *8 */9package com.testsigma.service;10import com.testsigma.dto.*;11import com.testsigma.dto.export.TestCaseXMLDTO;12import com.testsigma.event.EventType;13import com.testsigma.event.TestCaseEvent;14import com.testsigma.exception.*;15import com.testsigma.mapper.TestCaseMapper;16import com.testsigma.mapper.TestStepMapper;17import com.testsigma.model.*;18import com.testsigma.repository.TestCaseRepository;19import com.testsigma.specification.SearchCriteria;20import com.testsigma.specification.SearchOperation;21import com.testsigma.specification.TestCaseSpecificationsBuilder;22import com.testsigma.web.request.TestCaseCopyRequest;23import com.testsigma.web.request.TestCaseRequest;24import lombok.RequiredArgsConstructor;25import lombok.extern.log4j.Log4j2;26import org.springframework.beans.factory.ObjectFactory;27import org.springframework.beans.factory.annotation.Autowired;28import org.springframework.context.ApplicationEventPublisher;29import org.springframework.context.annotation.Lazy;30import org.springframework.data.domain.Page;31import org.springframework.data.domain.PageRequest;32import org.springframework.data.domain.Pageable;33import org.springframework.data.jpa.domain.Specification;34import org.springframework.stereotype.Service;35import java.io.IOException;36import java.sql.SQLException;37import java.sql.Timestamp;38import java.util.*;39@Service40@RequiredArgsConstructor(onConstructor = @__({@Autowired, @Lazy}))41@Log4j242public class TestCaseService extends XMLExportService<TestCase> {43 private final TestCaseMapper testCaseMapper;44 private final com.testsigma.service.TestPlanService testPlanService;45 private final TestDeviceService testDeviceService;46 private final TestDeviceResultService testDeviceResultService;47 private final ObjectFactory<AgentExecutionService> agentExecutionServiceObjectFactory;48 private final TestCaseRepository testCaseRepository;49 private final TagService tagService;50 private final TestStepService testStepService;51 private final TestStepMapper testStepMapper;52 private final ApplicationEventPublisher applicationEventPublisher;53 private final com.testsigma.service.DryTestPlanService dryTestPlanService;54 private final TestCaseMapper mapper;55 private final TestCaseFilterService testCaseFilterService;56 private final StepGroupFilterService stepGroupFilterService;57 private final WorkspaceVersionService workspaceVersionService;58 private final TestSuiteService testSuiteService;59 public Page<TestCase> findAll(Specification<TestCase> specification, Pageable pageable) {60 return testCaseRepository.findAll(specification, pageable);61 }62 public List<TestCase> findAllByWorkspaceVersionId(Long workspaceVersionId) {63 return testCaseRepository.findAllByWorkspaceVersionId(workspaceVersionId);64 }65 public List<TestCase> findAllBySuiteId(Long suiteId) {66 return this.testCaseRepository.findAllBySuiteId(suiteId);67 }68 public Page<TestCase> findAllByTestDataId(Long testDataId, Pageable pageable) {69 return this.testCaseRepository.findAllByTestDataId(testDataId, pageable);70 }71 public Page<TestCase> findAllByPreRequisite(Long preRequisite, Pageable pageable) {72 return this.testCaseRepository.findAllByPreRequisite(preRequisite, pageable);73 }74 public TestCase find(Long id) throws ResourceNotFoundException {75 return testCaseRepository.findById(id).orElseThrow(76 () -> new ResourceNotFoundException("Couldn't find TestCase resource with id:" + id));77 }78 public TestCaseEntityDTO find(Long id, Long environmentResultId, String testDataSetName, Long testCaseResultId) {79 TestCaseEntityDTO testCaseEntityDTO = new TestCaseEntityDTO();80 try {81 TestCase testCase = this.find(id);82 testCaseEntityDTO = testCaseMapper.map(testCase);83 TestDeviceResult testDeviceResult = testDeviceResultService.find(environmentResultId);84 TestDevice testDevice = testDeviceService.find(testDeviceResult.getTestDeviceId());85 Optional<TestPlan> optionalTestPlan = testPlanService.findOptional(testDevice.getTestPlanId());86 AbstractTestPlan testPlan;87 if (optionalTestPlan.isPresent())88 testPlan = optionalTestPlan.get();89 else90 testPlan = dryTestPlanService.find(testDevice.getTestPlanId());91 WorkspaceVersion applicationVersion = testPlan.getWorkspaceVersion();92 Workspace workspace = applicationVersion.getWorkspace();93 testCaseEntityDTO.setTestCaseResultId(testCaseResultId);94 testCaseEntityDTO.setStatus(testDeviceResult.getStatus());95 testCaseEntityDTO.setResult(testDeviceResult.getResult());96 AgentExecutionService agentExecutionService = agentExecutionServiceObjectFactory.getObject();97 agentExecutionService.setTestPlan(testPlan);98 agentExecutionService.checkTestCaseIsInReadyState(testCase);99 agentExecutionService100 .loadTestCase(testDataSetName, testCaseEntityDTO, testPlan, workspace);101 } catch (TestsigmaNoMinsAvailableException e) {102 log.debug("======= Testcase Error=========");103 log.error(e.getMessage(), e);104 testCaseEntityDTO.setMessage(e.getMessage());105 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_MINS_VALIDATION_FAILURE);106 return testCaseEntityDTO;107 } catch (TestsigmaException e) {108 log.debug("======= Testcase Error=========");109 log.error(e.getMessage(), e);110 if (e.getErrorCode() != null) {111 if (e.getErrorCode().equals(ExceptionErrorCodes.ENVIRONMENT_PARAMETERS_NOT_CONFIGURED)) {112 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_ENVIRONMENT_PARAM_FAILURE);113 } else if (e.getErrorCode().equals(ExceptionErrorCodes.ENVIRONMENT_PARAMETER_NOT_FOUND)) {114 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_ENVIRONMENT_PARAM_FAILURE);115 } else if (e.getErrorCode().equals(ExceptionErrorCodes.TEST_DATA_SET_NOT_FOUND)) {116 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_TEST_DATA_SET_FAILURE);117 } else if (e.getErrorCode().equals(ExceptionErrorCodes.TEST_DATA_NOT_FOUND)) {118 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_TEST_DATA_FAILURE);119 } else if (e.getErrorCode().equals(ExceptionErrorCodes.ELEMENT_NOT_FOUND)) {120 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.ERROR_ELEMENT_FAILURE);121 }122 }123 testCaseEntityDTO.setErrorCode(testCaseEntityDTO.getErrorCode() == null ? ExceptionErrorCodes.UNKNOWN_ERROR : testCaseEntityDTO.getErrorCode());124 testCaseEntityDTO.setMessage(e.getMessage());125 return testCaseEntityDTO;126 } catch (Exception e) {127 log.debug("======= Testcase Error=========");128 log.error(e.getMessage(), e);129 testCaseEntityDTO.setErrorCode(ExceptionErrorCodes.UNKNOWN_ERROR);130 testCaseEntityDTO.setMessage(e.getMessage());131 return testCaseEntityDTO;132 }133 return testCaseEntityDTO;134 }135 public TestCase create(TestCaseRequest testCaseRequest) throws TestsigmaException, SQLException {136 TestCase testCase = testCaseMapper.map(testCaseRequest);137 testCase.setIsActive(true);138 testCase.setCreatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));139 setStatusTimeAndBy(testCaseRequest, testCase);140 List<Long> preReqList = new ArrayList<>();141 preReqList.add(testCase.getId());142 validatePreRequisiteIsValid(testCase, preReqList);143 testCase = create(testCase);144 tagService.updateTags(testCaseRequest.getTags(), TagType.TEST_CASE, testCase.getId());145 return testCase;146 }147 public TestCase create(TestCase testCaseRequest) {148 TestCase testCase = testCaseRepository.save(testCaseRequest);149 publishEvent(testCase, EventType.CREATE);150 return testCase;151 }152 public TestCase update(TestCase testCase) {153 testCase = this.testCaseRepository.save(testCase);154 publishEvent(testCase, EventType.UPDATE);155 return testCase;156 }157 public TestCase update(TestCaseRequest testCaseRequest, Long id) throws TestsigmaException, SQLException {158 TestCase testCase = testCaseRepository.findById(id).get();159 Long oldPreRequisite = testCase.getPreRequisite();160 testCase.setUpdatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));161 setStatusTimeAndBy(testCaseRequest, testCase);162 testCaseMapper.map(testCaseRequest, testCase);163 List<Long> preReqList = new ArrayList<>();164 preReqList.add(testCase.getId());165 validatePreRequisiteIsValid(testCase, preReqList);166 testCase = update(testCase);167 if (testCaseRequest.getTags() != null) {168 tagService.updateTags(testCaseRequest.getTags(), TagType.TEST_CASE, testCase.getId());169 }170 if (testCase.getPreRequisite() != null && !testCase.getPreRequisite().equals(oldPreRequisite)){171 testSuiteService.handlePreRequisiteChange(testCase);172 }173 return testCase;174 }175 private void validatePreRequisiteIsValid(TestCase testCase, List<Long> preReqList) throws TestsigmaException {176 Long preRequisiteId = testCase.getPreRequisite();177 if (preRequisiteId != null) {178 if (preReqList.size() > 5) {179 log.debug("Testcase Prerequisite hierarchy is more than 5,Prerequisite IDs:" + preReqList);180 throw new TestsigmaException("Prerequisite hierarchy crossed the allowed limit of 5");181 } else if (preReqList.contains(testCase.getPreRequisite())) {182 log.debug("Cyclic dependency for Testsuite prerequisites found for Testsuite:" + testCase);183 throw new TestsigmaException("Prerequisite to the TestCase is not valid. This prerequisite causes cyclic dependencies for TestCase.");184 }185 preReqList.add(preRequisiteId);186 TestCase preRequisiteTestCase = find(preRequisiteId);187 if (preRequisiteTestCase.getPreRequisite() != null) {188 validatePreRequisiteIsValid(preRequisiteTestCase, preReqList);189 }190 } else {191 return;192 }193 }194 //TODO:need to revisit this code[chandra]195 private void setStatusTimeAndBy(TestCaseRequest testCaseRequest, TestCase testcase) throws ResourceNotFoundException, TestsigmaDatabaseException, SQLException {196 TestCaseStatus status = testCaseRequest.getStatus();197 Timestamp at = new Timestamp(System.currentTimeMillis());198 if (status.equals(TestCaseStatus.DRAFT)) {199 testCaseRequest.setDraftAt(at);200 } else if (status.equals(TestCaseStatus.IN_REVIEW)) {201 if (!testcase.getStatus().equals(TestCaseStatus.IN_REVIEW)) {202 testCaseRequest.setReviewSubmittedAt(at);203 }204 } else if (status.equals(TestCaseStatus.READY)) {205 if (testcase.getStatus().equals(TestCaseStatus.IN_REVIEW)) {206 testCaseRequest.setReviewedAt(at);207 }208 } else if (status.equals(TestCaseStatus.OBSOLETE)) {209 testCaseRequest.setObsoleteAt(at);210 }211 }212 public Integer markAsDelete(List<Long> ids) {213 return testCaseRepository.markAsDelete(ids);214 }215 public void restore(Long id) {216 testCaseRepository.markAsRestored(id);217 }218 public void destroy(Long id) throws ResourceNotFoundException {219 TestCase testcase = this.find(id);220 testCaseRepository.delete(testcase);221 publishEvent(testcase, EventType.DELETE);222 }223 public Long automatedCountByVersion(Long versionId) {224 return this.testCaseRepository.countByVersion(versionId);225 }226 public Long testCaseCountByPreRequisite(Long testCaseId){227 return this.testCaseRepository.countByPreRequisite(testCaseId);228 }229 public List<Long> getTestCaseIdsByPreRequisite(Long testCaseId){230 return this.testCaseRepository.getTestCaseIdsByPreRequisite(testCaseId);231 }232 public List<TestCaseStatusBreakUpDTO> breakUpByStatus(Long versionId) {233 return this.testCaseRepository.breakUpByStatus(versionId);234 }235 public List<TestCaseTypeBreakUpDTO> breakUpByType(Long versionId) {236 return this.testCaseRepository.breakUpByType(versionId);237 }238 public TestCase copy(TestCaseCopyRequest testCaseRequest) throws ResourceNotFoundException, SQLException {239 TestCase parentCase = this.find(testCaseRequest.getTestCaseId());240 TestCase testCase = this.testCaseMapper.copy(parentCase);241 testCase.setStatus(parentCase.getStatus());242 testCase.setName(testCaseRequest.getName());243 testCase.setCreatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));244 testCase.setLastRunId(null);245 if (testCaseRequest.getIsStepGroup()) {246 testCase.setTestDataStartIndex(null);247 testCase.setTestDataId(null);248 testCase.setIsDataDriven(false);249 }250 testCase.setIsStepGroup(testCaseRequest.getIsStepGroup());251 testCase.setCopiedFrom(parentCase.getId());252 testCase.setPreRequisiteCase(null);253 testCase = create(testCase);254 List<String> tags = tagService.list(TagType.TEST_CASE, parentCase.getId());255 tagService.updateTags(tags, TagType.TEST_CASE, testCase.getId());256 List<TestStep> steps = this.fetchTestSteps(parentCase, testCaseRequest.getStepIds());257 List<TestStep> newSteps = new ArrayList<>();258 Map<Long, TestStep> parentStepIds = new HashMap<Long, TestStep>();259 Integer position = 0;260 TestStep firstStep = steps.get(0);261 if(firstStep.getConditionType() == TestStepConditionType.LOOP_WHILE){262 TestStep whileStep = this.testStepService.find(firstStep.getParentId());263 steps.add(0, whileStep);264 }265 for (TestStep parent : steps) {266 if (testCase.getIsStepGroup() && parent.getStepGroupId() != null)267 continue;268 TestStep step = this.testStepMapper.copy(parent);269 step.setPosition(position);270 step.setCreatedDate(new Timestamp(Calendar.getInstance().getTimeInMillis()));271 step.setTestCaseId(testCase.getId());272 TestStep parentStep = parentStepIds.get(parent.getParentId());273 step.setParentId(parentStep != null ? parentStep.getId() : null);274 TestStep prerequiste = parentStepIds.get(parentStep != null ? parent.getPreRequisiteStepId() : null);275 step.setPreRequisiteStepId(prerequiste != null ? prerequiste.getId() : null);276 step.setId(null);277 step.setParentStep(parentStep);278 step = this.testStepService.create(step);279 parentStepIds.put(parent.getId(), step);280 newSteps.add(step);281 position++;282 }283 return testCase;284 }285 private List<TestStep> fetchTestSteps(TestCase testCase, List<Long> stepIds) {286 if (stepIds != null)287 return this.testStepService.findAllByTestCaseIdAndIdIn(testCase.getId(), stepIds);288 else289 return this.testStepService.findAllByTestCaseId(testCase.getId());290 }291 public void publishEvent(TestCase testCase, EventType eventType) {292 TestCaseEvent<TestCase> event = createEvent(testCase, eventType);293 log.info("Publishing event - " + event.toString());294 applicationEventPublisher.publishEvent(event);295 }296 public TestCaseEvent<TestCase> createEvent(TestCase testCase, EventType eventType) {297 TestCaseEvent<TestCase> event = new TestCaseEvent<>();298 event.setEventData(testCase);299 event.setEventType(eventType);300 return event;301 }302 public void export(BackupDTO backupDTO) throws IOException, ResourceNotFoundException {303 if (!backupDTO.getIsTestCaseEnabled()) return;304 log.debug("backup process for testcase initiated");305 writeXML("testcases", backupDTO, PageRequest.of(0, 25));306 log.debug("backup process for testcase completed");307 }308 public Specification<TestCase> getExportXmlSpecification(BackupDTO backupDTO) throws ResourceNotFoundException {309 boolean hasFilter = backupDTO.getFilterId() != null && backupDTO.getFilterId() > 0;310 if (hasFilter) return specificationBuilder(backupDTO);311 SearchCriteria criteria = new SearchCriteria("workspaceVersionId", SearchOperation.EQUALITY, backupDTO.getWorkspaceVersionId());312 List<SearchCriteria> params = new ArrayList<>();313 params.add(criteria);314 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();315 testCaseSpecificationsBuilder.params = params;316 return testCaseSpecificationsBuilder.build();...

Full Screen

Full Screen

Source:BackupDetailService.java Github

copy

Full Screen

...10import com.testsigma.config.StorageServiceFactory;11import com.testsigma.model.*;12import com.testsigma.constants.MessageConstants;13import com.testsigma.dto.BackupDTO;14import com.testsigma.dto.export.BaseXMLDTO;15import com.testsigma.exception.ResourceNotFoundException;16import com.testsigma.exception.TestsigmaException;17import com.testsigma.mapper.BackupDetailMapper;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.beans.factory.annotation.Value;24import org.springframework.context.annotation.Lazy;25import org.springframework.data.domain.Page;26import org.springframework.data.domain.Pageable;27import org.springframework.data.jpa.domain.Specification;28import org.springframework.stereotype.Service;29import org.springframework.web.multipart.MultipartFile;30import java.io.File;31import java.io.IOException;32import java.net.URL;33import java.sql.Timestamp;34import java.util.List;35import java.util.Optional;36@Log4j237@Service38@RequiredArgsConstructor(onConstructor = @__({@Autowired, @Lazy}))39public class BackupDetailService extends XMLExportImportService<BackupDetail> {40 private final BackupDetailRepository repository;41 private final StorageServiceFactory storageServiceFactory;42 private final AgentService agentService;43 private final WorkspaceService workspaceService;44 private final AttachmentService attachmentService;45 private final TestDeviceService testDeviceService;46 private final TestPlanService testPlanService;47 private final RestStepService reststepService;48 private final TestCaseService testcaseService;49 private final TestCasePriorityService testCasePriorityService;50 private final TestCaseTypeService testCaseTypeService;51 private final TestDataProfileService testDataProfileService;52 private final TestStepService teststepService;53 private final ElementService elementService;54 private final WorkspaceVersionService versionService;55 private final ElementScreenService elementScreenService;56 private final UploadService uploadService;57 private final UploadVersionService uploadVersionService;58 private final BackupDetailMapper exportBackupEntityMapper;59 private final TestSuiteService testSuiteService;60 private final SuiteTestCaseMappingService suiteTestCaseMappingService;61 @Value("${unzip.dir}")62 private String unzipDir;63 public BackupDetail find(Long id) throws ResourceNotFoundException {64 return repository.findById(id).orElseThrow(() -> new ResourceNotFoundException("Backup is not found with id:" + id));65 }66 public Page<BackupDetail> findAll(Pageable pageable) {67 return repository.findAll(pageable);68 }69 public Optional<URL> downLoadURL(BackupDetail backupDetail) {70 return storageServiceFactory.getStorageService().generatePreSignedURLIfExists(71 "/backup/" + backupDetail.getName(), StorageAccessLevel.READ, 300);72 }73 public Optional<URL> getTestCasesPreSignedURL(BackupDetail backupDetail) {74 return storageServiceFactory.getStorageService().generatePreSignedURLIfExists(backupDetail.getAffectedCasesListPath(),75 StorageAccessLevel.READ, 300);76 }77 public BackupDetail create(BackupDetail backupDetail) {78 backupDetail.setMessage(MessageConstants.BACKUP_IS_IN_PROGRESS);79 backupDetail.setStatus(BackupStatus.IN_PROGRESS);80 backupDetail.setCreatedDate(new Timestamp(System.currentTimeMillis()));81 backupDetail = this.repository.save(backupDetail);82 return backupDetail;83 }84 public void create(BackupRequest request, MultipartFile file) throws IOException {85 BackupDTO importDTO = exportBackupEntityMapper.map(request);86 BackupDetail backupDetail = exportBackupEntityMapper.map(importDTO);87 backupDetail.setMessage(MessageConstants.BACKUP_IS_IN_PROGRESS);88 backupDetail.setStatus(BackupStatus.IN_PROGRESS);89 backupDetail.setActionType(BackupActionType.EXPORT);90 if (file != null && !file.isEmpty()) {91 backupDetail.setMessage(MessageConstants.IMPORT_IS_IN_PROGRESS);92 backupDetail.setStatus(BackupStatus.IN_PROGRESS);93 backupDetail.setActionType(BackupActionType.IMPORT);94 backupDetail = this.repository.save(backupDetail);95 try {96 File uploadedFile = this.copyZipFileToTemp(file);97 this.uploadImportFileToStorage(uploadedFile, backupDetail);98 this.importBackup(backupDetail);99 } catch (Exception e) {100 log.error(e.getMessage(), e);101 }102 } else {103 this.repository.save(backupDetail);104 }105 }106 public BackupDetail save(BackupDetail backupDetail) {107 return this.repository.save(backupDetail);108 }109 @Override110 Optional<BackupDetail> getRecentImportedEntity(BackupDTO importDTO, Long... ids) {111 return Optional.empty();112 }113 @Override114 boolean hasToSkip(BackupDetail backupDetail, BackupDTO importDTO) {115 return false;116 }117 @Override118 void updateImportedId(BackupDetail backupDetail, BackupDetail previous, BackupDTO importDTO) {119 }120 public void destroy(Long id) throws ResourceNotFoundException {121 BackupDetail detail = this.find(id);122 this.repository.delete(detail);123 }124 @Override125 protected Page<BackupDetail> findAll(Specification<BackupDetail> specification, Pageable pageRequest) throws ResourceNotFoundException {126 return null;127 }128 @Override129 protected List<? extends BaseXMLDTO> mapToXMLDTOList(List<BackupDetail> list) {130 return null;131 }132 @Override133 public Specification<BackupDetail> getExportXmlSpecification(BackupDTO backupDTO) throws ResourceNotFoundException {134 return null;135 }136 public void export(BackupRequest request) throws IOException, TestsigmaException {137 BackupDTO backupDTORequest = exportBackupEntityMapper.map(request);138 BackupDetail backupDetailRequest = exportBackupEntityMapper.map(backupDTORequest);139 final BackupDetail backupDetail = create(backupDetailRequest);140 final BackupDTO backupDTO = exportBackupEntityMapper.mapTo(backupDetail);141 log.debug("initiating backup - " + backupDetail.getId());142 new Thread(() -> {143 try {144 log.debug("backup process started for ::" + backupDetail.getId());145 initExportFolder(backupDTO);146 workspaceService.export(backupDTO);147 versionService.export(backupDTO);148 testCasePriorityService.export(backupDTO);149 testCaseTypeService.export(backupDTO);150 elementScreenService.export(backupDTO);151 elementService.export(backupDTO);152 testDataProfileService.export(backupDTO);153 attachmentService.export(backupDTO);154 agentService.export(backupDTO);155 uploadService.export(backupDTO);156 uploadVersionService.export(backupDTO);157 testcaseService.export(backupDTO);158 teststepService.export(backupDTO);159 reststepService.export(backupDTO);160 testSuiteService.export(backupDTO);161 suiteTestCaseMappingService.export(backupDTO);162 testPlanService.export(backupDTO);163 testDeviceService.export(backupDTO);164 backupDetail.setSrcFiles(backupDTO.getSrcFiles());165 backupDetail.setDestFiles(backupDTO.getDestFiles());166 exportToStorage(backupDetail);167 log.debug("backup process export completed");168 } catch (Exception e) {169 log.error(e.getMessage(), e);170 backupDetail.setStatus(BackupStatus.FAILURE);171 backupDetail.setMessage(e.getMessage());172 repository.save(backupDetail);173 destroy(backupDTO);174 } catch (Error error) {175 log.error(error.getMessage(), error);176 } finally {177 destroy(backupDTO);178 log.debug("backup process completed");179 }180 }).start();181 }182 public void importBackup(BackupDetail importOp) throws IOException, TestsigmaException {183 log.debug("initiating import - " + importOp.getId());184 final BackupDTO importDTO = exportBackupEntityMapper.mapTo(importOp);185 new Thread(() -> {186 try {187 log.debug("import process started for ::" + importOp.getId());188 importDTO.setImportFileUrl(storageServiceFactory.getStorageService().generatePreSignedURLIfExists(189 "/backup/" + importDTO.getName(), StorageAccessLevel.READ, 300).get().toString());190 initImportFolder(importDTO);191 // workspaceService.setXmlImportVersionPrerequisites(importDTO);192 versionService.setXmlImportVersionPrerequisites(importDTO);193 testCasePriorityService.importXML(importDTO);194 testCaseTypeService.importXML(importDTO);195 elementScreenService.importXML(importDTO);196 elementService.importXML(importDTO);197 testDataProfileService.importXML(importDTO);198 attachmentService.importXML(importDTO);...

Full Screen

Full Screen

Source:SuiteTestCaseMappingService.java Github

copy

Full Screen

...10import com.fasterxml.jackson.core.JsonProcessingException;11import com.fasterxml.jackson.core.type.TypeReference;12import com.fasterxml.jackson.dataformat.xml.XmlMapper;13import com.testsigma.dto.BackupDTO;14import com.testsigma.dto.export.SuiteTestCaseMappingXMLDTO;15import com.testsigma.exception.ResourceNotFoundException;16import com.testsigma.mapper.TestSuiteTestCaseMapper;17import com.testsigma.model.AbstractTestSuite;18import com.testsigma.model.SuiteTestCaseMapping;19import com.testsigma.model.TestCase;20import com.testsigma.model.TestSuite;21import com.testsigma.repository.SuiteTestCaseMappingRepository;22import com.testsigma.specification.SearchCriteria;23import com.testsigma.specification.SearchOperation;24import com.testsigma.specification.SuiteTestCaseMappingSpecificationsBuilder;25import lombok.RequiredArgsConstructor;26import lombok.extern.log4j.Log4j2;27import org.springframework.beans.factory.annotation.Autowired;28import org.springframework.context.annotation.Lazy;29import org.springframework.data.domain.Page;30import org.springframework.data.domain.PageRequest;31import org.springframework.data.domain.Pageable;32import org.springframework.data.jpa.domain.Specification;33import org.springframework.stereotype.Service;34import java.io.IOException;35import java.util.ArrayList;36import java.util.List;37import java.util.Optional;38import java.util.stream.Collectors;39@Log4j240@Service41@RequiredArgsConstructor(onConstructor = @__({@Autowired,@Lazy}))42public class SuiteTestCaseMappingService extends XMLExportImportService<SuiteTestCaseMapping> {43 private final SuiteTestCaseMappingRepository suiteTestCaseMappingRepository;44 private final TestSuiteService testSuiteService;45 private final TestSuiteTestCaseMapper mapper;46 private final TestCaseService testCaseService;47 public Optional<SuiteTestCaseMapping> findFirstByTestSuiteAndTestCase(AbstractTestSuite testSuite, TestCase testCase) {48 return suiteTestCaseMappingRepository.findFirstByTestSuiteAndTestCase(testSuite, testCase);49 }50 public List<SuiteTestCaseMapping> findAllBySuiteId(Long id) {51 return this.suiteTestCaseMappingRepository.findAllBySuiteId(id);52 }53 public SuiteTestCaseMapping add(SuiteTestCaseMapping suiteTestCaseMapping) {54 return this.suiteTestCaseMappingRepository.save(suiteTestCaseMapping);55 }56 public SuiteTestCaseMapping update(SuiteTestCaseMapping suiteTestCaseMapping) {57 return this.suiteTestCaseMappingRepository.save(suiteTestCaseMapping);58 }59 public Boolean deleteAll(List<SuiteTestCaseMapping> deletableMaps) {60 this.suiteTestCaseMappingRepository.deleteAll(deletableMaps);61 return true;62 }63 public void export(BackupDTO backupDTO) throws IOException, ResourceNotFoundException {64 if (!backupDTO.getIsSuitesEnabled()) return;65 log.debug("backup process for Testsuite case initiated");66 writeXML("test_suite_test_case_mapping", backupDTO, PageRequest.of(0, 25));67 log.debug("backup process for Testsuite case completed");68 }69 protected Page<SuiteTestCaseMapping> findAll(Specification specification, Pageable pageRequest) throws ResourceNotFoundException {70 return suiteTestCaseMappingRepository.findAll(specification, pageRequest);71 }72 @Override73 protected List<SuiteTestCaseMappingXMLDTO> mapToXMLDTOList(List<SuiteTestCaseMapping> list) {74 return mapper.map(list);75 }76 @Override77 public Specification<SuiteTestCaseMapping> getExportXmlSpecification(BackupDTO backupDTO) throws ResourceNotFoundException {...

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1package com.testsigma.test;2import com.testsigma.service.TestSuiteService;3import com.testsigma.service.TestSuiteServiceService;4import com.testsigma.service.TestSuiteServiceServiceLocator;5public class TestSuiteExport {6 public static void main(String[] args) {7 try {8 TestSuiteServiceService testSuiteServiceService = new TestSuiteServiceServiceLocator();9 TestSuiteService testSuiteService = testSuiteServiceService.getTestSuiteServicePort();10 String testSuiteName = "TestSuiteName";11ewTestSuite.xml";12 testSuiteService.export(testSuiteName, filePath);13 } catch (Exception e) {14 e.printStackTrace();15 }16 }17}

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.TestSuiteService;2import java.io.File;3import java.io.FileOutputStream;4import java.io.IOException;5import java.io.OutputStream;6import java.io.PrintStream;7import java.util.List;8import java.util.logging.Level;9import java.util.logging.Logger;10import org.apache.poi.ss.usermodel.Workbook;11import org.apache.poi.xssf.usermodel.XSSFWorkbook;12public class 2 {13 public static void main(String[] args) {14 try {15 String testSuiteName = "TestSuiteName";16 String testSuiteVersion = "1.0.0";17 String exportPath = "C:\\Users\\Administrator\\Desktop\\";18 String exportFileName = "TestSuiteName";19 String exportFileExtension = "xlsx";20 TestSuiteService testSuiteService = new TestSuiteService();21 Workbook workbook = testSuiteService.export(testSuiteName, testSuiteVersion, exportPath, exportFileName, exportFileExtension);22 File file = new File(exportPath + exportFileName + "." + exportFileExtension);23 OutputStream fileOut = new FileOutputStream(file);24 workbook.write(fileOut);25 fileOut.close();26 workbook.close();27 } catch (IOException ex) {28 Logger.getLogger(2.class.getName()).log(Level.SEVERE, null, ex);29 }30 }31}32import com.testsigma.service.TestSuiteService;33import java.io.File;34import java.io.FileOutputStream;35import java.io.IOException;36import java.io.OutputStream;37import java.io.PrintStream;38import java.util.List;39import java.util.logging.Level;40import java.util.logging.Logger;41import org.apache.poi.ss.usermodel.Workbook;42import org.apache.poi.xssf.usermodel.XSSFWorkbook;43public class 3 {44 public static void main(String[] args) {45 try {46 String testSuiteName = "TestSuiteName";47 String testSuiteVersion = "1.0.0";48 String exportPath = "C:\\Users\\Administrator\\Desktop\\";49 String exportFileName = "TestSuiteName";50 String exportFileExtension = "xlsx";51 TestSuiteService testSuiteService = new TestSuiteService();52 Workbook workbook = testSuiteService.export(testSuiteName, testSuiteVersion, exportPath, exportFileName, exportFileExtension);

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import java.io.File;2import java.io.IOException;3import java.util.List;4import org.apache.commons.io.FileUtils;5import com.testsigma.service.TestSuiteService;6public class ExportTestSuite {7public static void main(String[] args) throws IOException {8TestSuiteService testSuiteService = new TestSuiteService();9List<String> testSuiteIds = testSuiteService.getTestSuiteIds();10String testSuiteId = testSuiteIds.get(0);11File file = new File("testSuite.json");12FileUtils.writeStringToFile(file, testSuiteService.exportTestSuite(testSuiteId));13}14}15import java.io.File;16import java.io.IOException;17import java.util.List;18import org.apache.commons.io.FileUtils;19import com.testsigma.service.TestSuiteService;20public class ImportTestSuite {21public static void main(String[] args) throws IOException {22TestSuiteService testSuiteService = new TestSuiteService();23List<String> testSuiteIds = testSuiteService.getTestSuiteIds();24String testSuiteId = testSuiteIds.get(0);25File file = new File("testSuite.json");26testSuiteService.importTestSuite(testSuiteId, FileUtils.readFileToString(file));27}28}29import java.util.List;30import com.testsigma.service.TestSuiteService;31public class GetTestSuiteIds {32public static void main(String[] args) {33TestSuiteService testSuiteService = new TestSuiteService();34List<String> testSuiteIds = testSuiteService.getTestSuiteIds();35System.out.println(testSuiteIds);36}37}38import com.testsigma.service.TestSuiteService;39public class GetTestSuite {40public static void main(String[] args) {41TestSuiteService testSuiteService = new TestSuiteService();42List<String> testSuiteIds = testSuiteService.getTestSuiteIds();43String testSuiteId = testSuiteIds.get(0);44System.out.println(testSuiteService.getTestSuite(testSuiteId));45}46}

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.TestSuiteService;2import java.io.File;3public class TestSuiteServiceExport {4public static void main(String[] args) throws Exception {5TestSuiteService service = new TestSuiteService();6service.export("testSuiteId", new File("exportedTestSuite.xml"));7}8}9import com.testsigma.service.TestSuiteService;10import java.io.File;11public class TestSuiteServiceImport {12public static void main(String[] args) throws Exception {13TestSuiteService service = new TestSuiteService();14service.importTestSuite(new File("exportedTestSuite.xml"), "testSuiteId");15}16}17import com.testsigma.service.TestSuiteService;18public class TestSuiteServiceGetTestSuite {19public static void main(String[] args) throws Exception {20TestSuiteService service = new TestSuiteService();21System.out.println(service.getTestSuite("testSuiteId"));22}23}24import com.testsigma.service.TestSuiteService;25public class TestSuiteServiceGetTestSuites {26public static void main(String[] args) throws Exception {27TestSuiteService service = new TestSuiteService();28System.out.println(service.getTestSuites());29}30}31import com.testsigma.service.TestSuiteService;32public class TestSuiteServiceRemoveTestSuite {33public static void main(String[] args) throws Exception {34TestSuiteService service = new TestSuiteService();35service.removeTestSuite("testSuiteId");36}37}38import com.testsigma.service.TestSuiteService;39import com.testsigma.service.TestSuite;40public class TestSuiteServiceSave {41public static void main(String[] args) throws Exception {42TestSuiteService service = new TestSuiteService();43TestSuite testSuite = new TestSuite();44testSuite.setId("testSuiteId");45testSuite.setName("testSuiteName");46service.save(testSuite);47}48}

Full Screen

Full Screen

export

Using AI Code Generation

copy

Full Screen

1import com.testsigma.service.TestSuiteService;2import com.testsigma.service.TestSuiteServiceFactory;3import com.testsigma.service.TestSuiteServiceException;4import java.io.File;5import java.io.IOException;6public class 2 {7public static void main(String[] args) {8TestSuiteService testSuiteService = TestSuiteServiceFactory.getTestSuiteService();9try {10testSuiteService.export("testsuite.xml");11} catch (TestSuiteServiceException e) {12System.out.println("Error exporting test suite: " + e.getMessage());13} catch (IOException e) {14System.out.println("Error exporting test suite: " + e.getMessage());15}16}17}18import com.testsigma.service.TestSuiteService;19import com.testsigma.service.TestSuiteServiceFactory;20import com.testsigma.service.TestSuiteServiceException;21import java.io.File;22import java.io.IOException;23public class 3 {24public static void main(String[] args) {25TestSuiteService testSuiteService = TestSuiteServiceFactory.getTestSuiteService();26try {27testSuiteService.import("testsuite.xml");28} catch (TestSuiteServiceException e) {29System.out.println("Error importing test suite: " + e.getMessage());30} catch (IOException e) {31System.out.println("Error importing test suite: " + e.getMessage());32}33}34}35import com.testsigma.service.TestSuiteService;36import com.testsigma.service.TestSuiteServiceFactory;37import com.testsigma.service.TestSuiteServiceException;38import com.testsigma.service.TestSuite;39import com.testsigma.service.TestSuiteException;40public class 4 {41public static void main(String[] args) {42TestSuiteService testSuiteService = TestSuiteServiceFactory.getTestSuiteService();43try {44TestSuite testSuite = testSuiteService.getTestSuite();45} catch (TestSuiteServiceException e) {46System.out.println("Error

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