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