Search in sources :

Example 1 with TestItemActivityResource

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;
}
Also used : TicketPostedEvent(com.epam.ta.reportportal.core.events.activity.TicketPostedEvent) GetIntegrationHandler(com.epam.ta.reportportal.core.integration.GetIntegrationHandler) TestItem(com.epam.ta.reportportal.entity.item.TestItem) Autowired(org.springframework.beans.factory.annotation.Autowired) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) Ticket(com.epam.ta.reportportal.ws.model.externalsystem.Ticket) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Service(org.springframework.stereotype.Service) BAD_REQUEST_ERROR(com.epam.ta.reportportal.ws.model.ErrorType.BAD_REQUEST_ERROR) UNABLE_POST_TICKET(com.epam.ta.reportportal.ws.model.ErrorType.UNABLE_POST_TICKET) BtsConstants(com.epam.reportportal.extension.bugtracking.BtsConstants) TestItemRepository(com.epam.ta.reportportal.dao.TestItemRepository) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) PostTicketRQ(com.epam.ta.reportportal.ws.model.externalsystem.PostTicketRQ) Predicates.notNull(com.epam.ta.reportportal.commons.Predicates.notNull) BusinessRule.expect(com.epam.ta.reportportal.commons.validation.BusinessRule.expect) Optional.ofNullable(java.util.Optional.ofNullable) Integration(com.epam.ta.reportportal.entity.integration.Integration) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Collectors(java.util.stream.Collectors) CreateTicketHandler(com.epam.ta.reportportal.core.bts.handler.CreateTicketHandler) PluginBox(com.epam.ta.reportportal.core.plugin.PluginBox) List(java.util.List) BtsExtension(com.epam.reportportal.extension.bugtracking.BtsExtension) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) Collections(java.util.Collections) Ticket(com.epam.ta.reportportal.ws.model.externalsystem.Ticket) Integration(com.epam.ta.reportportal.entity.integration.Integration) BtsExtension(com.epam.reportportal.extension.bugtracking.BtsExtension) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) Collections(java.util.Collections) TicketPostedEvent(com.epam.ta.reportportal.core.events.activity.TicketPostedEvent) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Example 2 with TestItemActivityResource

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);
            }
        }
    });
}
Also used : StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) JStatusEnum(com.epam.ta.reportportal.jooq.enums.JStatusEnum) TestItemStatusChangedEvent(com.epam.ta.reportportal.core.events.activity.TestItemStatusChangedEvent) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)

Example 3 with TestItemActivityResource

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;
}
Also used : TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)

Example 4 with TestItemActivityResource

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;
}
Also used : TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)

Example 5 with TestItemActivityResource

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);
        }
    });
}
Also used : ItemIssueTypeDefinedEvent(com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IssueEntityBuilder(com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) IssueEntity(com.epam.ta.reportportal.entity.item.issue.IssueEntity) TestItemActivityResource(com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource) TestItem(com.epam.ta.reportportal.entity.item.TestItem)

Aggregations

TestItemActivityResource (com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)13 TestItem (com.epam.ta.reportportal.entity.item.TestItem)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)6 StatusEnum (com.epam.ta.reportportal.entity.enums.StatusEnum)4 ItemIssueTypeDefinedEvent (com.epam.ta.reportportal.core.events.activity.ItemIssueTypeDefinedEvent)3 TestItemStatusChangedEvent (com.epam.ta.reportportal.core.events.activity.TestItemStatusChangedEvent)3 StatusChangingStrategy (com.epam.ta.reportportal.core.item.impl.status.StatusChangingStrategy)3 IssueEntity (com.epam.ta.reportportal.entity.item.issue.IssueEntity)3 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)3 IssueEntityBuilder (com.epam.ta.reportportal.ws.converter.builders.IssueEntityBuilder)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)2 BusinessRuleViolationException (com.epam.ta.reportportal.commons.validation.BusinessRuleViolationException)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)2 Project (com.epam.ta.reportportal.entity.project.Project)2 TestItemBuilder (com.epam.ta.reportportal.ws.converter.builders.TestItemBuilder)2 BtsConstants (com.epam.reportportal.extension.bugtracking.BtsConstants)1 BtsExtension (com.epam.reportportal.extension.bugtracking.BtsExtension)1 Predicates (com.epam.ta.reportportal.commons.Predicates)1