use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource in project service-api by reportportal.
the class CreateTicketHandlerImpl method createIssue.
@Override
public Ticket createIssue(PostTicketRQ postTicketRQ, Long integrationId, ReportPortalUser.ProjectDetails projectDetails, ReportPortalUser user) {
validatePostTicketRQ(postTicketRQ);
List<TestItem> testItems = ofNullable(postTicketRQ.getBackLinks()).map(links -> testItemRepository.findAllById(links.keySet())).orElseGet(Collections::emptyList);
List<TestItemActivityResource> before = testItems.stream().map(it -> TO_ACTIVITY_RESOURCE.apply(it, projectDetails.getProjectId())).collect(Collectors.toList());
Integration integration = getIntegrationHandler.getEnabledBtsIntegration(projectDetails, integrationId);
expect(BtsConstants.DEFECT_FORM_FIELDS.getParam(integration.getParams()), notNull()).verify(BAD_REQUEST_ERROR, "There aren't any submitted BTS fields!");
BtsExtension btsExtension = pluginBox.getInstance(integration.getType().getName(), BtsExtension.class).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, Suppliers.formattedSupplier("BugTracking plugin for {} isn't installed", BtsConstants.PROJECT.getParam(integration.getParams())).get()));
Ticket ticket = btsExtension.submitTicket(postTicketRQ, integration);
before.forEach(it -> messageBus.publishActivity(new TicketPostedEvent(ticket, user.getUserId(), user.getUsername(), it)));
return ticket;
}
use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource 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.ws.model.activity.TestItemActivityResource in project service-api by reportportal.
the class ItemIssueTypeDefinedEventTest method getTestItem.
private static TestItemActivityResource getTestItem(String name, String description, boolean ignoreAnalyzer) {
TestItemActivityResource testItem = new TestItemActivityResource();
testItem.setProjectId(3L);
testItem.setStatus("FAILED");
testItem.setIssueTypeLongName(name);
testItem.setIssueDescription(description);
testItem.setIgnoreAnalyzer(ignoreAnalyzer);
testItem.setAutoAnalyzed(false);
testItem.setName("name");
testItem.setId(2L);
testItem.setTickets("1:http:/example.com/ticket/1,2:http:/example.com/ticket/2");
return testItem;
}
use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource in project service-api by reportportal.
the class TestItemStatusChangedEventTest method getTestItem.
private static TestItemActivityResource getTestItem(String status) {
TestItemActivityResource testItem = new TestItemActivityResource();
testItem.setProjectId(3L);
testItem.setStatus(status);
testItem.setIssueTypeLongName("Product Bug");
testItem.setIssueDescription("Description");
testItem.setIgnoreAnalyzer(false);
testItem.setAutoAnalyzed(true);
testItem.setName("name");
testItem.setId(2L);
testItem.setTickets("1:http:/example.com/ticket/1,2:http:/example.com/ticket/2");
return testItem;
}
use of com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource 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);
}
});
}
Aggregations