use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ 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.UpdateUserFilterRQ 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.UpdateUserFilterRQ in project service-api by reportportal.
the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameConsistsOfWhitespaces.
@Test
public void updateFilterShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
userFilterRQ.setName(WHITESPACES_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + FILTER_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(userFilterRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
// THEN
ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
assertEquals(INCORRECT_REQUEST, error.getErrorType());
assertEquals(INCORRECT_REQUEST_MESSAGE + "[" + FIELD_NAME_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters.
@Test
public void updateFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
userFilterRQ.setName(SHORT_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + FILTER_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(userFilterRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
// THEN
ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
assertEquals(INCORRECT_REQUEST, error.getErrorType());
assertEquals(INCORRECT_REQUEST_MESSAGE + "[" + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameIsNull.
@Test
public void updateFilterShouldReturnErrorWhenNameIsNull() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + FILTER_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(userFilterRQ)).contentType(APPLICATION_JSON)).andExpect(status().isBadRequest()).andReturn();
// THEN
ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
assertEquals(INCORRECT_REQUEST, error.getErrorType());
assertEquals(INCORRECT_REQUEST_MESSAGE + FIELD_NAME_IS_NULL_MESSAGE, error.getMessage());
}
Aggregations