use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class TestItemControllerValidationTest method startChildTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters.
@Test
public void startChildTestItemShouldReturnErrorWhenNameIsGreaterThanOneThousandTwentyFourCharacters() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(LONG_NAME_VALUE);
// 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_SIZE_MESSAGE + "] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class TestItemControllerValidationTest method shouldReturnBadRequestWhenMoreThan300Issues.
@Test
public void shouldReturnBadRequestWhenMoreThan300Issues() throws Exception {
// GIVEN
final DefineIssueRQ defineIssueRQ = new DefineIssueRQ();
defineIssueRQ.setIssues(Stream.generate(() -> {
final IssueDefinition issueDefinition = new IssueDefinition();
issueDefinition.setId(1L);
final Issue issue = new Issue();
issue.setComment("comment");
issue.setIssueType("ab001");
issueDefinition.setIssue(issue);
return issueDefinition;
}).limit(301).collect(Collectors.toList()));
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + ITEM_PATH).with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(defineIssueRQ)).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 'issues' should have size from '0' to '300'.] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class TestItemControllerValidationTest method shouldReturnBadRequestWhenMoreThan300ItemIdsToUnlink.
@Test
public void shouldReturnBadRequestWhenMoreThan300ItemIdsToUnlink() throws Exception {
// GIVEN
final UnlinkExternalIssueRQ unlinkExternalIssueRQ = new UnlinkExternalIssueRQ();
unlinkExternalIssueRQ.setTicketIds(List.of("id"));
unlinkExternalIssueRQ.setTestItemIds(Stream.generate(() -> 1L).limit(301).collect(Collectors.toList()));
// 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 'testItemIds' should have size from '0' to '300'.] ", error.getMessage());
}
use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class TestItemControllerValidationTest method startRootTestItemShouldReturnErrorWhenNameIsEmpty.
@Test
public void startRootTestItemShouldReturnErrorWhenNameIsEmpty() throws Exception {
// GIVEN
StartTestItemRQ startTestItemRQ = prepareTestItem();
startTestItemRQ.setName(EMPTY);
// 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());
}
use of com.epam.ta.reportportal.ws.model.ErrorRS in project service-api by reportportal.
the class TestItemControllerValidationTest method shouldReturnBadRequestWhenMoreThan300IssuesToLink.
@Test
public void shouldReturnBadRequestWhenMoreThan300IssuesToLink() throws Exception {
// GIVEN
final LinkExternalIssueRQ linkExternalIssueRQ = new LinkExternalIssueRQ();
final Issue.ExternalSystemIssue externalSystemIssue = getExternalSystemIssue();
linkExternalIssueRQ.setIssues(Stream.generate(() -> externalSystemIssue).limit(301).collect(Collectors.toList()));
linkExternalIssueRQ.setTestItemIds(List.of(1L));
// WHEN
MvcResult mvcResult = mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + ITEM_PATH + "/issue/link").with(token(oAuthHelper.getDefaultToken())).content(objectMapper.writeValueAsBytes(linkExternalIssueRQ)).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 'issues' should have size from '0' to '300'.] ", error.getMessage());
}
Aggregations