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;
}
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());
}
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.");
}
Aggregations