use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.
the class UserFilterBuilderTest method userFilterBuilder.
@Test
void userFilterBuilder() {
final UpdateUserFilterRQ request = new UpdateUserFilterRQ();
final String name = "name";
request.setName(name);
final String objectType = "Launch";
request.setObjectType(objectType);
request.setConditions(Sets.newHashSet(new UserFilterCondition("name", "eq", "value")));
final Order order = new Order();
order.setIsAsc(false);
order.setSortingColumnName("column");
request.setOrders(Collections.singletonList(order));
final String description = "description";
request.setDescription(description);
final boolean share = true;
request.setShare(share);
final String owner = "owner";
final Long projectId = 1L;
final UserFilter userFilter = new UserFilterBuilder().addFilterRq(request).addOwner(owner).addProject(projectId).get();
assertEquals(name, userFilter.getName());
assertEquals(description, userFilter.getDescription());
assertEquals(share, userFilter.isShared());
assertEquals(owner, userFilter.getOwner());
assertEquals(projectId, userFilter.getProject().getId());
assertEquals(Launch.class, userFilter.getTargetClass().getClassObject());
assertThat(userFilter.getFilterCondition()).containsExactlyInAnyOrder(FilterCondition.builder().eq("name", "value").build());
final FilterSort filterSort = new FilterSort();
filterSort.setDirection(Sort.Direction.DESC);
filterSort.setField("column");
assertThat(userFilter.getFilterSorts()).containsExactlyInAnyOrder(filterSort);
}
use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.
the class UserFilterBuilder method addFilterConditions.
/**
* Convert provided conditions into db and add them to filter object
*
* @param conditions Conditions from rq
* @return UserFilterBuilder
*/
public UserFilterBuilder addFilterConditions(Set<UserFilterCondition> conditions) {
userFilter.getFilterCondition().clear();
ofNullable(conditions).ifPresent(c -> userFilter.getFilterCondition().addAll(c.stream().map(entity -> FilterCondition.builder().withSearchCriteria(entity.getFilteringField()).withValue(entity.getValue()).withNegative(Condition.isNegative(entity.getCondition())).withCondition(Condition.findByMarker(entity.getCondition()).orElseThrow(() -> new ReportPortalException(ErrorType.INCORRECT_REQUEST, entity.getCondition()))).build()).collect(toList())));
return this;
}
Aggregations