Search in sources :

Example 1 with ProjectAttributesActivityResource

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

the class ProjectConfigEventTest method getProjectAttributes.

private static ProjectAttributesActivityResource getProjectAttributes(Map<String, String> config) {
    ProjectAttributesActivityResource resource = new ProjectAttributesActivityResource();
    resource.setProjectName("test_project");
    resource.setProjectId(3L);
    resource.setConfig(config);
    return resource;
}
Also used : ProjectAttributesActivityResource(com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource)

Example 2 with ProjectAttributesActivityResource

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

the class ProjectActivityConverterTest method toActivityResource.

@Test
void toActivityResource() {
    final Project project = getProject();
    final ProjectAttributesActivityResource resource = ProjectActivityConverter.TO_ACTIVITY_RESOURCE.apply(project);
    assertEquals(resource.getProjectId(), project.getId());
    assertEquals(resource.getProjectName(), project.getName());
    assertThat(resource.getConfig()).containsOnlyKeys("attr.lol");
    assertThat(resource.getConfig()).containsValue("value");
}
Also used : ProjectAttributesActivityResource(com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource) Project(com.epam.ta.reportportal.entity.project.Project) Test(org.junit.jupiter.api.Test)

Example 3 with ProjectAttributesActivityResource

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

the class UpdateProjectHandlerImpl method updateProject.

@Override
public OperationCompletionRS updateProject(String projectName, UpdateProjectRQ updateProjectRQ, ReportPortalUser user) {
    Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(ErrorType.PROJECT_NOT_FOUND, projectName));
    ProjectAttributesActivityResource before = TO_ACTIVITY_RESOURCE.apply(project);
    updateProjectConfiguration(updateProjectRQ.getConfiguration(), project);
    ofNullable(updateProjectRQ.getUserRoles()).ifPresent(roles -> updateProjectUserRoles(roles, project, user));
    projectRepository.save(project);
    ProjectAttributesActivityResource after = TO_ACTIVITY_RESOURCE.apply(project);
    applicationEventPublisher.publishEvent(new ProjectEvent(project.getId(), UPDATE_EVENT));
    messageBus.publishActivity(new ProjectUpdatedEvent(before, after, user.getUserId(), user.getUsername()));
    messageBus.publishActivity(new ProjectAnalyzerConfigEvent(before, after, user.getUserId(), user.getUsername()));
    return new OperationCompletionRS("Project with name = '" + project.getName() + "' is successfully updated.");
}
Also used : ProjectAttributesActivityResource(com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource) Project(com.epam.ta.reportportal.entity.project.Project) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ProjectAnalyzerConfigEvent(com.epam.ta.reportportal.core.events.activity.ProjectAnalyzerConfigEvent) ProjectUpdatedEvent(com.epam.ta.reportportal.core.events.activity.ProjectUpdatedEvent) ProjectEvent(com.epam.reportportal.extension.event.ProjectEvent) OperationCompletionRS(com.epam.ta.reportportal.ws.model.OperationCompletionRS)

Aggregations

ProjectAttributesActivityResource (com.epam.ta.reportportal.ws.model.activity.ProjectAttributesActivityResource)3 Project (com.epam.ta.reportportal.entity.project.Project)2 ProjectEvent (com.epam.reportportal.extension.event.ProjectEvent)1 ProjectAnalyzerConfigEvent (com.epam.ta.reportportal.core.events.activity.ProjectAnalyzerConfigEvent)1 ProjectUpdatedEvent (com.epam.ta.reportportal.core.events.activity.ProjectUpdatedEvent)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