Search in sources :

Example 6 with IssueEntity

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

the class ClusterItemDataProviderMockTest method getIssueEntity.

private IssueEntity getIssueEntity(Long index) {
    final IssueEntity issueEntity = new IssueEntity();
    issueEntity.setIssueId(index);
    issueEntity.setIssueDescription("description " + index);
    issueEntity.setAutoAnalyzed(false);
    issueEntity.setIgnoreAnalyzer(false);
    final IssueType issueType = getIssueType();
    issueEntity.setIssueType(issueType);
    return issueEntity;
}
Also used : IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity)

Example 7 with IssueEntity

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

the class ClusterItemDataProviderMockTest method getTestItemResults.

private TestItemResults getTestItemResults(Long index) {
    final TestItemResults testItemResults = new TestItemResults();
    testItemResults.setDuration(0.01);
    testItemResults.setEndTime(LocalDateTime.now(ZoneOffset.UTC));
    testItemResults.setStatus(StatusEnum.FAILED);
    final IssueEntity issueEntity = getIssueEntity(index);
    testItemResults.setIssue(issueEntity);
    final LinkedHashSet<Statistics> statistics = getStatistics();
    testItemResults.setStatistics(statistics);
    return testItemResults;
}
Also used : IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults) Statistics(com.epam.ta.reportportal.entity.statistics.Statistics)

Example 8 with IssueEntity

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

the class FinishTestItemHandlerImpl method processChildItemResult.

