use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class IntegrationControllerTest method updateProjectIntegration.
@Test
void updateProjectIntegration() 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);
doNothing().when(emailService).testConnection();
mockMvc.perform(put("/v1/integration/default_personal/8").with(token(oAuthHelper.getDefaultToken())).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 BugTrackingSystemControllerTest method updateGlobalBtsIntegration.
@Test
@Disabled
void updateGlobalBtsIntegration() 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" + "/9").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 createGlobalIntegrationNegative.
@Test
void createGlobalIntegrationNegative() throws Exception {
IntegrationRQ request = new IntegrationRQ();
request.setName("name");
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/unknown").with(token(oAuthHelper.getSuperadminToken())).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 createProjectIntegration.
@Test
void createProjectIntegration() throws Exception {
IntegrationRQ request = new IntegrationRQ();
request.setName("email");
Map<String, Object> params = new HashMap<>();
params.put("param1", "value");
params.put("param2", "lalala");
request.setIntegrationParams(params);
request.setEnabled(true);
doNothing().when(emailService).testConnection();
mockMvc.perform(post("/v1/integration/default_personal/email").with(token(oAuthHelper.getDefaultToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isCreated());
mockMvc.perform(post("/v1/integration/default_personal/email").with(token(oAuthHelper.getDefaultToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isConflict());
}
use of com.epam.ta.reportportal.ws.model.integration.IntegrationRQ in project service-api by reportportal.
the class CreateIntegrationHandlerImpl method createGlobalIntegration.
@Override
public EntryCreatedRS createGlobalIntegration(IntegrationRQ createRequest, String pluginName, ReportPortalUser user) {
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 -> {
validateGlobalIntegrationName(name, integrationType);
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.setCreator(user.getUsername());
integrationService.checkConnection(integration);
integrationRepository.save(integration);
return new EntryCreatedRS(integration.getId());
}
Aggregations