Search in sources :

Example 1 with UserFilterCondition

use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.

the class UserFilterControllerTest method createFilterPositive.

@Test
void createFilterPositive() throws Exception {
    String name = "userFilter";
    String description = "description";
    UpdateUserFilterRQ request = new UpdateUserFilterRQ();
    request.setName(name);
    request.setObjectType("Launch");
    final Order order = new Order();
    order.setIsAsc(false);
    order.setSortingColumnName("startTime");
    request.setOrders(Lists.newArrayList(order));
    request.setDescription(description);
    request.setConditions(Sets.newHashSet(new UserFilterCondition("name", "cnt", "test")));
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/filter").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(request)).contentType(APPLICATION_JSON)).andExpect(status().isCreated()).andReturn();
    EntryCreatedRS response = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), new TypeReference<EntryCreatedRS>() {
    });
    final Optional<UserFilter> optionalFilter = repository.findById(response.getId());
    assertTrue(optionalFilter.isPresent());
    assertEquals(name, optionalFilter.get().getName());
    assertEquals(description, optionalFilter.get().getDescription());
}
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) EntryCreatedRS(com.epam.ta.reportportal.ws.model.EntryCreatedRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with UserFilterCondition

use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.

the class UserFilterControllerValidationTest method prepareFilter.

private UpdateUserFilterRQ prepareFilter() {
    UpdateUserFilterRQ userFilterRQ = new UpdateUserFilterRQ();
    userFilterRQ.setObjectType("Launch");
    Order order = new Order();
    order.setIsAsc(false);
    order.setSortingColumnName("startTime");
    userFilterRQ.setOrders(Lists.newArrayList(order));
    userFilterRQ.setDescription("description");
    userFilterRQ.setConditions(Sets.newHashSet(new UserFilterCondition("name", "cnt", "test")));
    return userFilterRQ;
}
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)

Example 3 with UserFilterCondition

use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.

the class UpdateUserFilterHandlerTest method getUpdateRequest.

private UpdateUserFilterRQ getUpdateRequest(String name) {
    UpdateUserFilterRQ updateUserFilterRQ = new UpdateUserFilterRQ();
    updateUserFilterRQ.setName(name);
    updateUserFilterRQ.setObjectType("Launch");
    updateUserFilterRQ.setShare(false);
    Order order = new Order();
    order.setIsAsc(true);
    order.setSortingColumnName(CRITERIA_NAME);
    updateUserFilterRQ.setOrders(Lists.newArrayList(order));
    UserFilterCondition condition = new UserFilterCondition(CRITERIA_NAME, "cnt", "we");
    updateUserFilterRQ.setConditions(Sets.newHashSet(condition));
    return updateUserFilterRQ;
}
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)

Example 4 with UserFilterCondition

use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition in project service-api by reportportal.

the class UserFilterControllerTest method createUserFiltersLongDescription.

@Test
void createUserFiltersLongDescription() throws Exception {
    String name = "userFilter";
    UpdateUserFilterRQ request = new UpdateUserFilterRQ();
    request.setName(name);
    request.setObjectType("Launch");
    final Order order = new Order();
    order.setIsAsc(false);
    order.setSortingColumnName("startTime");
    request.setOrders(Lists.newArrayList(order));
    request.setDescription(StringUtils.leftPad("", 1501, "a"));
    request.setConditions(Sets.newHashSet(new UserFilterCondition("name", "cnt", "test")));
    mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + "/filter").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().is4xxClientError());
}
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) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 5 with UserFilterCondition

use of com.epam.ta.reportportal.ws.model.filter.UserFilterCondition 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)

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