Search in sources :

Example 1 with DefineIssueRQ

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());
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) IssueDefinition(com.epam.ta.reportportal.ws.model.issue.IssueDefinition) DefineIssueRQ(com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with DefineIssueRQ

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());
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) IssueDefinition(com.epam.ta.reportportal.ws.model.issue.IssueDefinition) ErrorRS(com.epam.ta.reportportal.ws.model.ErrorRS) MvcResult(org.springframework.test.web.servlet.MvcResult) DefineIssueRQ(com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with DefineIssueRQ

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());
}
Also used : ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) DefineIssueRQ(com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ) Test(org.junit.jupiter.api.Test)

Example 4 with DefineIssueRQ

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());
}
Also used : Issue(com.epam.ta.reportportal.ws.model.issue.Issue) IssueDefinition(com.epam.ta.reportportal.ws.model.issue.IssueDefinition) DefineIssueRQ(com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Aggregations

DefineIssueRQ (com.epam.ta.reportportal.ws.model.issue.DefineIssueRQ)4 Test (org.junit.jupiter.api.Test)4 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)3 Issue (com.epam.ta.reportportal.ws.model.issue.Issue)3 IssueDefinition (com.epam.ta.reportportal.ws.model.issue.IssueDefinition)3 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)1 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)1 ErrorRS (com.epam.ta.reportportal.ws.model.ErrorRS)1 MvcResult (org.springframework.test.web.servlet.MvcResult)1