use of com.epam.ta.reportportal.ws.model.ErrorType.BAD_REQUEST_ERROR 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.ErrorType.BAD_REQUEST_ERROR in project service-api by reportportal.
the class ExecuteIntegrationHandlerImpl method executeCommand.
@Override
public Object executeCommand(ReportPortalUser.ProjectDetails projectDetails, Long integrationId, String command, Map<String, Object> executionParams) {
Integration integration = integrationRepository.findByIdAndProjectId(integrationId, projectDetails.getProjectId()).orElseGet(() -> integrationRepository.findGlobalById(integrationId).orElseThrow(() -> new ReportPortalException(INTEGRATION_NOT_FOUND, integrationId)));
ReportPortalExtensionPoint pluginInstance = pluginBox.getInstance(integration.getType().getName(), ReportPortalExtensionPoint.class).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, formattedSupplier("Plugin for '{}' isn't installed", integration.getType().getName()).get()));
Boolean asyncMode = ofNullable((Boolean) executionParams.get(ASYNC_MODE)).orElse(false);
executionParams.put(PROJECT_ID, projectDetails.getProjectId());
return ofNullable(pluginInstance.getCommandToExecute(command)).map(it -> {
if (asyncMode) {
supplyAsync(() -> it.executeCommand(integration, executionParams));
return new OperationCompletionRS(formattedSupplier("Command '{}' accepted for processing in plugin", command, integration.getType().getName()).get());
}
return it.executeCommand(integration, executionParams);
}).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, formattedSupplier("Command '{}' is not found in plugin {}.", command, integration.getType().getName()).get()));
}
use of com.epam.ta.reportportal.ws.model.ErrorType.BAD_REQUEST_ERROR in project service-api by reportportal.
the class SauceLabsIntegrationService method retrieveCreateParams.
@Override
public Map<String, Object> retrieveCreateParams(String integrationType, Map<String, Object> integrationParams) {
expect(integrationParams, MapUtils::isNotEmpty).verify(BAD_REQUEST_ERROR, "No integration params provided");
final String encryptedToken = encryptor.encrypt(ACCESS_TOKEN.getParameter(integrationParams).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, "Access token value is not specified")));
final String username = USERNAME.getParameter(integrationParams).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, "Username value is not specified"));
HashMap<String, Object> result = Maps.newHashMapWithExpectedSize(integrationParams.size());
result.put(ACCESS_TOKEN.getName(), encryptedToken);
result.put(USERNAME.getName(), username);
integrationParams.entrySet().stream().filter(it -> !it.getKey().equals(ACCESS_TOKEN.getName()) && !it.getKey().equals(USERNAME.getName())).forEach(it -> result.put(it.getKey(), it.getValue()));
return result;
}
Aggregations