use of com.epam.ta.reportportal.ws.model.analyzer.SearchRq in project service-api by reportportal.
the class SearchLogServiceImpl method composeRequest.
private Optional<SearchRq> composeRequest(SearchLogRq request, Project project, TestItem item, Launch launch) {
SearchLogsMode searchMode = SearchLogsMode.fromString(request.getSearchMode()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, request.getSearchMode()));
SearchRq searchRq = new SearchRq();
searchRq.setFilteredLaunchIds(searchCollectorFactory.getCollector(searchMode).collect(request.getFilterId(), launch));
// TODO fix query - select messages from `Nested Step` descendants too
List<String> logMessages = logRepository.findMessagesByLaunchIdAndItemIdAndPathAndLevelGte(launch.getId(), item.getItemId(), item.getPath(), LogLevel.ERROR_INT);
if (CollectionUtils.isEmpty(logMessages)) {
return Optional.empty();
}
searchRq.setLogMessages(logMessages);
final AnalyzerConfig analyzerConfig = AnalyzerUtils.getAnalyzerConfig(project);
searchRq.setAnalyzerConfig(analyzerConfig);
searchRq.setLogLines(analyzerConfig.getNumberOfLogLines());
searchRq.setItemId(item.getItemId());
searchRq.setLaunchId(launch.getId());
searchRq.setLaunchName(launch.getName());
searchRq.setProjectId(project.getId());
return Optional.of(searchRq);
}
use of com.epam.ta.reportportal.ws.model.analyzer.SearchRq in project service-api by reportportal.
the class SearchLogServiceImpl method search.
@Override
public Iterable<SearchLogRs> search(Long itemId, SearchLogRq request, ReportPortalUser.ProjectDetails projectDetails) {
Project project = projectRepository.findById(projectDetails.getProjectId()).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectDetails.getProjectId()));
TestItem item = testItemRepository.findById(itemId).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, itemId));
Launch launch = launchRepository.findById(item.getLaunchId()).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, item.getLaunchId()));
expect(item.getItemResults().getStatus(), not(statusIn(StatusEnum.IN_PROGRESS))).verify(ErrorType.TEST_ITEM_IS_NOT_FINISHED);
return composeRequest(request, project, item, launch).map(searchRq -> processRequest(project.getId(), searchRq)).orElse(Collections.emptyList());
}
Aggregations