Search in sources :

Example 1 with ItemFinishedEvent

use of com.epam.ta.reportportal.core.events.item.ItemFinishedEvent in project service-api by reportportal.

the class FinishTestItemHandlerImpl method updateFinishedItem.

private void updateFinishedItem(TestItemResults testItemResults, StatusEnum actualStatus, Optional<IssueEntity> resolvedIssue, TestItem testItem, ReportPortalUser user, Long projectId) {
    resolvedIssue.ifPresent(issue -> deleteOldIssueIndex(actualStatus, testItem, testItemResults, projectId));
    if (testItemResults.getStatus() != actualStatus) {
        TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(testItem, projectId);
        Optional<StatusChangingStrategy> statusChangingStrategy = ofNullable(statusChangingStrategyMapping.get(actualStatus));
        if (statusChangingStrategy.isPresent()) {
            statusChangingStrategy.get().changeStatus(testItem, actualStatus, user);
        } else {
            testItemResults.setStatus(actualStatus);
        }
        publishUpdateActivity(before, TO_ACTIVITY_RESOURCE.apply(testItem, projectId), user);
    }
    resolvedIssue.ifPresent(issue -> {
        updateItemIssue(testItemResults, issue);
        if (ITEM_CAN_BE_INDEXED.test(testItem)) {
            eventPublisher.publishEvent(new ItemFinishedEvent(testItem.getItemId(), testItem.getLaunchId(), projectId));
        }
    });
}
Also used : ItemFinishedEvent(com.epam.ta.reportportal.core.events.item.ItemFinishedEvent) StatusChangingStrategy(com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)

Aggregations

ItemFinishedEvent (com.epam.ta.reportportal.core.events.item.ItemFinishedEvent)1 StatusChangingStrategy (com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy)1 TestItemActivityResource (com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)1