use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class WidgetControllerValidationTest method updateWidgetShouldReturnErrorWhenNameIsEmpty.
@Test
public void updateWidgetShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(EMPTY);
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + WIDGET_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(widgetRQ)).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.ErrorRS in project service-api by reportportal.
the class WidgetControllerValidationTest method createWidgetShouldReturnErrorWhenNameIsNull.
@Test
public void createWidgetShouldReturnErrorWhenNameIsNull() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + WIDGET_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(widgetRQ)).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());
}
use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class WidgetControllerValidationTest method createWidgetShouldReturnErrorWhenNameIsLessThanThreeCharacters.
@Test
public void createWidgetShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(SHORT_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + WIDGET_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(widgetRQ)).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.ErrorRS in project service-api by reportportal.
the class WidgetControllerValidationTest method createWidgetShouldReturnErrorWhenNameConsistsOfWhitespaces.
@Test
public void createWidgetShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(WHITESPACES_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + WIDGET_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(widgetRQ)).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.ErrorRS in project service-api by reportportal.
the class WidgetControllerValidationTest method updateWidgetShouldReturnErrorWhenNameIsLessThanThreeCharacters.
@Test
public void updateWidgetShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(SHORT_NAME_VALUE);
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + WIDGET_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(widgetRQ)).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());
}
Aggregations