Search in sources :

Example 16 with ErrorRS

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

the class LaunchControllerValidationTest method createLaunchShouldReturnErrorWhenNameIsGreaterThanTwoHundredAndFiftySixCharacters.

@Test
public void createLaunchShouldReturnErrorWhenNameIsGreaterThanTwoHundredAndFiftySixCharacters() throws Exception {
    // GIVEN
    StartLaunchRQ startLaunchRQ = prepareLaunch();
    startLaunchRQ.setName(LONG_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(startLaunchRQ)).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 : StartLaunchRQ(com.epam.ta.reportportal.ws.model.launch.StartLaunchRQ) 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 17 with ErrorRS

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

the class LaunchControllerValidationTest method mergeLaunchShouldReturnErrorWhenNameConsistsOfWhitespaces.

@Test
public void mergeLaunchShouldReturnErrorWhenNameConsistsOfWhitespaces() throws Exception {
    // GIVEN
    MergeLaunchesRQ mergeLaunchesRQ = prepareLaunchesMerge();
    mergeLaunchesRQ.setName(WHITESPACES_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(post(DEFAULT_PROJECT_BASE_URL + LAUNCH_PATH + MERGE_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(mergeLaunchesRQ)).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 : MergeLaunchesRQ(com.epam.ta.reportportal.ws.model.launch.MergeLaunchesRQ) 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 18 with ErrorRS

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

the class BugTrackingSystemControllerTest method shouldNotCreateIssueWhenMoreThen300BackLinks.

@Test
void shouldNotCreateIssueWhenMoreThen300BackLinks() throws Exception {
    final PostTicketRQ request = new PostTicketRQ();
    final Map<Long, String> backLinks = LongStream.range(1, 302).boxed().collect(Collectors.toMap(it -> it, String::valueOf));
    request.setBackLinks(backLinks);
    final MvcResult mvcResult = mockMvc.perform(post("/v1/bts/superadmin_personal/10/ticket").with(token(oAuthHelper.getSuperadminToken())).contentType(MediaType.APPLICATION_JSON).content(objectMapper.writeValueAsBytes(request))).andExpect(status().isBadRequest()).andReturn();
    ErrorRS error = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), ErrorRS.class);
    assertEquals(INCORRECT_REQUEST, error.getErrorType());
    assertEquals(INCORRECT_REQUEST_MESSAGE + "[Field 'backLinks' should have size from '0' to '300'.] ", error.getMessage());
}
Also used : ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) INCORRECT_REQUEST_MESSAGE(com.epam.ta.reportportal.ws.controller.constants.ValidationTestsConstants.INCORRECT_REQUEST_MESSAGE) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) Disabled(org.junit.jupiter.api.Disabled) Lists(com.google.common.collect.Lists) MockMvcResultMatchers.status(org.springframework.test.web.servlet.result.MockMvcResultMatchers.status) MvcResult(org.springframework.test.web.servlet.MvcResult) Map(java.util.Map) INCORRECT_REQUEST(com.epam.ta.reportportal.ws.model.ErrorType.INCORRECT_REQUEST) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) LongStream(java.util.stream.LongStream) MediaType(org.springframework.http.MediaType) Integration(com.epam.ta.reportportal.entity.integration.Integration) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Mockito.when(org.mockito.Mockito.when) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) com.epam.ta.reportportal.ws.model.externalsystem(com.epam.ta.reportportal.ws.model.externalsystem) Maps(com.google.common.collect.Maps) Sql(org.springframework.test.context.jdbc.Sql) Collectors(java.util.stream.Collectors) MockMvcRequestBuilders(org.springframework.test.web.servlet.request.MockMvcRequestBuilders) Test(org.junit.jupiter.api.Test) List(java.util.List) IntegrationRQ(com.epam.ta.reportportal.ws.model.integration.IntegrationRQ) BtsExtension(com.epam.reportportal.extension.bugtracking.BtsExtension) CollectionUtils(org.springframework.util.CollectionUtils) 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 19 with ErrorRS

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

the class DashboardControllerValidationTest method createDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters.

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

Example 20 with ErrorRS

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

the class DashboardControllerValidationTest method updateDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters.

@Test
public void updateDashboardShouldReturnErrorWhenNameIsLessThanThreeCharacters() throws Exception {
    // GIVEN
    CreateDashboardRQ createDashboardRQ = new CreateDashboardRQ();
    createDashboardRQ.setName(SHORT_NAME_VALUE);
    // WHEN
    MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + DASHBOARD_PATH + ID_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(createDashboardRQ)).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 : ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) CreateDashboardRQ(com.epam.ta.reportportal.ws.model.dashboard.CreateDashboardRQ) 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