use of com.epam.ta.reportportal.commons.querygen.FilterCondition 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.commons.querygen.FilterCondition 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.commons.querygen.FilterCondition 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.commons.querygen.FilterCondition 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());
}
use of com.epam.ta.reportportal.commons.querygen.FilterCondition in project commons-dao by reportportal.
the class UserRepositoryTest method loadUsersByFilterForProject.
@Test
void loadUsersByFilterForProject() {
// given
Filter filter = buildDefaultUserFilter();
filter.withCondition(new FilterCondition(Condition.EQUALS, false, "3", CRITERIA_PROJECT_ID));
// when
List<User> users = userRepository.findByFilterExcluding(filter, PageRequest.of(0, 5), "email").getContent();
// then
assertThat("Users not found", users, Matchers.notNullValue());
assertThat("Incorrect size of founded users", users, Matchers.hasSize(3));
users.forEach(it -> assertNull(it.getEmail()));
}
Aggregations