Search in sources :

Example 11 with UpdateUserFilterRQ

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

Example 12 with UpdateUserFilterRQ

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

the class UserFilterControllerValidationTest method createFilterShouldReturnErrorWhenNameIsEmpty.

@Test
public void createFilterShouldReturnErrorWhenNameIsEmpty() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    userFilterRQ.setName(EMPTY);
    // 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());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 13 with UpdateUserFilterRQ

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

the class UserFilterControllerValidationTest method createFilterShouldReturnErrorWhenNameIsNull.

@Test
public void createFilterShouldReturnErrorWhenNameIsNull() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    // 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_NULL_MESSAGE, error.getMessage());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 14 with UpdateUserFilterRQ

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

the class UserFilterControllerValidationTest method createFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters.

@Test
public void createFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    userFilterRQ.setName(SHORT_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_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 15 with UpdateUserFilterRQ

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

the class UserFilterControllerValidationTest method createFilterShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters.

@Test
public void createFilterShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    userFilterRQ.setName(LONG_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_SIZE_MESSAGE + "] ", error.getMessage());
}
Also used : UpdateUserFilterRQ(com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

UpdateUserFilterRQ (com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ)19 Test (org.junit.jupiter.api.Test)17 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)13 MvcResult (org.springframework.test.web.servlet.MvcResult)11 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)10 Order (com.epam.ta.reportportal.ws.model.filter.Order)6 UserFilterCondition (com.epam.ta.reportportal.ws.model.filter.UserFilterCondition)6 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)3 ActivityEvent (com.epam.ta.reportportal.core.events.ActivityEvent)3 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)3 OperationCompletionRS (com.epam.ta.reportportal.ws.model.OperationCompletionRS)2 FilterSort (com.epam.ta.reportportal.entity.filter.FilterSort)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)1