Search in sources :

Example 6 with UserFilterCondition

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);
}
Also used : Order(com.epam.ta.reportportal.ws.model.filter.Order) UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) UserFilterCondition(com.epam.ta.reportportal.ws.model.filter.UserFilterCondition) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) FilterSort(com.epam.ta.reportportal.entity.filter.FilterSort) Test(org.junit.jupiter.api.Test)

Example 7 with UserFilterCondition

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;
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) ObjectType(com.epam.ta.reportportal.entity.filter.ObjectType) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) Optional.ofNullable(java.util.Optional.ofNullable) UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) Order(com.epam.ta.reportportal.ws.model.filter.Order) Set(java.util.Set) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) FilterSort(com.epam.ta.reportportal.entity.filter.FilterSort) Supplier(java.util.function.Supplier) UserFilterCondition(com.epam.ta.reportportal.ws.model.filter.UserFilterCondition) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Sort(org.springframework.data.domain.Sort) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException)

Aggregations

Order (com.epam.ta.reportportal.ws.model.filter.Order)7 UpdateUserFilterRQ (com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ)7 UserFilterCondition (com.epam.ta.reportportal.ws.model.filter.UserFilterCondition)7 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)4 Test (org.junit.jupiter.api.Test)4 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)3 FilterSort (com.epam.ta.reportportal.entity.filter.FilterSort)2 Condition (com.epam.ta.reportportal.commons.querygen.Condition)1 FilterCondition (com.epam.ta.reportportal.commons.querygen.FilterCondition)1 ObjectType (com.epam.ta.reportportal.entity.filter.ObjectType)1 Project (com.epam.ta.reportportal.entity.project.Project)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)1 List (java.util.List)1 Optional.ofNullable (java.util.Optional.ofNullable)1 Set (java.util.Set)1 Supplier (java.util.function.Supplier)1 Collectors.toList (java.util.stream.Collectors.toList)1 Sort (org.springframework.data.domain.Sort)1