Search in sources :

Example 1 with PostTicketRQ

use of com.epam.ta.reportportal.ws.model.externalsystem.PostTicketRQ 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)

Aggregations

BtsConstants (com.epam.reportportal.extension.bugtracking.BtsConstants)1 BtsExtension (com.epam.reportportal.extension.bugtracking.BtsExtension)1 Predicates.notNull (com.epam.ta.reportportal.commons.Predicates.notNull)1 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 BusinessRule.expect (com.epam.ta.reportportal.commons.validation.BusinessRule.expect)1 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)1 CreateTicketHandler (com.epam.ta.reportportal.core.bts.handler.CreateTicketHandler)1 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)1 TicketPostedEvent (com.epam.ta.reportportal.core.events.activity.TicketPostedEvent)1 GetIntegrationHandler (com.epam.ta.reportportal.core.integration.GetIntegrationHandler)1 PluginBox (com.epam.ta.reportportal.core.plugin.PluginBox)1 TestItemRepository (com.epam.ta.reportportal.dao.TestItemRepository)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 TestItem (com.epam.ta.reportportal.entity.item.TestItem)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 TO_ACTIVITY_RESOURCE (com.epam.ta.reportportal.ws.converter.converters.TestItemConverter.TO_ACTIVITY_RESOURCE)1 BAD_REQUEST_ERROR (com.epam.ta.reportportal.ws.model.ErrorType.BAD_REQUEST_ERROR)1 UNABLE_POST_TICKET (com.epam.ta.reportportal.ws.model.ErrorType.UNABLE_POST_TICKET)1 TestItemActivityResource (com.epam.ta.reportportal.ws.model.activity.TestItemActivityResource)1 PostTicketRQ (com.epam.ta.reportportal.ws.model.externalsystem.PostTicketRQ)1