Search in sources :

Example 1 with ProjectUser

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());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) User(com.epam.ta.reportportal.entity.user.User) Metadata(com.epam.ta.reportportal.entity.Metadata) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 2 with ProjectUser

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;
}
Also used : ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser)

Example 3 with ProjectUser

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

Example 4 with ProjectUser

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;
}
Also used : MapUtils(org.apache.commons.collections4.MapUtils) BeforeEach(org.junit.jupiter.api.BeforeEach) java.util(java.util) SenderCase(com.epam.ta.reportportal.entity.project.email.SenderCase) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) User(com.epam.ta.reportportal.entity.user.User) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) TestItemIssueGroup(com.epam.ta.reportportal.entity.enums.TestItemIssueGroup) ProjectAttributeEnum(com.epam.ta.reportportal.entity.enums.ProjectAttributeEnum) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ProjectType(com.epam.ta.reportportal.entity.enums.ProjectType) Test(org.junit.jupiter.api.Test) Attribute(com.epam.ta.reportportal.entity.attribute.Attribute) Stream(java.util.stream.Stream) IssueGroup(com.epam.ta.reportportal.entity.item.issue.IssueGroup) IssueType(com.epam.ta.reportportal.entity.item.issue.IssueType) Assertions(org.junit.jupiter.api.Assertions) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) User(com.epam.ta.reportportal.entity.user.User)

Example 5 with ProjectUser

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());
}
Also used : ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) 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