Search in sources :

Example 6 with ProjectUser

use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.

the class PersonalProjectService method generatePersonalProject.

/**
 * Generates personal project for provided user
 *
 * @param user User project should be created for
 * @return Built Project object
 */
public Project generatePersonalProject(User user) {
    Project project = new Project();
    project.setName(generatePersonalProjectName(user.getLogin()));
    project.setCreationDate(Date.from(ZonedDateTime.now().toInstant()));
    project.setProjectType(ProjectType.PERSONAL);
    ProjectUser projectUser = new ProjectUser().withUser(user).withProjectRole(ProjectRole.PROJECT_MANAGER).withProject(project);
    project.setUsers(Sets.newHashSet(projectUser));
    project.setMetadata(new Metadata(Collections.singletonMap("additional_info", "Personal project of " + (isNullOrEmpty(user.getFullName()) ? user.getLogin() : user.getFullName()))));
    project.setProjectAttributes(defaultProjectAttributes(project, attributeRepository.getDefaultProjectAttributes()));
    project.setProjectIssueTypes(defaultIssueTypes(project, issueTypeRepository.getDefaultIssueTypes()));
    return project;
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) Metadata(com.epam.ta.reportportal.entity.Metadata)

Example 7 with ProjectUser

use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.

the class UserRepositoryTest method findAllMembersByProjectManagerRole.

@Test
void findAllMembersByProjectManagerRole() {
    List<String> emails = userRepository.findEmailsByProjectAndRole(1L, ProjectRole.PROJECT_MANAGER);
    assertFalse(emails.isEmpty());
    emails.forEach(e -> {
        User user = userRepository.findByEmail(e).get();
        assertEquals(ProjectRole.PROJECT_MANAGER, user.getProjects().stream().filter(it -> it.getId().getProjectId().equals(1L)).map(ProjectUser::getProjectRole).findFirst().get());
    });
}
Also used : ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) User(com.epam.ta.reportportal.entity.user.User) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 8 with ProjectUser

use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.

the class ProjectUtilsTest method isAssignedPositiveTest.

@Test
void isAssignedPositiveTest() {
    User user = new User();
    ProjectUser projectUser = new ProjectUser();
    projectUser.setUser(user);
    Project project = new Project();
    project.setId(1L);
    projectUser.setProject(project);
    user.setProjects(Sets.newHashSet(projectUser));
    assertTrue(ProjectUtils.isAssignedToProject(user, 1L));
}
Also used : ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) User(com.epam.ta.reportportal.entity.user.User) Test(org.junit.jupiter.api.Test)

Aggregations

ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)8 Test (org.junit.jupiter.api.Test)6 User (com.epam.ta.reportportal.entity.user.User)5 BaseTest (com.epam.ta.reportportal.BaseTest)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 Metadata (com.epam.ta.reportportal.entity.Metadata)2 Project (com.epam.ta.reportportal.entity.project.Project)2 Attribute (com.epam.ta.reportportal.entity.attribute.Attribute)1 ProjectAttributeEnum (com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum)1 ProjectType (com.epam.ta.reportportal.entity.enums.ProjectType)1 TestItemIssueGroup (com.epam.ta.reportportal.entity.enums.TestItemIssueGroup)1 IssueGroup (com.epam.ta.reportportal.entity.item.issue.IssueGroup)1 IssueType (com.epam.ta.reportportal.entity.item.issue.IssueType)1 SenderCase (com.epam.ta.reportportal.entity.project.email.SenderCase)1 Sets (com.google.common.collect.Sets)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Stream (java.util.stream.Stream)1 MapUtils (org.apache.commons.collections4.MapUtils)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1