Search in sources :

Example 1 with IntegrationActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource in project service-api by reportportal.

the class IntegrationEventsTest method getIntegration.

private static IntegrationActivityResource getIntegration() {
    IntegrationActivityResource integration = new IntegrationActivityResource();
    integration.setId(2L);
    integration.setName("name");
    integration.setProjectId(3L);
    integration.setTypeName("type");
    integration.setProjectName("test_project");
    return integration;
}
Also used : IntegrationActivityResource(com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource)

Example 2 with IntegrationActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource in project service-api by reportportal.

the class IntegrationConverterTest method toActivityResource.

@Test
void toActivityResource() {
    final Integration integration = getIntegration();
    final IntegrationActivityResource resource = IntegrationConverter.TO_ACTIVITY_RESOURCE.apply(integration);
    assertEquals(resource.getId(), integration.getId());
    assertEquals(resource.getProjectId(), integration.getProject().getId());
    assertEquals(resource.getProjectName(), integration.getProject().getName());
    assertEquals(resource.getTypeName(), integration.getType().getName());
}
Also used : Integration(com.epam.ta.reportportal.entity.integration.Integration) IntegrationActivityResource(com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource) Test(org.junit.jupiter.api.Test)

Example 3 with IntegrationActivityResource

use of com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource in project service-api by reportportal.

the class CreateIntegrationHandlerImpl method updateProjectIntegration.

@Override
public OperationCompletionRS updateProjectIntegration(Long id, String projectName, IntegrationRQ updateRequest, ReportPortalUser user) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    final Integration integration = integrationRepository.findByIdAndProjectId(id, project.getId()).orElseThrow(() -> new ReportPortalException(ErrorType.INTEGRATION_NOT_FOUND, id));
    IntegrationActivityResource beforeUpdate = TO_ACTIVITY_RESOURCE.apply(integration);
    ofNullable(updateRequest.getName()).map(String::toLowerCase).ifPresent(name -> {
        if (!name.equals(integration.getName())) {
            validateProjectIntegrationName(name, integration.getType(), project);
            updateRequest.setName(name);
        }
    });
    IntegrationService integrationService = integrationServiceMapping.getOrDefault(integration.getType().getName(), this.basicIntegrationService);
    Integration updatedIntegration = integrationService.updateIntegration(integration, updateRequest);
    updatedIntegration.setProject(project);
    integrationService.checkConnection(integration);
    integrationRepository.save(updatedIntegration);
    messageBus.publishActivity(new IntegrationUpdatedEvent(user.getUserId(), user.getUsername(), beforeUpdate, TO_ACTIVITY_RESOURCE.apply(updatedIntegration)));
    return new OperationCompletionRS("Integration with id = " + updatedIntegration.getId() + " has been successfully updated.");
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) Integration(com.epam.ta.reportportal.entity.integration.Integration) IntegrationUpdatedEvent(com.epam.ta.reportportal.core.events.activity.IntegrationUpdatedEvent) IntegrationActivityResource(com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) IntegrationService(com.epam.ta.reportportal.core.integration.util.IntegrationService) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

IntegrationActivityResource (com.epam.ta.reportportal.ws.model.activity.IntegrationActivityResource)3 Integration (com.epam.ta.reportportal.entity.integration.Integration)2 IntegrationUpdatedEvent (com.epam.ta.reportportal.core.events.activity.IntegrationUpdatedEvent)1 IntegrationService (com.epam.ta.reportportal.core.integration.util.IntegrationService)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)1 Test (org.junit.jupiter.api.Test)1