Search in sources :

Example 1 with SearchLogsMode

use of com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode 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);
}
Also used : SearchLogsMode(com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) SearchRq(com.epam.ta.reportportal.ws.model.analyzer.SearchRq)

Aggregations

SearchLogsMode (com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 SearchRq (com.epam.ta.reportportal.ws.model.analyzer.SearchRq)1 AnalyzerConfig (com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)1