Search in sources :

Example 1 with SearchRq

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);
}
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)

Example 2 with 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());
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) java.util(java.util) Project(com.epam.ta.reportportal.entity.project.Project) TestItem(com.epam.ta.reportportal.entity.item.TestItem) LogLevel(com.epam.ta.reportportal.entity.enums.LogLevel) Autowired(org.springframework.beans.factory.annotation.Autowired) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) SearchCollectorFactory(com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchCollectorFactory) Collections.singletonList(java.util.Collections.singletonList) Preconditions.statusIn(com.epam.ta.reportportal.commons.Preconditions.statusIn) Lists(com.google.common.collect.Lists) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Collectors.toMap(java.util.stream.Collectors.toMap) CollectionUtils(org.apache.commons.collections.CollectionUtils) Service(org.springframework.stereotype.Service) Log(com.epam.ta.reportportal.entity.log.Log) TestItemConverter(com.epam.ta.reportportal.ws.converter.converters.TestItemConverter) LogRepository(com.epam.ta.reportportal.dao.LogRepository) Predicates.not(com.epam.ta.reportportal.commons.Predicates.not) SearchLogRs(com.epam.ta.reportportal.ws.model.log.SearchLogRs) SearchLogService(com.epam.ta.reportportal.core.analyzer.auto.SearchLogService) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) SearchLogRq(com.epam.ta.reportportal.ws.model.log.SearchLogRq) TO_LOG_ENTRY(com.epam.ta.reportportal.ws.converter.converters.LogConverter.TO_LOG_ENTRY) Collectors.toSet(java.util.stream.Collectors.toSet) Launch(com.epam.ta.reportportal.entity.launch.Launch) SearchRq(com.epam.ta.reportportal.ws.model.analyzer.SearchRq) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Optional.ofNullable(java.util.Optional.ofNullable) IssueConverter(com.epam.ta.reportportal.ws.converter.converters.IssueConverter) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) AnalyzerConfig(com.epam.ta.reportportal.ws.model.project.AnalyzerConfig) Maps(com.google.common.collect.Maps) PathName(com.epam.ta.reportportal.entity.item.PathName) ChronoUnit(java.time.temporal.ChronoUnit) SearchLogsMode(com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode) LaunchRepository(com.epam.ta.reportportal.dao.LaunchRepository) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) SearchRs(com.epam.ta.reportportal.ws.model.analyzer.SearchRs) AnalyzerServiceClient(com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient) Transactional(org.springframework.transaction.annotation.Transactional) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

SearchLogsMode (com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchLogsMode)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 SearchRq (com.epam.ta.reportportal.ws.model.analyzer.SearchRq)2 AnalyzerConfig (com.epam.ta.reportportal.ws.model.project.AnalyzerConfig)2 Preconditions.statusIn (com.epam.ta.reportportal.commons.Preconditions.statusIn)1 Predicates.not (com.epam.ta.reportportal.commons.Predicates.not)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 SearchLogService (com.epam.ta.reportportal.core.analyzer.auto.SearchLogService)1 AnalyzerServiceClient (com.epam.ta.reportportal.core.analyzer.auto.client.AnalyzerServiceClient)1 SearchCollectorFactory (com.epam.ta.reportportal.core.analyzer.auto.strategy.search.SearchCollectorFactory)1 LaunchRepository (com.epam.ta.reportportal.dao.LaunchRepository)1 LogRepository (com.epam.ta.reportportal.dao.LogRepository)1 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 LogLevel (com.epam.ta.reportportal.entity.enums.LogLevel)1 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)1 PathName (com.epam.ta.reportportal.entity.item.PathName)1 TestItem (com.epam.ta.reportportal.entity.item.TestItem)1 Launch (com.epam.ta.reportportal.entity.launch.Launch)1