use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class CreateIntegrationHandlerImpl method createProjectIntegration.
@Override
public EntryCreatedRS createProjectIntegration(String projectName, IntegrationRQ createRequest, String pluginName, ReportPortalUser user) {
Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
IntegrationType integrationType = integrationTypeRepository.findByName(pluginName).orElseThrow(() -> new ReportPortalException(ErrorType.INTEGRATION_NOT_FOUND, pluginName));
IntegrationService integrationService = integrationServiceMapping.getOrDefault(integrationType.getName(), this.basicIntegrationService);
String integrationName = ofNullable(createRequest.getName()).map(String::toLowerCase).map(name -> {
validateProjectIntegrationName(name, integrationType, project);
return name;
}).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_INTEGRATION_NAME, "Integration name should be not null"));
createRequest.setName(integrationName);
Integration integration = integrationService.createIntegration(createRequest, integrationType);
integration.setProject(project);
integration.setCreator(user.getUsername());
integrationService.checkConnection(integration);
integrationRepository.save(integration);
messageBus.publishActivity(new IntegrationCreatedEvent(TO_ACTIVITY_RESOURCE.apply(integration), user.getUserId(), user.getUsername()));
return new EntryCreatedRS(integration.getId());
}
use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class BugTrackingSystemControllerTest method getUpdateRQ.
private IntegrationRQ getUpdateRQ() {
IntegrationRQ integrationRQ = new IntegrationRQ();
integrationRQ.setEnabled(true);
integrationRQ.setName("jira1");
Map<String, Object> integrationParams = new HashMap<>();
integrationParams.put("defectFormFields", getPostFormFields());
integrationRQ.setIntegrationParams(integrationParams);
return integrationRQ;
}
use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class BugTrackingSystemControllerTest method updateProjectBtsIntegration.
@Test
@Disabled
void updateProjectBtsIntegration() throws Exception {
when(pluginBox.getInstance("jira", BtsExtension.class)).thenReturn(java.util.Optional.ofNullable(extension));
when(extension.testConnection(any(Integration.class))).thenReturn(true);
IntegrationRQ request = getUpdateRQ();
mockMvc.perform(put("/v1/integration/superadmin_personal/10").with(token(oAuthHelper.getSuperadminToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isOk());
}
use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class IntegrationControllerTest method createProjectIntegrationNegative.
@Test
void createProjectIntegrationNegative() throws Exception {
IntegrationRQ request = new IntegrationRQ();
Map<String, Object> params = new HashMap<>();
params.put("param1", "value");
params.put("param2", "lalala");
request.setIntegrationParams(params);
request.setEnabled(true);
mockMvc.perform(post("/v1/integration/default_personal/unknown").with(token(oAuthHelper.getDefaultToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isNotFound());
}
use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class IntegrationControllerTest method updateProjectIntegrationNegative.
@Test
void updateProjectIntegrationNegative() throws Exception {
IntegrationRQ request = new IntegrationRQ();
Map<String, Object> params = new HashMap<>();
params.put("param1", "value");
params.put("param2", "lalala");
request.setIntegrationParams(params);
request.setEnabled(true);
mockMvc.perform(put("/v1/integration/default_personal/88").with(token(oAuthHelper.getDefaultToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isNotFound());
}
Aggregations