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());
}
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());
}
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());
}
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());
}
Aggregations