Search in sources :

Example 1 with CreateProjectRQ

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

the class ProjectControllerTest method createProjectPositive.

@Test
void createProjectPositive() throws Exception {
    CreateProjectRQ rq = new CreateProjectRQ();
    rq.setProjectName("TestProject");
    rq.setEntryType("INTERNAL");
    mockMvc.perform(post("/v1/project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isCreated());
    final Optional<Project> createdProjectOptional = projectRepository.findByName("TestProject".toLowerCase());
    assertTrue(createdProjectOptional.isPresent());
    assertEquals(11, createdProjectOptional.get().getProjectAttributes().size());
    assertEquals(5, createdProjectOptional.get().getProjectIssueTypes().size());
}
Also used : Project(com.epam.ta.reportportal.entity.project.Project) CreateProjectRQ(com.epam.ta.reportportal.ws.model.project.CreateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 2 with CreateProjectRQ

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

the class ProjectControllerTest method createProjectWithReservedName.

@Test
void createProjectWithReservedName() throws Exception {
    CreateProjectRQ rq = new CreateProjectRQ();
    rq.setProjectName("project");
    rq.setEntryType("INTERNAL");
    mockMvc.perform(post("/v1/project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isBadRequest());
}
Also used : CreateProjectRQ(com.epam.ta.reportportal.ws.model.project.CreateProjectRQ) BaseMvcTest(com.epam.ta.reportportal.ws.BaseMvcTest) Test(org.junit.jupiter.api.Test)

Example 3 with CreateProjectRQ

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

the class CreateProjectHandlerImplTest method createProjectWithWrongType.

@Test
void createProjectWithWrongType() {
    ReportPortalUser rpUser = getRpUser("user", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    CreateProjectRQ createProjectRQ = new CreateProjectRQ();
    String projectName = "projectName";
    createProjectRQ.setProjectName(projectName);
    createProjectRQ.setEntryType("wrongType");
    when(projectRepository.findByName(projectName.toLowerCase().trim())).thenReturn(Optional.empty());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.createProject(createProjectRQ, rpUser));
    assertEquals("Error in handled Request. Please, check specified parameters: 'wrongType'", exception.getMessage());
}
Also used : CreateProjectRQ(com.epam.ta.reportportal.ws.model.project.CreateProjectRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Example 4 with CreateProjectRQ

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

the class CreateProjectHandlerImplTest method createProjectByNotExistUser.

@Test
void createProjectByNotExistUser() {
    ReportPortalUser rpUser = getRpUser("user", UserRole.ADMINISTRATOR, ProjectRole.PROJECT_MANAGER, 1L);
    CreateProjectRQ createProjectRQ = new CreateProjectRQ();
    String projectName = "projectName";
    createProjectRQ.setProjectName(projectName);
    createProjectRQ.setEntryType("internal");
    when(projectRepository.findByName(projectName.toLowerCase().trim())).thenReturn(Optional.empty());
    when(userRepository.findRawById(rpUser.getUserId())).thenReturn(Optional.empty());
    ReportPortalException exception = assertThrows(ReportPortalException.class, () -> handler.createProject(createProjectRQ, rpUser));
    assertEquals("User 'user' not found.", exception.getMessage());
}
Also used : CreateProjectRQ(com.epam.ta.reportportal.ws.model.project.CreateProjectRQ) ReportPortalException(com.epam.ta.reportportal.exception.ReportPortalException) ReportPortalUser(com.epam.ta.reportportal.commons.ReportPortalUser) Test(org.junit.jupiter.api.Test)

Aggregations

CreateProjectRQ (com.epam.ta.reportportal.ws.model.project.CreateProjectRQ)4 Test (org.junit.jupiter.api.Test)4 ReportPortalUser (com.epam.ta.reportportal.commons.ReportPortalUser)2 ReportPortalException (com.epam.ta.reportportal.exception.ReportPortalException)2 BaseMvcTest (com.epam.ta.reportportal.ws.BaseMvcTest)2 Project (com.epam.ta.reportportal.entity.project.Project)1