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