private TestItemResults processChildItemResult(TestItem testItem, FinishTestItemRQ finishTestItemRQ, ReportPortalUser user, ReportPortalUser.ProjectDetails projectDetails, Launch launch) {
    TestItemResults testItemResults = testItem.getItemResults();
    StatusEnum actualStatus = fromValue(finishTestItemRQ.getStatus()).orElse(INTERRUPTED);
    Optional<IssueEntity> resolvedIssue = resolveIssue(user, actualStatus, testItem, finishTestItemRQ.getIssue(), projectDetails.getProjectId());
    if (testItemResults.getStatus() == IN_PROGRESS) {
        testItemResults.setStatus(actualStatus);
        resolvedIssue.ifPresent(issue -> updateItemIssue(testItemResults, issue));
        ofNullable(testItem.getRetryOf()).ifPresentOrElse(retryOf -> {
        }, () -> {
            changeStatusHandler.changeParentStatus(testItem, projectDetails.getProjectId(), user);
            changeStatusHandler.changeLaunchStatus(launch);
            if (testItem.isHasRetries()) {
                retryHandler.finishRetries(testItem.getItemId(), JStatusEnum.valueOf(actualStatus.name()), TO_LOCAL_DATE_TIME.apply(finishTestItemRQ.getEndTime()));
            }
        });
    } else {
        updateFinishedItem(testItemResults, actualStatus, resolvedIssue, testItem, user, projectDetails.getProjectId());
    }
    testItem.getAttributes().removeIf(attribute -> ATTRIBUTE_KEY_STATUS.equalsIgnoreCase(attribute.getKey()) && ATTRIBUTE_VALUE_INTERRUPTED.equalsIgnoreCase(attribute.getValue()));
    return testItemResults;
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemResults(com.epam.ta.reportportal.entity.item.TestItemResults)

Example 9 with IssueEntity

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

the class UpdateTestItemHandlerImpl method resetItemsIssue.

@Override
public void resetItemsIssue(List<Long> itemIds, Long projectId, ReportPortalUser user) {
    itemIds.forEach(itemId -> {
        TestItem item = testItemRepository.findById(itemId).orElseThrow(() -> new ReportPortalException(TEST_ITEM_NOT_FOUND, itemId));
        TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(item, projectId);
        IssueType issueType = issueTypeHandler.defineIssueType(projectId, TestItemIssueGroup.TO_INVESTIGATE.getLocator());
        IssueEntity issueEntity = new IssueEntityBuilder(issueEntityRepository.findById(itemId).orElseThrow(() -> new ReportPortalException(ErrorType.ISSUE_TYPE_NOT_FOUND, itemId))).addIssueType(issueType).addAutoAnalyzedFlag(false).get();
        issueEntityRepository.save(issueEntity);
        item.getItemResults().setIssue(issueEntity);
        TestItemActivityResource after = TO_ACTIVITY_RESOURCE.apply(item, projectId);
        if (!StringUtils.equalsIgnoreCase(before.getIssueTypeLongName(), after.getIssueTypeLongName())) {
            ItemIssueTypeDefinedEvent event = new ItemIssueTypeDefinedEvent(before, after, user.getUserId(), user.getUsername());
            messageBus.publishActivity(event);
        }
    });
}
Also used : ItemIssueTypeDefinedEvent(com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IssueEntityBuilder(com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Example 10 with IssueEntity

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

the class UpdateTestItemHandlerImpl method defineTestItemsIssues.

@Override
public List<Issue> defineTestItemsIssues(ReportPortalUser.ProjectDetails projectDetails, DefineIssueRQ defineIssue, ReportPortalUser user) {
    Project project = projectRepository.findById(projectDetails.getProjectId()).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectDetails.getProjectId()));
    List<String> errors = new ArrayList<>();
    List<IssueDefinition> definitions = defineIssue.getIssues();
    expect(CollectionUtils.isEmpty(definitions), equalTo(false)).verify(FAILED_TEST_ITEM_ISSUE_TYPE_DEFINITION);
    List<Issue> updated = new ArrayList<>(defineIssue.getIssues().size());
    List<ItemIssueTypeDefinedEvent> events = new ArrayList<>();
    List<TestItem> itemsForIndexUpdate = new ArrayList<>();
    List<Long> itemsForIndexRemove = new ArrayList<>();
    definitions.forEach(issueDefinition -> {
        try {
            TestItem testItem = testItemRepository.findById(issueDefinition.getId()).orElseThrow(() -> new BusinessRuleViolationException(formattedSupplier("Cannot update issue type for test item '{}', cause it is not found.", issueDefinition.getId()).get()));
            verifyTestItem(testItem, issueDefinition.getId());
            TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(testItem, projectDetails.getProjectId());
            Issue issue = issueDefinition.getIssue();
            IssueType issueType = issueTypeHandler.defineIssueType(projectDetails.getProjectId(), issue.getIssueType());
            IssueEntity issueEntity = new IssueEntityBuilder(testItem.getItemResults().getIssue()).addIssueType(issueType).addDescription(issue.getComment()).addIgnoreFlag(issue.getIgnoreAnalyzer()).addAutoAnalyzedFlag(issue.getAutoAnalyzed()).get();
            externalTicketHandler.updateLinking(user.getUsername(), issueEntity, issueDefinition.getIssue().getExternalSystemIssues());
            testItem.getItemResults().setIssue(issueEntity);
            issueEntity.setTestItemResults(testItem.getItemResults());
            testItemRepository.save(testItem);
            if (ITEM_CAN_BE_INDEXED.test(testItem)) {
                itemsForIndexUpdate.add(testItem);
            } else {
                itemsForIndexRemove.add(testItem.getItemId());
            }
            updated.add(IssueConverter.TO_MODEL.apply(issueEntity));
            TestItemActivityResource after = TO_ACTIVITY_RESOURCE.apply(testItem, projectDetails.getProjectId());
            events.add(new ItemIssueTypeDefinedEvent(before, after, user.getUserId(), user.getUsername()));
        } catch (BusinessRuleViolationException e) {
            errors.add(e.getMessage());
        }
    });
    expect(errors.isEmpty(), equalTo(TRUE)).verify(FAILED_TEST_ITEM_ISSUE_TYPE_DEFINITION, errors.toString());
    logIndexerService.indexDefectsUpdate(project.getId(), AnalyzerUtils.getAnalyzerConfig(project), itemsForIndexUpdate);
    logIndexerService.indexItemsRemoveAsync(project.getId(), itemsForIndexRemove);
    events.forEach(messageBus::publishActivity);
    return updated;
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) ItemIssueTypeDefinedEvent(com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) BusinessRuleViolationException(com.epam.ta.reportportal.commons.validation.BusinessRuleViolationException) IssueEntityBuilder(com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder) IssueDefinition(com.epam.ta.reportportal.ws.model.issue.IssueDefinition) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)24 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)18 TestItem (com.epam.ta.reportportal.entity.item.TestItem)9 TestItemResults (com.epam.ta.reportportal.entity.item.TestItemResults)8 Test (org.junit.jupiter.api.Test)7 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)6 IssueGroup (com.epam.ta.reportportal.entity.item.issue.IssueGroup)6 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)4 Issue (com.epam.ta.reportportal.ws.model.issue.Issue)4 IssueEntityBuilder (com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 ItemIssueTypeDefinedEvent (com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent)2 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)2 Launch (com.epam.ta.reportportal.entity.launch.Launch)2 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 TestItemActivityResource (com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)2 TO_LOCAL_DATE_TIME (com.epam.ta.reportportal.commons.EntityUtils.TO_LOCAL_DATE_TIME)1 Preconditions (com.epam.ta.reportportal.commons.Preconditions)1 Predicates.equalTo (com.epam.ta.reportportal.commons.Predicates.equalTo)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1