Search in sources :

Example 6 with FilterCondition

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

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());
}
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 8 with FilterCondition

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());
}
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 9 with FilterCondition

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());
}
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 10 with FilterCondition

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

Aggregations

BaseTest (com.epam.ta.reportportal.BaseTest)13 Filter (com.epam.ta.reportportal.commons.querygen.Filter)13 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)13 Test (org.junit.jupiter.api.Test)13 CompositeFilterCondition (com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition)8 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)6 ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)6 User (com.epam.ta.reportportal.entity.user.User)6 Launch (com.epam.ta.reportportal.entity.launch.Launch)4 ActivityResource (com.epam.ta.reportportal.ws.model.ActivityResource)4 Sort (org.springframework.data.domain.Sort)4 Condition (com.epam.ta.reportportal.commons.querygen.Condition)3 ConvertibleCondition (com.epam.ta.reportportal.commons.querygen.ConvertibleCondition)3 CRITERIA_ACTION (com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_ACTION)3 CRITERIA_CREATION_DATE (com.epam.ta.reportportal.commons.querygen.constant.ActivityCriteriaConstant.CRITERIA_CREATION_DATE)3 GeneralCriteriaConstant (com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant)3 CRITERIA_COMPOSITE_ATTRIBUTE (com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_COMPOSITE_ATTRIBUTE)3 CRITERIA_ITEM_ATTRIBUTE_KEY (com.epam.ta.reportportal.commons.querygen.constant.ItemAttributeConstant.CRITERIA_ITEM_ATTRIBUTE_KEY)3 CRITERIA_LAUNCH_MODE (com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE)3 CRITERIA_STATUS (com.epam.ta.reportportal.commons.querygen.constant.TestItemCriteriaConstant.CRITERIA_STATUS)3