use of com.epam.reportportal.extension.bugtracking.BtsExtension 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.reportportal.extension.bugtracking.BtsExtension in project service-api by reportportal.
the class BtsIntegrationService method checkConnection.
@Override
public boolean checkConnection(Integration integration) {
BtsExtension extension = pluginBox.getInstance(integration.getType().getName(), BtsExtension.class).orElseThrow(() -> new ReportPortalException(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, Suppliers.formattedSupplier("Could not find plugin with name '{}'.", integration.getType().getName()).get()));
expect(extension.testConnection(integration), BooleanUtils::isTrue).verify(ErrorType.UNABLE_INTERACT_WITH_INTEGRATION, "Connection refused.");
return true;
}
Aggregations