Search in sources :

Example 1 with User

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

the class UserRepositoryTest method searchForUserTestWithNoResults.

@Test
void searchForUserTestWithNoResults() {
    Filter filter = Filter.builder().withTarget(User.class).withCondition(new FilterCondition(Condition.CONTAINS, false, "_ub", CRITERIA_USER)).build();
    Page<User> users = userRepository.findByFilter(filter, PageRequest.of(0, 5));
    assertEquals(0, users.getTotalElements());
}
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) Filter(com.epam.ta.reportportal.commons.querygen.Filter) CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 2 with User

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

the class UserRepositoryTest method findByFilterExcludingProjects.

@Test
void findByFilterExcludingProjects() {
    final CompositeFilterCondition userCondition = new CompositeFilterCondition(List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_USER), new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_FULL_NAME), new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_EMAIL)), Operator.AND);
    Filter filter = Filter.builder().withTarget(User.class).withCondition(userCondition).withCondition(new FilterCondition(Operator.AND, Condition.ANY, true, "superadmin_personal", CRITERIA_PROJECT)).build();
    Page<User> users = userRepository.findByFilterExcludingProjects(filter, PageRequest.of(0, 5));
    assertEquals(3, users.getTotalElements());
}
Also used : CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) User(com.epam.ta.reportportal.entity.user.User) CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Filter(com.epam.ta.reportportal.commons.querygen.Filter) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 3 with User

use of com.epam.ta.reportportal.entity.user.User 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 4 with User

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

the class UserRepositoryTest method searchForUserTest.

@Test
void searchForUserTest() {
    Filter filter = Filter.builder().withTarget(User.class).withCondition(new FilterCondition(Condition.CONTAINS, false, "chuba", CRITERIA_USER)).build();
    Page<User> users = userRepository.findByFilter(filter, PageRequest.of(0, 5));
    assertEquals(2, users.getTotalElements());
}
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) Filter(com.epam.ta.reportportal.commons.querygen.Filter) CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Example 5 with User

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

the class UserRepositoryTest method shouldNotFindByFilterExcludingProjects.

@Test
void shouldNotFindByFilterExcludingProjects() {
    final CompositeFilterCondition userCondition = new CompositeFilterCondition(List.of(new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_USER), new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_FULL_NAME), new FilterCondition(Operator.OR, Condition.CONTAINS, false, "ch", CRITERIA_EMAIL)), Operator.AND);
    Filter filter = Filter.builder().withTarget(User.class).withCondition(userCondition).withCondition(new FilterCondition(Operator.AND, Condition.ANY, true, "millennium_falcon", CRITERIA_PROJECT)).build();
    Page<User> users = userRepository.findByFilterExcludingProjects(filter, PageRequest.of(0, 5));
    assertEquals(1, users.getTotalElements());
}
Also used : CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) ProjectUser(com.epam.ta.reportportal.entity.user.ProjectUser) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) User(com.epam.ta.reportportal.entity.user.User) CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Filter(com.epam.ta.reportportal.commons.querygen.Filter) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

User (com.epam.ta.reportportal.entity.user.User)22 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)14 ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)13 Test (org.junit.jupiter.api.Test)13 BaseTest (com.epam.ta.reportportal.BaseTest)10 Filter (com.epam.ta.reportportal.commons.querygen.Filter)7 Project (com.epam.ta.reportportal.entity.project.Project)7 CompositeFilterCondition (com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition)6 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)6 Transactional (org.springframework.transaction.annotation.Transactional)6 AbstractUserReplicator (com.epam.reportportal.auth.integration.AbstractUserReplicator)4 ContentTypeResolver (com.epam.reportportal.commons.ContentTypeResolver)4 UserBinaryDataService (com.epam.ta.reportportal.binary.UserBinaryDataService)4 ProjectRepository (com.epam.ta.reportportal.dao.ProjectRepository)4 UserRepository (com.epam.ta.reportportal.dao.UserRepository)4 UserRole (com.epam.ta.reportportal.entity.user.UserRole)4 UserType (com.epam.ta.reportportal.entity.user.UserType)4 PersonalProjectService (com.epam.ta.reportportal.util.PersonalProjectService)4 Optional (java.util.Optional)4 Component (org.springframework.stereotype.Component)4