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