Search in sources :

Example 11 with WidgetRQ

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());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) Widget(com.epam.ta.reportportal.entity.widget.Widget) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 12 with WidgetRQ

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());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) 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 WidgetRQ

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());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) 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 WidgetRQ

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;
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters)

Example 15 with 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());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) 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

WidgetRQ (com.epam.ta.reportportal.ws.model.widget.WidgetRQ)19 Test (org.junit.jupiter.api.Test)16 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)14 MvcResult (org.springframework.test.web.servlet.MvcResult)11 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)10 ContentParameters (com.epam.ta.reportportal.ws.model.widget.ContentParameters)7 Widget (com.epam.ta.reportportal.entity.widget.Widget)6 UserFilter (com.epam.ta.reportportal.entity.filter.UserFilter)3 WidgetBuilder (com.epam.ta.reportportal.ws.converter.builders.WidgetBuilder)3 ShareableObjectsHandler (com.epam.ta.reportportal.auth.acl.ShareableObjectsHandler)2 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 Condition (com.epam.ta.reportportal.commons.querygen.Condition)2 Filter (com.epam.ta.reportportal.commons.querygen.Filter)2 ProjectFilter (com.epam.ta.reportportal.commons.querygen.ProjectFilter)2 EntryCreatedRS (com.epam.ta.reportportal.ws.model.EntryCreatedRS)2 ErrorType (com.epam.ta.reportportal.ws.model.ErrorType)2 List (java.util.List)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Pageable (org.springframework.data.domain.Pageable)2 Service (org.springframework.stereotype.Service)2