Search in sources :

Example 11 with UserFilter

use of com.epam.ta.reportportal.entity.filter.UserFilter in project service-api by reportportal.

the class DefaultLaunchFilterProvider method createLaunchFilter.

private static Filter createLaunchFilter(ReportPortalUser.ProjectDetails projectDetails, UserFilter launchFilter) {
    validateLaunchFilterTarget(launchFilter);
    Filter filter = Filter.builder().withTarget(launchFilter.getTargetClass().getClassObject()).withCondition(FilterCondition.builder().eq(CRITERIA_PROJECT_ID, String.valueOf(projectDetails.getProjectId())).build()).withCondition(FilterCondition.builder().withCondition(Condition.NOT_EQUALS).withSearchCriteria(CRITERIA_LAUNCH_STATUS).withValue(StatusEnum.IN_PROGRESS.name()).build()).withCondition(FilterCondition.builder().eq(CRITERIA_LAUNCH_MODE, Mode.DEFAULT.toString()).build()).build();
    filter.getFilterConditions().addAll(launchFilter.getFilterCondition());
    return filter;
}
Also used : UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) Filter(com.epam.ta.reportportal.commons.querygen.Filter)

Example 12 with UserFilter

use of com.epam.ta.reportportal.entity.filter.UserFilter in project service-api by reportportal.

the class DefaultLaunchFilterProvider method createLaunchPageable.

private static Pageable createLaunchPageable(UserFilter launchFilter, int launchesLimit) {
    BusinessRule.expect(launchesLimit, limit -> limit > 0).verify(ErrorType.BAD_REQUEST_ERROR, "Launches limit should be greater than 0");
    Sort sort = ofNullable(launchFilter.getFilterSorts()).map(sorts -> Sort.by(sorts.stream().map(s -> Sort.Order.by(s.getField()).with(s.getDirection())).collect(toList()))).orElseGet(Sort::unsorted);
    return PageRequest.of(0, launchesLimit, sort);
}
Also used : BusinessRule(com.epam.ta.reportportal.commons.validation.BusinessRule) StatusEnum(com.epam.ta.reportportal.entity.enums.StatusEnum) CRITERIA_PROJECT_ID(com.epam.ta.reportportal.commons.querygen.constant.GeneralCriteriaConstant.CRITERIA_PROJECT_ID) ObjectType(com.epam.ta.reportportal.entity.filter.ObjectType) UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) Optional.ofNullable(java.util.Optional.ofNullable) Filter(com.epam.ta.reportportal.commons.querygen.Filter) PageRequest(org.springframework.data.domain.PageRequest) ErrorType(com.epam.ta.reportportal.ws.model.ErrorType) FilterCondition(com.epam.ta.reportportal.commons.querygen.FilterCondition) Collectors.toList(java.util.stream.Collectors.toList) CRITERIA_LAUNCH_STATUS(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_STATUS) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Pair(org.apache.commons.lang3.tuple.Pair) Queryable(com.epam.ta.reportportal.commons.querygen.Queryable) Condition(com.epam.ta.reportportal.commons.querygen.Condition) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) CRITERIA_LAUNCH_MODE(com.epam.ta.reportportal.commons.querygen.constant.LaunchCriteriaConstant.CRITERIA_LAUNCH_MODE) Suppliers(com.epam.ta.reportportal.commons.validation.Suppliers) Mode(com.epam.ta.reportportal.ws.model.launch.Mode) Sort(org.springframework.data.domain.Sort)

Example 13 with UserFilter

use of com.epam.ta.reportportal.entity.filter.UserFilter in project service-api by reportportal.

the class UserFilterControllerTest method updateUserFilterPositive.

@Test
void updateUserFilterPositive() throws Exception {
    UpdateUserFilterRQ updateUserFilterRQ = new UpdateUserFilterRQ();
    updateUserFilterRQ.setName("new name");
    updateUserFilterRQ.setObjectType("Launch");
    updateUserFilterRQ.setDescription("new description");
    updateUserFilterRQ.setShare(true);
    Order order = new Order();
    order.setIsAsc(true);
    order.setSortingColumnName("name");
    updateUserFilterRQ.setOrders(Lists.newArrayList(order));
    updateUserFilterRQ.setConditions(Sets.newHashSet(new UserFilterCondition("name", "eq", "filter")));
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/filter/3").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(updateUserFilterRQ)).contentType(APPLICATION_JSON)).andExpect(status().isOk());
    final Optional<UserFilter> optionalUserFilter = repository.findById(3L);
    assertTrue(optionalUserFilter.isPresent());
    assertEquals("new description", optionalUserFilter.get().getDescription());
    assertEquals("new name", optionalUserFilter.get().getName());
}
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) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 14 with UserFilter

use of com.epam.ta.reportportal.entity.filter.UserFilter 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 15 with UserFilter

use of com.epam.ta.reportportal.entity.filter.UserFilter in project service-api by reportportal.

the class UserPreferenceBuilderTest method userPreferenceBuilder.

@Test
void userPreferenceBuilder() {
    final UserFilter filter = new UserFilter();
    filter.setName("name");
    filter.setOwner("owner");
    final Long projectId = 1L;
    final Long userId = 2L;
    final UserPreference userPreference = new UserPreferenceBuilder().withFilter(filter).withProject(projectId).withUser(userId).get();
    assertThat(userPreference.getFilter()).isEqualToComparingFieldByField(filter);
    assertEquals(projectId, userPreference.getProject().getId());
    assertEquals(userId, userPreference.getUser().getId());
}
Also used : UserFilter(com.epam.ta.reportportal.entity.filter.UserFilter) UserPreference(com.epam.ta.reportportal.entity.preference.UserPreference) Test(org.junit.jupiter.api.Test)

Aggregations

UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)23 Filter (com.epam.ta.reportportal.commons.querygen.Filter)7 Widget (com.epam.ta.reportportal.entity.widget.Widget)7 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)7 Test (org.junit.jupiter.api.Test)7 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)6 FilterSort (com.epam.ta.reportportal.entity.filter.FilterSort)5 ProjectFilter (com.epam.ta.reportportal.commons.querygen.ProjectFilter)4 WidgetBuilder (com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)4 Condition (com.epam.ta.reportportal.commons.querygen.Condition)3 DashboardWidget (com.epam.ta.reportportal.entity.dashboard.DashboardWidget)3 ObjectType (com.epam.ta.reportportal.entity.filter.ObjectType)3 Project (com.epam.ta.reportportal.entity.project.Project)3 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)3 Order (com.epam.ta.reportportal.ws.model.filter.Order)3 UpdateUserFilterRQ (com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ)3 UserFilterCondition (com.epam.ta.reportportal.ws.model.filter.UserFilterCondition)3 WidgetRQ (com.epam.ta.reportportal.ws.model.widget.WidgetRQ)3 List (java.util.List)3