Search in sources :

Example 1 with INCORRECT_REQUEST_MESSAGE

use of com.epam.ta.reportportal.ws.controller.constants.ValidationTestsConstants.INCORRECT_REQUEST_MESSAGE 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)

Aggregations

BtsExtension (com.epam.reportportal.extension.bugtracking.BtsExtension)1 Integration (com.epam.ta.reportportal.entity.integration.Integration)1 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)1 INCORRECT_REQUEST_MESSAGE (com.epam.ta.reportportal.ws.controller.constants.ValidationTestsConstants.INCORRECT_REQUEST_MESSAGE)1 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)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 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Collectors (java.util.stream.Collectors)1 LongStream (java.util.stream.LongStream)1 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)1 Disabled (org.junit.jupiter.api.Disabled)1 Test (org.junit.jupiter.api.Test)1 ArgumentMatchers.any (org.mockito.ArgumentMatchers.any)1