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