Search in sources :

Example 1 with CompositeFilterCondition

use of com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition 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 2 with CompositeFilterCondition

use of com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition 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 3 with CompositeFilterCondition

use of com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition in project commons-dao by reportportal.

the class LogRepositoryTest method findAllWithAttachmentOfRetries.

@Test
void findAllWithAttachmentOfRetries() {
    Filter logWithAttachmentsFilter = Filter.builder().withTarget(Log.class).withCondition(FilterCondition.builder().withCondition(Condition.EXISTS).withSearchCriteria(CRITERIA_LOG_BINARY_CONTENT).withValue("1").build()).withCondition(new CompositeFilterCondition(Lists.newArrayList(FilterCondition.builder().eq(CRITERIA_RETRY_PARENT_LAUNCH_ID, String.valueOf(1L)).build(), FilterCondition.builder().eq(CRITERIA_ITEM_LAUNCH_ID, String.valueOf(1L)).withOperator(Operator.OR).build()))).build();
    Page<Log> logPage = logRepository.findByFilter(logWithAttachmentsFilter, PageRequest.of(0, 10));
    List<Log> logs = logPage.getContent();
    assertFalse(logs.isEmpty());
    logs.forEach(log -> {
        Attachment attachment = log.getAttachment();
        assertNotNull(attachment);
        assertNotNull(attachment.getId());
        assertNotNull(attachment.getFileId());
        assertNotNull(attachment.getContentType());
        assertNotNull(attachment.getThumbnailId());
    });
    assertEquals(7, logs.size());
}
Also used : CompositeFilterCondition(com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition) Filter(com.epam.ta.reportportal.commons.querygen.Filter) Log(com.epam.ta.reportportal.entity.log.Log) IndexLog(com.epam.ta.reportportal.ws.model.analyzer.IndexLog) Attachment(com.epam.ta.reportportal.entity.attachment.Attachment) BaseTest(com.epam.ta.reportportal.BaseTest) Test(org.junit.jupiter.api.Test)

Aggregations

BaseTest (com.epam.ta.reportportal.BaseTest)3 CompositeFilterCondition (com.epam.ta.reportportal.commons.querygen.CompositeFilterCondition)3 Filter (com.epam.ta.reportportal.commons.querygen.Filter)3 Test (org.junit.jupiter.api.Test)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)2 ProjectUser (com.epam.ta.reportportal.entity.user.ProjectUser)2 User (com.epam.ta.reportportal.entity.user.User)2 Attachment (com.epam.ta.reportportal.entity.attachment.Attachment)1 Log (com.epam.ta.reportportal.entity.log.Log)1 IndexLog (com.epam.ta.reportportal.ws.model.analyzer.IndexLog)1