use of com.epam.ta.reportportal.ws.model.item.ExternalIssueRQ in project service-api by reportportal.
the class UpdateTestItemHandlerImpl method processExternalIssues.
@Override
public List<OperationCompletionRS> processExternalIssues(ExternalIssueRQ request, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
List<String> errors = new ArrayList<>();
List<TestItem> testItems = testItemRepository.findAllById(request.getTestItemIds());
testItems.forEach(testItem -> {
try {
verifyTestItem(testItem, testItem.getItemId());
} catch (Exception e) {
errors.add(e.getMessage());
}
});
expect(errors.isEmpty(), equalTo(TRUE)).verify(FAILED_TEST_ITEM_ISSUE_TYPE_DEFINITION, errors.toString());
List<TestItemActivityResource> before = testItems.stream().map(it -> TO_ACTIVITY_RESOURCE.apply(it, projectDetails.getProjectId())).collect(Collectors.toList());
if (LinkExternalIssueRQ.class.equals(request.getClass())) {
LinkExternalIssueRQ linkRequest = (LinkExternalIssueRQ) request;
externalTicketHandler.linkExternalTickets(user.getUsername(), testItems.stream().map(it -> it.getItemResults().getIssue()).collect(Collectors.toList()), linkRequest.getIssues());
}
if (UnlinkExternalIssueRQ.class.equals(request.getClass())) {
externalTicketHandler.unlinkExternalTickets(testItems, (UnlinkExternalIssueRQ) request);
}
testItemRepository.saveAll(testItems);
List<TestItemActivityResource> after = testItems.stream().map(it -> TO_ACTIVITY_RESOURCE.apply(it, projectDetails.getProjectId())).collect(Collectors.toList());
before.forEach(it -> messageBus.publishActivity(new LinkTicketEvent(it, after.stream().filter(t -> t.getId().equals(it.getId())).findFirst().get(), user.getUserId(), user.getUsername(), ActivityAction.LINK_ISSUE)));
return testItems.stream().map(TestItem::getItemId).map(COMPOSE_UPDATE_RESPONSE).collect(toList());
}
Aggregations