use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.
the class UserRepositoryTest method createUserTest.
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Test
void createUserTest() {
User reg = new User();
reg.setEmail("email.com");
reg.setFullName("test");
reg.setLogin("created");
reg.setPassword("new");
reg.setUserType(UserType.INTERNAL);
reg.setRole(UserRole.USER);
Map<String, Object> map = new HashMap<>();
map.put("last_login", new Date());
reg.setMetadata(new Metadata(map));
Project defaultProject = projectRepository.findByName("superadmin_personal").get();
Set<ProjectUser> projectUsers = defaultProject.getUsers();
projectUsers.add(new ProjectUser().withProjectRole(ProjectRole.CUSTOMER).withUser(reg).withProject(defaultProject));
defaultProject.setUsers(projectUsers);
userRepository.save(reg);
final Optional<User> created = userRepository.findByLogin("created");
assertTrue(created.isPresent());
}
use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.
the class ProjectUtilsTest method getTestProject.
private static Project getTestProject() {
Project project = new Project();
project.setId(1L);
project.setName("test_project");
project.setProjectType(ProjectType.PERSONAL);
project.setCreationDate(new Date());
project.setUsers(Sets.newHashSet(new ProjectUser().withUser(getTestUser()).withProject(project).withProjectRole(ProjectRole.PROJECT_MANAGER)));
return project;
}
use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.
the class ProjectUtilsTest method isAssignedNegativeTest.
@Test
void isAssignedNegativeTest() {
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));
assertFalse(ProjectUtils.isAssignedToProject(user, 2L));
}
use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.
the class ProjectUtilsTest method getProjectWithRecipients.
private Project getProjectWithRecipients() {
User firstUser = new User();
firstUser.setLogin(userLoginsToExclude[0]);
firstUser.setEmail(userEmailsToExclude[0]);
User secondUser = new User();
secondUser.setLogin(userLoginsToExclude[1]);
secondUser.setEmail(userEmailsToExclude[1]);
User thirdUser = new User();
thirdUser.setLogin(userLoginsToExclude[2]);
thirdUser.setEmail(userEmailsToExclude[2]);
Set<User> users = Sets.newHashSet(firstUser, secondUser, thirdUser);
Project project = new Project();
Set<ProjectUser> projectUsers = users.stream().map(u -> {
ProjectUser projectUser = new ProjectUser();
projectUser.setUser(u);
projectUser.setProject(project);
return projectUser;
}).collect(Collectors.toSet());
project.setUsers(projectUsers);
return project;
}
use of com.epam.ta.reportportal.entity.user.ProjectUser in project commons-dao by reportportal.
the class ProjectUtilsTest method findUserConfigByLogin.
@Test
void findUserConfigByLogin() {
final ProjectUser projectUser = ProjectUtils.findUserConfigByLogin(project, "test_user");
assertNotNull(projectUser);
assertEquals(getTestUser(), projectUser.getUser());
assertEquals(project, projectUser.getProject());
assertEquals(ProjectRole.PROJECT_MANAGER, projectUser.getProjectRole());
}
Aggregations