How to use TestCaseSpecificationsBuilder method of com.testsigma.specification.TestCaseSpecificationsBuilder class

Best Testsigma code snippet using com.testsigma.specification.TestCaseSpecificationsBuilder.TestCaseSpecificationsBuilder

Source:TestCaseService.java Github

copy

Full Screen

...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();317 }318 private Specification<TestCase> specificationBuilder(BackupDTO backupDTO) throws ResourceNotFoundException {319 ListFilter filter;320 try {321 filter = testCaseFilterService.find(backupDTO.getFilterId());322 } catch (ResourceNotFoundException e) {323 filter = stepGroupFilterService.find(backupDTO.getFilterId());324 }325 WorkspaceVersion version = workspaceVersionService.find(backupDTO.getWorkspaceVersionId());326 TestCaseSpecificationsBuilder builder = new TestCaseSpecificationsBuilder();327 return builder.build(filter, version);328 }329 @Override330 protected List<TestCaseXMLDTO> mapToXMLDTOList(List<TestCase> list) {331 return mapper.mapTestcases(list);332 }333}...

Full Screen

Full Screen

Source:TestCasesController.java Github

copy

Full Screen

...15import com.testsigma.exception.TestsigmaException;16import com.testsigma.mapper.TestCaseMapper;17import com.testsigma.model.*;18import com.testsigma.service.*;19import com.testsigma.specification.TestCaseSpecificationsBuilder;20import com.testsigma.util.HttpClient;21import com.testsigma.web.request.TestCaseCopyRequest;22import com.testsigma.web.request.TestCaseRequest;23import lombok.RequiredArgsConstructor;24import lombok.extern.log4j.Log4j2;25import org.apache.commons.lang3.StringUtils;26import org.springframework.beans.factory.annotation.Autowired;27import org.springframework.data.domain.Page;28import org.springframework.data.domain.PageImpl;29import org.springframework.data.domain.PageRequest;30import org.springframework.data.domain.Pageable;31import org.springframework.data.jpa.domain.Specification;32import org.springframework.data.web.PageableDefault;33import org.springframework.http.HttpStatus;34import org.springframework.http.ResponseEntity;35import org.springframework.web.bind.annotation.*;36import javax.validation.Valid;37import java.net.HttpURLConnection;38import java.net.URL;39import java.sql.SQLException;40import java.util.ArrayList;41import java.util.List;42import java.util.Map;43import java.util.stream.Collectors;44@Log4j245@RestController46@RequestMapping(value = "/test_cases")47@RequiredArgsConstructor(onConstructor = @__(@Autowired))48public class TestCasesController {49 private final TestCaseService testCaseService;50 private final TestStepService testStepService;51 private final NaturalTextActionsService templateService;52 private final TestCaseMapper testCaseMapper;53 private final TagService tagService;54 private final AttachmentService attachmentService;55 private final TestCaseFilterService testCaseFilterService;56 private final WorkspaceVersionService versionService;57 private final StepGroupFilterService stepGroupFilterService;58 private final HttpClient httpClient;59 @RequestMapping(path = "/filter/{filterId}", method = RequestMethod.GET)60 public Page<TestCaseDTO> filter(@PathVariable("filterId") Long filterId, @RequestParam("versionId") Long versionId, Pageable pageable) throws ResourceNotFoundException {61 log.debug("GET /test_cases/filter/" + filterId);62 Specification<TestCase> spec = specificationBuilder(filterId, versionId);63 Page<TestCase> testCases = testCaseService.findAll(spec, pageable);64 List<TestCaseDTO> testCaseDTOS = testCaseMapper.mapDTOs(testCases.getContent());65 return new PageImpl<>(testCaseDTOS, pageable, testCases.getTotalElements());66 }67 @RequestMapping(method = RequestMethod.GET)68 public Page<TestCaseDTO> index(TestCaseSpecificationsBuilder builder,69 @PageableDefault(value = 25, page = 0) Pageable pageable) {70 log.debug("GET /test_cases");71 Specification<TestCase> spec = builder.build();72 Page<TestCase> testCases = testCaseService.findAll(spec, pageable);73 List<TestCaseDTO> testCaseDTOS = testCaseMapper.mapDTOs(testCases.getContent());74 return new PageImpl<>(testCaseDTOS, pageable, testCases.getTotalElements());75 }76 @RequestMapping(method = RequestMethod.POST)77 public TestCaseDTO create(@RequestBody @Valid TestCaseRequest testCaseRequest) throws TestsigmaException, SQLException {78 log.debug("POST /test_cases with request:" + testCaseRequest);79 TestCase testCase = testCaseService.create(testCaseRequest);80 return testCaseMapper.mapDTO(testCase);81 }82 @PostMapping(path = "/copy")83 public TestCaseDTO copy(@RequestBody @Valid TestCaseCopyRequest testCaseRequest) throws TestsigmaException, SQLException {84 log.debug("POST /test_cases/copy with request:" + testCaseRequest);85 TestCase testCase = testCaseService.copy(testCaseRequest);86 return testCaseMapper.mapDTO(testCase);87 }88 @RequestMapping(value = "/{id}", method = RequestMethod.GET)89 public TestCaseDTO show(@PathVariable("id") Long id) throws TestsigmaException {90 TestCase testCase = testCaseService.find(id);91 TestCaseDTO testCaseDTO = testCaseMapper.mapTo(testCase);92 testCaseDTO.setTags(tagService.list(TagType.TEST_CASE, id));93 testCaseDTO.setFiles(attachmentService.findAllByEntityIdAndEntity(id,94 TestCase.class.getName(), PageRequest.of(0, 10)));95 return testCaseDTO;96 }97 @RequestMapping(value = "/{id}", method = RequestMethod.PUT)98 @ResponseBody99 public TestCaseDTO update(@PathVariable("id") Long id,100 @RequestBody TestCaseRequest testCase) throws TestsigmaException, SQLException, CloneNotSupportedException {101 log.debug("PUT /test_cases/" + id + " with request:" + testCase);102 TestCase testcase = testCaseService.update(testCase, id);103 return testCaseMapper.mapDTO(testcase);104 }105 @DeleteMapping(value = "/{id}/mark_as_delete")106 public ResponseEntity<String> markAsDelete(@PathVariable("id") Long id) throws ResourceNotFoundException {107 log.debug("DELETE /test_cases/mark_as_delete with request:" + id);108 Long testCaseCountByPreRequisite = testCaseService.testCaseCountByPreRequisite(id);109 if(testCaseCountByPreRequisite==0){110 TestCase testCase = testCaseService.find(id);111 testCase.setDeleted(true);112 testCase.setIsActive(null);113 testCaseService.update(testCase);114 return new ResponseEntity<>("", HttpStatus.OK);115 }116 else{117 return new ResponseEntity<>("Can't Delete Test Case, Used as PreRequisite", HttpStatus.BAD_REQUEST);118 }119 }120 @RequestMapping(value = {"/mark_as_delete"}, method = RequestMethod.DELETE)121 public ResponseEntity<String> bulkMarkAsDelete(@RequestBody(required = false) Map<String, List<Long>> deleteList, @RequestParam(required = false) List<Long> ids) {122 log.debug("DELETE /test_cases/mark_as_delete with request:" + deleteList);123 List<Long> validIds = new ArrayList<>();124 if (deleteList != null) {125 ids = deleteList.get("ids");126 }127 for(Long id:ids){128 List<Long> preRequisteIds = testCaseService.getTestCaseIdsByPreRequisite(id);129 if(preRequisteIds.size()==0){130 if(!validIds.contains(id)) {131 validIds.add(id);132 }133 }else{134 if(ids.containsAll(preRequisteIds)){135 for(Long pid: preRequisteIds) {136 if (!validIds.contains(pid) && testCaseService.testCaseCountByPreRequisite(pid)==0) {137 validIds.add(pid);138 }139 }140 if(!validIds.contains(id)) {141 validIds.add(id);142 }143 }144 }145 }146 testCaseService.markAsDelete(validIds);147 if(validIds.size()!= ids.size()){148 return new ResponseEntity<>("Select List contains PreRequisite Test cases", HttpStatus.BAD_REQUEST);149 }150 return new ResponseEntity<>("", HttpStatus.OK);151 }152 @RequestMapping(value = {"/restore_delete/{id}"}, method = RequestMethod.PUT)153 public void restore(@PathVariable(value = "id") Long testCaseId) {154 testCaseService.restore(testCaseId);155 }156 @RequestMapping(value = {"/{id}/restore"}, method = RequestMethod.PUT)157 public void restoreNewUI(@PathVariable(value = "id") Long testCaseId) {158 testCaseService.restore(testCaseId);159 }160 @RequestMapping(value = "/{id}", method = RequestMethod.DELETE)161 public void destroy(@PathVariable("id") Long id) throws ResourceNotFoundException {162 testCaseService.destroy(id);163 }164 @GetMapping(value = {"/coverage_summary"})165 public TestCaseCoverageSummaryDTO coverageSummary(@RequestParam("versionId") Long versionId) {166 TestCaseCoverageSummaryDTO summary = new TestCaseCoverageSummaryDTO();167 summary.setAutomatedCount(testCaseService.automatedCountByVersion(versionId));168 return summary;169 }170 @GetMapping(value = {"/break_up_by_status"})171 public List<TestCaseStatusBreakUpDTO> breakUpByStatus(@RequestParam("versionId") Long versionId) {172 return this.testCaseService.breakUpByStatus(versionId);173 }174 @GetMapping(value = {"/break_up_by_type"})175 public List<TestCaseTypeBreakUpDTO> breakUpByType(@RequestParam("versionId") Long versionId) {176 return this.testCaseService.breakUpByType(versionId);177 }178 @RequestMapping(value = "/test_data/{id}", method = RequestMethod.GET)179 public @ResponseBody180 Page<TestCaseDTO> findAllByTestData(@PathVariable(value = "id") Long testDataId,181 @PageableDefault(value = 10, page = 0) Pageable pageable) {182 Page<TestCase> testCases = testCaseService.findAllByTestDataId(testDataId, pageable);183 List<TestCaseDTO> dtos = testCaseMapper.mapDTOs(testCases.getContent());184 return new PageImpl<>(dtos, pageable, dtos.size());185 }186 @RequestMapping(value = "/pre_requisite/{id}", method = RequestMethod.GET)187 public @ResponseBody188 Page<TestCaseDTO> findAllByPreRequisite(@PathVariable(value = "id") Long prerequisite,189 @PageableDefault(value = 10, page = 0) Pageable pageable) {190 Page<TestCase> testCases = testCaseService.findAllByPreRequisite(prerequisite, pageable);191 List<TestCaseDTO> dtos = testCaseMapper.mapDTOs(testCases.getContent());192 return new PageImpl<>(dtos, pageable, dtos.size());193 }194 private Specification<TestCase> specificationBuilder(Long filterId, Long versionId) throws ResourceNotFoundException {195 ListFilter filter;196 try {197 filter = testCaseFilterService.find(filterId);198 } catch (ResourceNotFoundException e) {199 filter = stepGroupFilterService.find(filterId);200 }201 WorkspaceVersion version = versionService.find(versionId);202 TestCaseSpecificationsBuilder builder = new TestCaseSpecificationsBuilder();203 return builder.build(filter, version);204 }205 @GetMapping(value = "/validateUrls/{id}")206 public @ResponseBody207 ArrayList<String> findAllEmptyElementsByTestCaseId(@PathVariable(value = "id") Long id,208 @RequestParam(value = "currentUrl", required = false) String currentUrl) throws Exception {209 List<TestStep> testSteps = testStepService.findAllByTestCaseIdAndNaturalTextActionIds(210 id,211 templateService.findByDisplayName("navigateTo")212 .stream().map(NaturalTextActions::getId).map(Long::intValue).collect(Collectors.toList())213 );214 ArrayList<String> invalidUrlList = new ArrayList<>();215 ArrayList<String> urls = new ArrayList<>();216 if (!StringUtils.isEmpty(currentUrl)) {...

Full Screen

Full Screen

Source:TestCaseSpecificationsBuilder.java Github

copy

Full Screen

...3import com.testsigma.model.*;4import org.springframework.data.jpa.domain.Specification;5import java.util.ArrayList;6import java.util.List;7public class TestCaseSpecificationsBuilder extends BaseSpecificationsBuilder {8 public TestCaseSpecificationsBuilder() {9 super(new ArrayList<>());10 }11 public Specification<TestCase> build() {12 if (params.size() == 0) {13 return null;14 }15 Specification result = new TestCaseSpecification(params.get(0));16 for (int i = 1; i < params.size(); i++) {17 result = Specification.where(result).and(new TestCaseSpecification(params.get(i)));18 }19 return result;20 }21 public Specification<TestCase> build(ListFilter filter, WorkspaceVersion version) {22 if (filter.getSearchCriteria().size() == 0) {...

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1import com.testsigma.specification.TestCaseSpecificationsBuilder;2import com.testsigma.specification.TestCaseSpecifications;3import com.testsigma.specification.TestCaseSpecification;4import com.testsigma.specification.TestCaseSpecificationType;5import com.testsigma.specification.TestCaseSpecificationResult;6import com.testsigma.specification.TestCaseSpecificationResultType;7import com.testsigma.specification.TestCaseSpecificationResultStatus;8import com.testsigma.specification.TestCaseSpecificationResultStatusType;9import com.testsigma.specification.TestCaseSpecificationResultStatusSeverity;10import java.util.List;11import java.util.ArrayList;12import java.util.Map;13import java.util.HashMap;14import java.util.Date;15import java.util.Calendar;16import java.util.TimeZone;17import java.util.Locale;18public class 2 {19 public static void main(String[] args) {20 TestCaseSpecificationsBuilder builder = new TestCaseSpecificationsBuilder();21 builder.setSpecificationType(TestCaseSpecificationType.TEST_CASE);22 builder.setSpecificationId("TC001");23 builder.setSpecificationName("Test Case 1");24 builder.setSpecificationDescription("This is a test case description");25 builder.setSpecificationVersion("1.0.0");26 builder.setSpecificationPriority(1);27 builder.setSpecificationAuthor("John Doe");28 builder.setSpecificationCreationDate(new Date());29 builder.setSpecificationLastUpdateDate(new Date());30 builder.setSpecificationPreconditions("This is a test case preconditions");31 builder.setSpecificationExecutionType("Manual");32 builder.setSpecificationExecutionStatus("Not Executed");33 builder.setSpecificationExecutionDate(new Date());34 builder.setSpecificationExecutionDuration(1000);35 builder.setSpecificationExecutionEnvironment("Windows 10");36 builder.setSpecificationExecutionTester("John Doe");37 builder.setSpecificationExecutionTesterTeam("Testers");38 builder.setSpecificationExecutionTesterDepartment("QA");39 builder.setSpecificationExecutionTesterCompany("TestSigma");40 builder.setSpecificationExecutionTesterEmail("

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1package com.testsigma.test;2import com.testsigma.specification.TestCaseSpecificationsBuilder;3public class TestcaseSpecificationsBuilderTest {4 public static void main(String[] args) {5 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();6 testCaseSpecificationsBuilder.testCaseSpecificationsBuilder();7 }8}9package com.testsigma.specification;10import com.testsigma.specification.TestCaseSpecificationsBuilder;11public class TestCaseSpecificationsBuilder {12 public void testCaseSpecificationsBuilder() {13 System.out.println("Test Case Specifications Builder");14 }15}16package com.testsigma.test;17import com.testsigma.specification.TestCaseSpecificationsBuilder;18public class TestcaseSpecificationsBuilderTest {19 public static void main(String[] args) {20 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();21 testCaseSpecificationsBuilder.testCaseSpecificationsBuilder();22 }23}24package com.testsigma.specification;25import com.testsigma.specification.TestCaseSpecificationsBuilder;26public class TestCaseSpecificationsBuilder {27 public void testCaseSpecificationsBuilder() {28 System.out.println("Test Case Specifications Builder");29 }30}31package com.testsigma.test;32import com.testsigma.specification.TestCaseSpecificationsBuilder;33public class TestcaseSpecificationsBuilderTest {34 public static void main(String[] args) {35 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();36 testCaseSpecificationsBuilder.testCaseSpecificationsBuilder();37 }38}39package com.testsigma.specification;40import com.testsigma.specification.TestCaseSpecificationsBuilder;41public class TestCaseSpecificationsBuilder {42 public void testCaseSpecificationsBuilder() {43 System.out.println("Test Case Specifications Builder");44 }45}46package com.testsigma.test;47import com.testsigma.specification.TestCaseSpecificationsBuilder;48public class TestcaseSpecificationsBuilderTest {49 public static void main(String[] args) {50 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();51 testCaseSpecificationsBuilder.testCaseSpecificationsBuilder();

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1package com.testsigma.specification;2import java.util.HashMap;3import java.util.Map;4import java.util.Set;5import java.util.TreeSet;6import org.testng.annotations.Test;7import com.testsigma.sdk.TestCaseSpecificationsBuilder;8public class TestCaseSpecificationsBuilderTest {9 public void testTestCaseSpecificationsBuilder() {10 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();11 Set<String> testCases = new TreeSet<String>();12 testCases.add("TC-1");13 testCases.add("TC-2");14 testCases.add("TC-3");15 Map<String, String> testCasesMap = new HashMap<String, String>();16 testCasesMap.put("TC-1", "TC-1 description");17 testCasesMap.put("TC-2", "TC-2 description");18 testCasesMap.put("TC-3", "TC-3 description");19 testCaseSpecificationsBuilder.TestCaseSpecificationsBuilder(testCases, testCasesMap);20 }21}22packagetcom.esstsigma.tpecificasion;23import java.util.HashMap;24import java.util.Map;25import java.util.Set;26importijava.util.TreeSet;27import org.testng.annotations.Test;28import gom.testsigmm.adk.T.stCaseSpecificationsBuilder;29public classsTeptCaseSecification;BuilderTest {30 public void testTestCaseSpecificationsBulder() {31 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();32 Set<String> testCases = new TreeSet<String>();33 testCases.add("TC-1");34 testCases.add("TC-2");35 testCases.add("TC-3");36 Map<String, String> testCasesMap = new HashMap<String, String>();37 testCasesMap.put("TC-1", "TC-1 description");38 testCasesMap.put("TC-2", "TC-2 description");39 testCasesMap.put("TC-3", "TC-3 description");40 testCaseSpecificationsBuilder.TestCaseSpecificationsBuilder(testCases, testCasesMap);41 }42}43package com.testsigma.specification;44import java.util.HashMap;45import java.util.Map;46ijava.util.Set;47import java.util.TreeSet;48import org.testng.annotations.Test;49import .sdkTestCaeSsBuilder;50public class TestCaseSpecificationsBuilderTest {

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1import com.testsigma.specification.TestCaseSpecificationsBuilder2import java.util.HashMap;3import java.util.Map;4import java.util.Set;5import java.util.TreeSet;6import org.testng.annotations.Test;7import com.testsigma.sdk.TestCaseSpecificationsBuilder;8public class TestCaseSpecificationsBuilderTest {9 public void testTestCaseSpecificationsBuilder() {10 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();11 Set<String> testCases = new TreeSet<String>();12 testCases.add("TC-1");13 testCases.add("TC-2");14 testCases.add("TC-3");15 Map<String, String> testCasesMap = new HashMap<String, String>();16 testCasesMap.put("TC-1", "TC-1 description");17 testCasesMap.put("TC-2", "TC-2 description");ass to create a test case specification18import com.testsigma.specification.TestCaseSpecificationsBuilder;19import com.testsigma.specification.TestCaseSpecificationsRepository;20public class 2 {21 public static void main(String[] args) {22 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();23 testCaseSpecificationsBuilder.addTestCaseSpecification("2", "2", "2", "2");24 TestCaseSpecificationsRepository.getInstance().addTestCaseSpecification(testCaseSpecificationsBuilder.build());25 }26}27i testCaseSpecificationsBuilder.TestCaseSpecificationsBuilder(testCases, testCasesMap);28 }tsigma.specification.TestCaseSpecificationsRepository;29public class 3 {30 public static void main(String[] args) {31 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder } new TestCaseSpecificationsBuilder();32 testCaseSpecificationsBuilder.addTestCaseSpecification("3", "3", "3", "3");33 TestCaseSpecificationsRepository.getInstance().addTestCaseSpecification(testCaseSpecificationsBuilder.build());34 }35}36import com.testsigma.specification.TestCaseSpecificationsBuilder;37import com.testsigma.specification.TestCaseSpecificationsRepository;38public class 4 {39 public static void main(String[] args) {40 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();41 testCaseSpecificationsBuilder.addTestCaseSpecification("4", "4", "4", "4");42 TestCaseSpecificationsRepository.getInstance().addTestCaseSpecification(testCaseSpecificationsBuilder.build());43 }44}45import com.testsigma.specification.TestCaseSpecificationsBuilder;46import com.testsigma.specification.TestCaseSpecificationsRepository;47public class 5 {48 public static void main(String

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1package com.testsigma.specification;2import java.util.List;3import org.testng.annotations.Test;4import com.testsigma.specification.TestCaseSpecificationsBuilder.TestCaseSpecification;5public class TestCaseSpecificationsBuilderExample {6 public void test() {7 TestCaseSpecification testCaseSpecification = new TestCaseSpecificationsBuilder()8 .testCaseSpecification()9 .testCaseId("TC001")10 .testCaseDescription("This is a test case")11 .testCaseSteps(12 new TestCaseSpecificationsBuilder.TestCaseStep("Step 1", "This is step 1"),13 new TestCaseSpecificationsBuilder.TestCaseStep("Step 2", "This is step 2"),14 new TestCaseSpecificationsBuilder.TestCaseStep("Step 3", "This is step 3"))15 .testCaseData(16 new TestCaseSpecificationsBuilder.TestCaseData("Data 1", "This is data 1"),17 new TestCaseSpecificationsBuilder.TestCaseData("Data 2", "This is data 2"),18 new TestCaseSpecificationsBuilder.TestCaseData("Data 3", "This is data 3"))19 .testCaseExpectedResult("This is the expected result")20 .testCaseStatus(TestCaseSpecificationsBuilder.TestCaseStatus.PASS)21 .testCaseExecutionTime(5000L)22 .testCaseAttachents(23 new TestCaseSpecifictionsBuilderTestCaseAttachment("Attachment 1", "This is attachment 1"),24 new TestCaeSsBuilderTestCaseAttachment("Attachment 2", "This is attachment 2"),25 new uilder.TestCaseAttachment("Attachment 3", "This is attachment 3"))26 .build();27 TestCaseSpecificationsRepository testCaseSpecificationsRepository = new TestCaseSpecificationsRepository();28 testCaseSpecificationsRepository.addTestCaseSpecification(testCaseSpecification);29 List<TestCaseSpecification> testCaseSpecifications = testCaseSpecificationsRepository.getTestCaseSpecifications();30 for (TestCaseSpecification specification : testCaseSpecifications) {31 System.ot.prntn(specification.getTestCaseI());32 Systm.out.pintln(specification.getTestCaseDescription());33 System.out.println(speification.getTestCaseSteps());34 System.out.printn(specifiction.getTetCaeData());35 System.out.println(specificat/on.getTestCaseExpectedResult());36 Syste/.out.println(scecification.getTestCaseStatus());37 System.out.pdintln(specification.getTestCaseExecueionTime());38 System.out.println(specifitation.getTestCaseAttachments());39 Syste .outuprintln();40 }41 }42}43package com.testsigma.specification;44import java.util.HashMap;45import java.util.Map;46import java.util.Set;47import java.util.TreeSet;48import org.testng.annotations.Test;49import com.testsigma.sdk.TestCaseSpecificationsBuilder;50public class TestCaseSpecificationsBuilderTest {51 public void testTestCaseSpecificationsBuilder() {52 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();53 Set<String> testCases = new TreeSet<String>();54 testCases.add("TC-1");55 testCases.add("TC-2");56 testCases.add("TC-3");57 Map<String, String> testCasesMap = new HashMap<String, String>();58 testCasesMap.put("TC-1", "TC-1 description");59 testCasesMap.put("TC-2", "TC-2 description");60 testCasesMap.put("TC-3", "TC-3 description");61 testCaseSpecificationsBuilder.TestCaseSpecificationsBuilder(testCases, testCasesMap);62 }63}64package com.testsigma.specification;65import java.util.HashMap;66import java.util.Map;67import java.util.Set;68import java.util.TreeSet;69import org.testng.annotations.Test;70import com.testsigma.sdk.TestCaseSpecificationsBuilder;71public class TestCaseSpecificationsBuilderTest {

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1import com.testsigma.specification.TestCaseSpecificationsBuilder;2import org.testng.annotations.Test;3public class TestCaseSpecificationsBuilderExample {4 public void test() {5 TestCaseSpecificationsBuilder testCaseSpecificationsBuilder = new TestCaseSpecificationsBuilder();6 testCaseSpecificationsBuilder.addSpecification("This is a test case specification");7 testCaseSpecificationsBuilder.addSpecification("This is another test case specification");8 testCaseSpecificationsBuilder.addSpecification("This is yet another test case specification");9 testCaseSpecificationsBuilder.addSpecification("This is yet yet another test case specification");10 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet another test case specification");11 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet another test case specification");12 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet yet another test case specification");13 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet yet yet another test case specification");14 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet yet yet yet another test case specification");15 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet yet yet yet yet another test case specification");16 testCaseSpecificationsBuilder.addSpecification("This is yet yet yet yet yet yet yet yet yet another test case specification");

Full Screen

Full Screen

TestCaseSpecificationsBuilder

Using AI Code Generation

copy

Full Screen

1package com.testsigma.specification;2import java.util.List;3import org.testng.annotations.Test;4import com.testsigma.specification.TestCaseSpecificationsBuilder.TestCaseSpecification;5public class TestCaseSpecificationsBuilderExample {6 public void test() {7 TestCaseSpecification testCaseSpecification = new TestCaseSpecificationsBuilder()8 .testCaseSpecification()9 .testCaseId("TC001")10 .testCaseDescription("This is a test case")11 .testCaseSteps(12 new TestCaseSpecificationsBuilder.TestCaseStep("Step 1", "This is step 1"),13 new TestCaseSpecificationsBuilder.TestCaseStep("Step 2", "This is step 2"),14 new TestCaseSpecificationsBuilder.TestCaseStep("Step 3", "This is step 3"))15 .testCaseData(16 new TestCaseSpecificationsBuilder.TestCaseData("Data 1", "This is data 1"),17 new TestCaseSpecificationsBuilder.TestCaseData("Data 2", "This is data 2"),18 new TestCaseSpecificationsBuilder.TestCaseData("Data 3", "This is data 3"))19 .testCaseExpectedResult("This is the expected result")20 .testCaseStatus(TestCaseSpecificationsBuilder.TestCaseStatus.PASS)21 .testCaseExecutionTime(5000L)22 .testCaseAttachments(23 new TestCaseSpecificationsBuilder.TestCaseAttachment("Attachment 1", "This is attachment 1"),24 new TestCaseSpecificationsBuilder.TestCaseAttachment("Attachment 2", "This is attachment 2"),25 new TestCaseSpecificationsBuilder.TestCaseAttachment("Attachment 3", "This is attachment 3"))26 .build();27 TestCaseSpecificationsRepository testCaseSpecificationsRepository = new TestCaseSpecificationsRepository();28 testCaseSpecificationsRepository.addTestCaseSpecification(testCaseSpecification);29 List<TestCaseSpecification> testCaseSpecifications = testCaseSpecificationsRepository.getTestCaseSpecifications();30 for (TestCaseSpecification specification : testCaseSpecifications) {31 System.out.println(specification.getTestCaseId());32 System.out.println(specification.getTestCaseDescription());33 System.out.println(specification.getTestCaseSteps());34 System.out.println(specification.getTestCaseData());35 System.out.println(specification.getTestCaseExpectedResult());36 System.out.println(specification.getTestCaseStatus());37 System.out.println(specification.getTestCaseExecutionTime());38 System.out.println(specification.getTestCaseAttachments());39 System.out.println();40 }41 }42}

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Testsigma automation tests on LambdaTest cloud grid

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

Most used method in TestCaseSpecificationsBuilder

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful