Search in sources :

Example 1 with PathName

use of com.epam.ta.reportportal.entity.item.PathName in project service-api by reportportal.

the class SearchLogServiceImpl method composeResponse.

private SearchLogRs composeResponse(Map<Long, TestItem> testItemMapping, Long projectId, Long itemId, Log log) {
    TestItem testItem = ofNullable(testItemMapping.get(itemId)).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, itemId));
    Long launchId = ofNullable(testItem.getLaunchId()).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, testItem.getLaunchId()));
    Launch launch = launchRepository.findById(launchId).orElseThrow(() -> new ReportPortalException(ErrorType.LAUNCH_NOT_FOUND, launchId));
    Map<Long, PathName> pathNameMapping = testItemRepository.selectPathNames(singletonList(testItem));
    SearchLogRs response = new SearchLogRs();
    response.setLaunchId(launch.getId());
    ofNullable(pathNameMapping.get(testItem.getItemId())).ifPresent(pathName -> {
        response.setPathNames(TestItemConverter.PATH_NAME_TO_RESOURCE.apply(pathName));
    });
    response.setItemId(testItem.getItemId());
    response.setItemName(testItem.getName());
    response.setPath(testItem.getPath());
    response.setPatternTemplates(testItem.getPatternTemplateTestItems().stream().map(patternTemplateTestItem -> patternTemplateTestItem.getPatternTemplate().getName()).collect(toSet()));
    response.setDuration(ofNullable(testItem.getItemResults().getDuration()).orElseGet(() -> getDuration(testItem)));
    response.setStatus(testItem.getItemResults().getStatus().name());
    TestItem itemWithStats = testItem;
    while (!itemWithStats.isHasStats()) {
        final Long parentId = itemWithStats.getParentId();
        itemWithStats = testItemRepository.findById(parentId).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, parentId));
    }
    response.setIssue(IssueConverter.TO_MODEL.apply(itemWithStats.getItemResults().getIssue()));
    response.setLogs(Lists.newArrayList(TO_LOG_ENTRY.apply(log)));
    return response;
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) SearchLogRs(com.epam.ta.reportportal.ws.model.log.SearchLogRs) PathName(com.epam.ta.reportportal.entity.item.PathName) Launch(com.epam.ta.reportportal.entity.launch.Launch) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

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 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 SearchLogRs (com.epam.ta.reportportal.ws.model.log.SearchLogRs)1