use of com.epam.ta.reportportal.core.events.activity.TestItemStatusChangedEvent in project service-api by reportportal.
the class ChangeStatusHandlerImpl method changeParentStatus.
@Override
public void changeParentStatus(TestItem childItem, Long projectId, ReportPortalUser user) {
ofNullable(childItem.getParentId()).flatMap(testItemRepository::findById).ifPresent(parent -> {
if (parent.isHasChildren()) {
ofNullable(parent.getItemResults().getIssue()).map(IssueEntity::getIssueId).ifPresent(issueEntityRepository::deleteById);
}
if (isParentStatusUpdateRequired(parent)) {
StatusEnum resolvedStatus = resolveStatus(parent.getItemId());
if (parent.getItemResults().getStatus() != resolvedStatus) {
TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(parent, projectId);
changeStatus(parent, resolvedStatus, user);
messageBus.publishActivity(new TestItemStatusChangedEvent(before, TO_ACTIVITY_RESOURCE.apply(parent, projectId), user.getUserId(), user.getUsername()));
changeParentStatus(parent, projectId, user);
}
}
});
}
use of com.epam.ta.reportportal.core.events.activity.TestItemStatusChangedEvent in project service-api by reportportal.
the class UpdateTestItemHandlerImpl method updateTestItem.
@Override
public OperationCompletionRS updateTestItem(ReportPortalUser.ProjectDetails projectDetails, Long itemId, UpdateTestItemRQ rq, ReportPortalUser user) {
TestItem testItem = testItemRepository.findById(itemId).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, itemId));
validate(projectDetails, user, testItem);
Optional<StatusEnum> providedStatus = StatusEnum.fromValue(rq.getStatus());
if (providedStatus.isPresent() && !providedStatus.get().equals(testItem.getItemResults().getStatus())) {
expect(testItem.isHasChildren() && !testItem.getType().sameLevel(TestItemTypeEnum.STEP), equalTo(FALSE)).verify(INCORRECT_REQUEST, "Unable to change status on test item with children");
checkInitialStatusAttribute(testItem, rq);
StatusChangingStrategy strategy = statusChangingStrategyMapping.get(providedStatus.get());
expect(strategy, notNull()).verify(INCORRECT_REQUEST, formattedSupplier("Actual status: '{}' cannot be changed to '{}'.", testItem.getItemResults().getStatus(), providedStatus.get()));
TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(testItem, projectDetails.getProjectId());
strategy.changeStatus(testItem, providedStatus.get(), user);
messageBus.publishActivity(new TestItemStatusChangedEvent(before, TO_ACTIVITY_RESOURCE.apply(testItem, projectDetails.getProjectId()), user.getUserId(), user.getUsername()));
}
testItem = new TestItemBuilder(testItem).overwriteAttributes(rq.getAttributes()).addDescription(rq.getDescription()).get();
testItemRepository.save(testItem);
return COMPOSE_UPDATE_RESPONSE.apply(itemId);
}
Aggregations