use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.
the class WidgetControllerTest method updateWidgetPositive.
@Test
void updateWidgetPositive() throws Exception {
final WidgetRQ rq = new WidgetRQ();
rq.setName("updated");
rq.setDescription("updated");
rq.setWidgetType("activityStream");
rq.setShare(false);
final ContentParameters contentParameters = new ContentParameters();
contentParameters.setContentFields(Arrays.asList("number", "start_time", "user"));
contentParameters.setItemsCount(50);
rq.setContentParameters(contentParameters);
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/widget/12").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isOk());
final Optional<Widget> optionalWidget = widgetRepository.findById(12L);
assertTrue(optionalWidget.isPresent());
assertEquals("updated", optionalWidget.get().getName());
assertEquals("updated", optionalWidget.get().getDescription());
}
use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.
the class WidgetControllerValidationTest method updateWidgetShouldReturnErrorWhenNameConsistsOfWhitespaces.
@Test
public void updateWidgetShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(WHITESPACES_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_IS_BLANK_MESSAGE + " " + FIELD_NAME_SIZE_MESSAGE + "] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.
the class WidgetControllerValidationTest method createWidgetShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters.
@Test
public void createWidgetShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(LONG_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.widget.WidgetRQ in project service-api by reportportal.
the class WidgetControllerValidationTest method prepareWidget.
private WidgetRQ prepareWidget() {
WidgetRQ widgetRQ = new WidgetRQ();
widgetRQ.setDescription("description");
widgetRQ.setWidgetType("oldLineChart");
ContentParameters contentParameters = new ContentParameters();
contentParameters.setContentFields(Arrays.asList("number", "name", "user", "statistics$defects$automation_bug$AB002"));
contentParameters.setItemsCount(50);
widgetRQ.setContentParameters(contentParameters);
widgetRQ.setShare(true);
return widgetRQ;
}
use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.
the class WidgetControllerValidationTest method createWidgetShouldReturnErrorWhenNameIsEmpty.
@Test
public void createWidgetShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
WidgetRQ widgetRQ = prepareWidget();
widgetRQ.setName(EMPTY);
// 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());
}
Aggregations