use of com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ in project service-api by reportportal.
the class TestItemControllerTest method defineTestItemIssue.
@Test
void defineTestItemIssue() throws Exception {
DefineIssueRQ rq = new DefineIssueRQ();
IssueDefinition issueDefinition = new IssueDefinition();
issueDefinition.setId(3L);
Issue issue = new Issue();
issue.setIssueType("pb001");
issue.setIgnoreAnalyzer(false);
issueDefinition.setIssue(issue);
rq.setIssues(Collections.singletonList(issueDefinition));
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/item").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(rq))).andExpect(status().isOk());
}
use of com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ 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.issue.DefineIssueRQ in project service-api by reportportal.
the class UpdateTestItemHandlerImplTest method defineIssuesOnNotExistProject.
@Test
void defineIssuesOnNotExistProject() {
ReportPortalUser rpUser = getRpUser("user", UserRole.USER, ProjectRole.MEMBER, 1L);
when(projectRepository.findById(1L)).thenReturn(Optional.empty());
ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.defineTestItemsIssues(extractProjectDetails(rpUser, "test_project"), new DefineIssueRQ(), rpUser));
assertEquals("Project '1' not found. Did you use correct project name?", exception.getMessage());
}
use of com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ in project service-api by reportportal.
the class TestItemControllerTest method defineTestItemIssueNegative.
@Test
void defineTestItemIssueNegative() throws Exception {
DefineIssueRQ rq = new DefineIssueRQ();
IssueDefinition issueDefinition = new IssueDefinition();
issueDefinition.setId(100L);
Issue issue = new Issue();
issue.setIssueType("pb001");
issue.setIgnoreAnalyzer(false);
issueDefinition.setIssue(issue);
rq.setIssues(Collections.singletonList(issueDefinition));
mockMvc.perform(put(DEFAULT_PROJECT_BASE_URL + "/item").with(token(oAuthHelper.getDefaultToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(rq))).andExpect(status().isBadRequest());
}
Aggregations