Search in sources :

Example 1 with IntegrationRQ

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());
}
Also used : HashMap(java.util.HashMap) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) Test(org.junit.jupiter.api.Test) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest)

Example 2 with IntegrationRQ

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());
}
Also used : Integration(com.epam.ta.reportportal.entity.integration.Integration) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with IntegrationRQ

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());
}
Also used : HashMap(java.util.HashMap) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) Test(org.junit.jupiter.api.Test) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest)

Example 4 with IntegrationRQ

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());
}
Also used : HashMap(java.util.HashMap) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) Test(org.junit.jupiter.api.Test) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest)

Example 5 with IntegrationRQ

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());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS) IntegrationCreatedEvent(com.epam.ta.reportportal.core.events.activity.IntegrationCreatedEvent) Autowired(org.springframework.beans.factory.annotation.Autowired) BooleanUtils(org.apache.commons.lang3.BooleanUtils) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) MessageBus(com.epam.ta.reportportal.core.events.MessageBus) StringUtils(org.apache.commons.lang3.StringUtils) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Service(org.springframework.stereotype.Service) Map(java.util.Map) Qualifier(org.springframework.beans.factory.annotation.Qualifier) TO_ACTIVITY_RESOURCE(com.epam.ta.reportportal.ws.converter.converters.IntegrationConverter.TO_ACTIVITY_RESOURCE) IntegrationRepository(com.epam.ta.reportportal.dao.IntegrationRepository) CreateIntegrationHandler(com.epam.ta.reportportal.core.integration.CreateIntegrationHandler) BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) Optional.ofNullable(java.util.Optional.ofNullable) Integration(com.epam.ta.reportportal.entity.integration.Integration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IntegrationTypeRepository(com.epam.ta.reportportal.dao.IntegrationTypeRepository) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) ProjectRepository(com.epam.ta.reportportal.dao.ProjectRepository) IntegrationUpdatedEvent(com.epam.ta.reportportal.core.events.activity.IntegrationUpdatedEvent) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) IntegrationActivityResource(com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource) IntegrationService(com.epam.ta.reportportal.core.integration.util.IntegrationService) Integration(com.epam.ta.reportportal.entity.integration.Integration) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) IntegrationType(com.epam.ta.reportportal.entity.integration.IntegrationType) IntegrationService(com.epam.ta.reportportal.core.integration.util.IntegrationService)

Aggregations

IntegrationRQ (com.epam.ta.reportportal.ws.model.integration.IntegrationRQ)13 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)10 Test (org.junit.jupiter.api.Test)10 HashMap (java.util.HashMap)9 Integration (com.epam.ta.reportportal.entity.integration.Integration)4 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 BusinessRule (com.epam.ta.reportportal.commons.validation.BusinessRule)2 Suppliers (com.epam.ta.reportportal.commons.validation.Suppliers)2 MessageBus (com.epam.ta.reportportal.core.events.MessageBus)2 IntegrationCreatedEvent (com.epam.ta.reportportal.core.events.activity.IntegrationCreatedEvent)2 IntegrationUpdatedEvent (com.epam.ta.reportportal.core.events.activity.IntegrationUpdatedEvent)2 CreateIntegrationHandler (com.epam.ta.reportportal.core.integration.CreateIntegrationHandler)2 IntegrationService (com.epam.ta.reportportal.core.integration.util.IntegrationService)2 IntegrationRepository (com.epam.ta.reportportal.dao.IntegrationRepository)2 IntegrationTypeRepository (com.epam.ta.reportportal.dao.IntegrationTypeRepository)2 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)2 IntegrationType (com.epam.ta.reportportal.entity.integration.IntegrationType)2 Project (com.epam.ta.reportportal.entity.project.Project)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 TO_ACTIVITY_RESOURCE (com.epam.ta.reportportal.ws.converter.converters.IntegrationConverter.TO_ACTIVITY_RESOURCE)2