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