use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource 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);
}
use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource in project service-api by reportportal.
the class AbstractStatusChangingStrategy method changeParentsStatuses.
protected List<Long> changeParentsStatuses(TestItem testItem, Launch launch, boolean issueRequired, ReportPortalUser user) {
List<Long> updatedParents = Lists.newArrayList();
Long parentId = testItem.getParentId();
while (parentId != null) {
TestItem parent = testItemRepository.findById(parentId).orElseThrow(() -> new ReportPortalException(ErrorType.TEST_ITEM_NOT_FOUND, testItem.getParentId()));
StatusEnum currentParentStatus = parent.getItemResults().getStatus();
if (!StatusEnum.IN_PROGRESS.equals(currentParentStatus)) {
StatusEnum newParentStatus = evaluateParentItemStatus(parent, testItem);
if (!currentParentStatus.equals(newParentStatus)) {
TestItemActivityResource before = TO_ACTIVITY_RESOURCE.apply(parent, launch.getProjectId());
parent.getItemResults().setStatus(newParentStatus);
updateItem(parent, launch.getProjectId(), issueRequired).ifPresent(updatedParents::add);
publishUpdateActivity(before, TO_ACTIVITY_RESOURCE.apply(parent, launch.getProjectId()), user);
} else {
return updatedParents;
}
} else {
return updatedParents;
}
parentId = parent.getParentId();
}
if (launch.getStatus() != IN_PROGRESS) {
launch.setStatus(launchRepository.hasRootItemsWithStatusNotEqual(launch.getId(), StatusEnum.PASSED.name(), INFO.name(), WARN.name()) ? FAILED : PASSED);
}
return updatedParents;
}
use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource in project service-api by reportportal.
the class TestItemConverterTest method toActivityResource.
@Test
void toActivityResource() {
final TestItem item = getItem(true);
final TestItemActivityResource activityResource = TestItemConverter.TO_ACTIVITY_RESOURCE.apply(item, 4L);
assertEquals(activityResource.getId(), item.getItemId());
assertEquals(activityResource.getName(), item.getName());
assertEquals((long) activityResource.getProjectId(), 4L);
assertEquals(activityResource.getIssueDescription(), item.getItemResults().getIssue().getIssueDescription());
assertEquals(activityResource.getIssueTypeLongName(), item.getItemResults().getIssue().getIssueType().getLongName());
assertEquals(activityResource.getStatus(), item.getItemResults().getStatus().name());
assertEquals(activityResource.getTickets(), item.getItemResults().getIssue().getTickets().stream().map(it -> it.getTicketId().concat(":").concat(it.getUrl())).collect(Collectors.joining(", ")));
assertEquals(activityResource.isIgnoreAnalyzer(), item.getItemResults().getIssue().getIgnoreAnalyzer());
assertEquals(activityResource.isAutoAnalyzed(), item.getItemResults().getIssue().getAutoAnalyzed());
}
Aggregations