Search in sources :

Example 1 with WidgetRQ

use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.

the class WidgetControllerTest method updateNonExistingWidget.

@Test
void updateNonExistingWidget() throws Exception {
    WidgetRQ rq = new WidgetRQ();
    rq.setName("name");
    rq.setWidgetType("oldLineChart");
    rq.setShare(false);
    var contextParams = new ContentParameters();
    contextParams.setItemsCount(1);
    contextParams.setContentFields(Collections.singletonList("test"));
    rq.setContentParameters(contextParams);
    mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/widget/100").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON)).andExpect(status().isNotFound());
}
Also used : WidgetRQ(com.epam.ta.reportportal.ws.model.widget.WidgetRQ) ContentParameters(com.epam.ta.reportportal.ws.model.widget.ContentParameters) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with WidgetRQ

use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ in project service-api by reportportal.

the class WidgetControllerValidationTest method updateWidgetShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters.

@Test
public void updateWidgetShouldReturnErrorWhenNameIsGreaterThanOneHundredAndTwentyEightCharacters() throws Exception {
    // GIVEN
    WidgetRQ widgetRQ = prepareWidget();
    widgetRQ.setName(LONG_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());
}
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 3 with WidgetRQ

use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ 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());
}
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 4 with WidgetRQ

use of com.epam.ta.reportportal.ws.model.widget.WidgetRQ 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());
}
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 5 with WidgetRQ

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