use of com.epam.ta.reportportal.ws.model.filter.Order 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.Order in project service-api by reportportal.
the class UserFilterBuilder method addSelectionParameters.
/**
* Convert provided selection into db and add them in correct order
* to filter object
*
* @param orders Filter sorting conditions
* @return UserFilterBuilder
*/
public UserFilterBuilder addSelectionParameters(List<Order> orders) {
userFilter.getFilterSorts().clear();
ofNullable(orders).ifPresent(o -> o.forEach(order -> {
FilterSort filterSort = new FilterSort();
filterSort.setField(order.getSortingColumnName());
filterSort.setDirection(order.getIsAsc() ? Sort.Direction.ASC : Sort.Direction.DESC);
userFilter.getFilterSorts().add(filterSort);
}));
return this;
}
Aggregations