use of com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ in project service-api by reportportal.
the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters.
@Test
public void updateFilterShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
userFilterRQ.setName(LONG_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 createFilterShouldReturnErrorWhenNameConsistsOfWhitespaces.
@Test
public void createFilterShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
userFilterRQ.setName(WHITESPACES_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + FILTER_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 updateFilterShouldReturnErrorWhenNameIsEmpty.
@Test
public void updateFilterShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
UpdateUserFilterRQ userFilterRQ = prepareFilter();
userFilterRQ.setName(EMPTY);
// 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 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);
}
Aggregations