Search in sources :

Example 6 with ErrorRS

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

the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void startRootTestItemShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    startTestItemRQ.setName(WHITESPACES_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + ITEM_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startTestItemRQ)).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 : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 7 with ErrorRS

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

the class TestItemControllerValidationTest method shouldReturnBadRequestWhenMoreThan300TicketsToUnlink.

@Test
public void shouldReturnBadRequestWhenMoreThan300TicketsToUnlink() throws Exception {
    // GIVEN
    final UnlinkExternalIssueRQ unlinkExternalIssueRQ = new UnlinkExternalIssueRQ();
    unlinkExternalIssueRQ.setTicketIds(Stream.generate(() -> "id").limit(301).collect(Collectors.toList()));
    unlinkExternalIssueRQ.setTestItemIds(List.of(1L));
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + ITEM_PATH + "/issue/unlink").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(unlinkExternalIssueRQ)).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 'ticketIds' should have size from '0' to '300'.] ", error.getMessage());
}
Also used : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) UnlinkExternalIssueRQ(com.epam.ta.reportportal.ws.model.item.UnlinkExternalIssueRQ) MvcResult(org.springframework.test.web.servlet.MvcResult) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 8 with ErrorRS

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

the class TestItemControllerValidationTest method startChildTestItemShouldReturnErrorWhenNameIsEmpty.

@Test
public void startChildTestItemShouldReturnErrorWhenNameIsEmpty() throws Exception {
    // GIVEN
    StartTestItemRQ startTestItemRQ = prepareTestItem();
    startTestItemRQ.setName(EMPTY);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + ITEM_PATH + PARENT_ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startTestItemRQ)).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 : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) StartTestItemRQ(com.epam.ta.reportportal.ws.model.StartTestItemRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 9 with ErrorRS

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

the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void updateFilterShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    userFilterRQ.setName(WHITESPACES_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + FILTER_PATH + ID_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 10 with ErrorRS

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

the class UserFilterControllerValidationTest method updateFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters.

@Test
public void updateFilterShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
    // GIVEN
    UpdateUserFilterRQ userFilterRQ = prepareFilter();
    userFilterRQ.setName(SHORT_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + FILTER_PATH + ID_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

BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)52 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)52 Test (org.junit.jupiter.api.Test)52 MvcResult (org.springframework.test.web.servlet.MvcResult)52 CreateDashboardRQ (com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ)10 UpdateUserFilterRQ (com.epam.ta.reportportal.ws.model.filter.UpdateUserFilterRQ)10 WidgetRQ (com.epam.ta.reportportal.ws.model.widget.WidgetRQ)10 StartTestItemRQ (com.epam.ta.reportportal.ws.model.StartTestItemRQ)8 MergeLaunchesRQ (com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ)4 StartLaunchRQ (com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ)4 Issue (com.epam.ta.reportportal.ws.model.issue.Issue)3 LinkExternalIssueRQ (com.epam.ta.reportportal.ws.model.item.LinkExternalIssueRQ)2 UnlinkExternalIssueRQ (com.epam.ta.reportportal.ws.model.item.UnlinkExternalIssueRQ)2 BtsExtension (com.epam.reportportal.extension.bugtracking.BtsExtension)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 INCORRECT_REQUEST_MESSAGE (com.epam.ta.reportportal.ws.controller.constants.ValidationTestsConstants.INCORRECT_REQUEST_MESSAGE)1 INCORRECT_REQUEST (com.epam.ta.reportportal.ws.model.ErrorType.INCORRECT_REQUEST)1 com.epam.ta.reportportal.ws.model.externalsystem (com.epam.ta.reportportal.ws.model.externalsystem)1 IntegrationRQ (com.epam.ta.reportportal.ws.model.integration.IntegrationRQ)1 DefineIssueRQ (com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ)1