use of com.epam.ta.reportportal.entity.project.ProjectIssueType in project service-api by reportportal.
the class UserControllerTest method createUserByAdminPositive.
@Test
void createUserByAdminPositive() throws Exception {
CreateUserRQFull rq = new CreateUserRQFull();
rq.setLogin("testLogin");
rq.setPassword("testPassword");
rq.setFullName("Test User");
rq.setEmail("test@test.com");
rq.setAccountRole("USER");
rq.setProjectRole("MEMBER");
rq.setDefaultProject("default_personal");
MvcResult mvcResult = mockMvc.perform(post("/v1/user").with(token(oAuthHelper.getSuperadminToken())).contentType(APPLICATION_JSON).content(objectMapper.writeValueAsBytes(rq))).andExpect(status().isCreated()).andReturn();
CreateUserRS createUserRS = objectMapper.readValue(mvcResult.getResponse().getContentAsString(), CreateUserRS.class);
assertNotNull(createUserRS.getId());
assertEquals(normalizeId(rq.getLogin()), createUserRS.getLogin());
assertTrue(userRepository.findById(createUserRS.getId()).isPresent());
final Optional<Project> projectOptional = projectRepository.findByName("default_personal");
assertTrue(projectOptional.isPresent());
assertTrue(projectOptional.get().getUsers().stream().anyMatch(config -> config.getUser().getLogin().equals("testlogin")));
Optional<Project> personalProject = projectRepository.findByName("testlogin_personal");
assertTrue(personalProject.isPresent(), "Personal project isn't created");
Project project = personalProject.get();
List<IssueType> defaultIssueTypes = issueTypeRepository.getDefaultIssueTypes();
project.getProjectAttributes().forEach(projectAttribute -> assertTrue(projectAttribute.getValue().equalsIgnoreCase(ProjectAttributeEnum.findByAttributeName(projectAttribute.getAttribute().getName()).get().getDefaultValue())));
assertTrue(defaultIssueTypes.containsAll(project.getProjectIssueTypes().stream().map(ProjectIssueType::getIssueType).collect(Collectors.toList())));
}
use of com.epam.ta.reportportal.entity.project.ProjectIssueType in project service-api by reportportal.
the class UpdateProjectSettingsHandlerImpl method updateProjectIssueSubType.
@Override
public OperationCompletionRS updateProjectIssueSubType(String projectName, ReportPortalUser user, UpdateIssueSubTypeRQ updateIssueSubTypeRQ) {
expect(updateIssueSubTypeRQ.getIds().size() > 0, equalTo(true)).verify(FORBIDDEN_OPERATION, "Please specify at least one item data for update.");
Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
List<IssueTypeActivityResource> issueTypeActivityResources = updateIssueSubTypeRQ.getIds().stream().map(subTypeRQ -> TO_ACTIVITY_RESOURCE.apply(validateAndUpdate(subTypeRQ, project.getProjectIssueTypes().stream().map(ProjectIssueType::getIssueType).collect(Collectors.toList())))).collect(Collectors.toList());
projectRepository.save(project);
issueTypeActivityResources.forEach(it -> messageBus.publishActivity(new DefectTypeUpdatedEvent(it, user.getUserId(), user.getUsername(), project.getId())));
return new OperationCompletionRS("Issue sub-type(s) was updated successfully.");
}
use of com.epam.ta.reportportal.entity.project.ProjectIssueType in project service-api by reportportal.
the class CreateProjectSettingsHandlerImplTest method getSubTypes.
private Set<ProjectIssueType> getSubTypes() {
HashSet<ProjectIssueType> subTypes = new HashSet<>();
for (int i = 1; i < 16; i++) {
IssueType issueType = new IssueType();
issueType.setId((long) i);
issueType.setIssueGroup(new IssueGroup(TestItemIssueGroup.PRODUCT_BUG));
ProjectIssueType projectIssueType = new ProjectIssueType();
projectIssueType.setIssueType(issueType);
subTypes.add(projectIssueType);
}
return subTypes;
}
use of com.epam.ta.reportportal.entity.project.ProjectIssueType in project service-api by reportportal.
the class EmailServiceTest method prepareLaunchTest.
@Test
void prepareLaunchTest() {
when(templateEngine.merge(any(String.class), any(Map.class))).thenReturn("EMAIL MESSAGE");
ProjectIssueType projectIssueType = new ProjectIssueType();
IssueType issueType = new IssueType();
issueType.setLocator("pb001");
issueType.setLongName("ProductBug");
projectIssueType.setIssueType(issueType);
String url = emailService.mergeFinishLaunchText("url", getLaunch(), Sets.newHashSet(projectIssueType));
System.out.println(url);
}
use of com.epam.ta.reportportal.entity.project.ProjectIssueType in project service-api by reportportal.
the class CreateProjectSettingsHandlerImpl method createProjectIssueSubType.
@Override
public IssueSubTypeCreatedRS createProjectIssueSubType(String projectName, ReportPortalUser user, CreateIssueSubTypeRQ rq) {
Project project = projectRepository.findByName(projectName).orElseThrow(() -> new ReportPortalException(PROJECT_NOT_FOUND, projectName));
expect(NOT_ISSUE_FLAG.getValue().equalsIgnoreCase(rq.getTypeRef()), equalTo(false)).verify(INCORRECT_REQUEST, "Impossible to create sub-type for 'Not Issue' type.");
/* Check if global issue type reference is valid */
TestItemIssueGroup expectedGroup = TestItemIssueGroup.fromValue(rq.getTypeRef()).orElseThrow(() -> new ReportPortalException(BAD_REQUEST_ERROR, rq.getTypeRef()));
List<ProjectIssueType> existingSubTypes = project.getProjectIssueTypes().stream().filter(projectIssueType -> projectIssueType.getIssueType().getIssueGroup().getTestItemIssueGroup().equals(expectedGroup)).collect(Collectors.toList());
expect(existingSubTypes.size() < ValidationConstraints.MAX_ISSUE_SUBTYPES, equalTo(true)).verify(INCORRECT_REQUEST, "Sub Issues count is bound of size limit");
String locator = PREFIX.get(expectedGroup.getValue()) + shortUUID();
IssueType subType = new IssueTypeBuilder().addLocator(locator).addIssueGroup(issueGroupRepository.findByTestItemIssueGroup(expectedGroup)).addLongName(rq.getLongName()).addShortName(rq.getShortName()).addHexColor(rq.getColor()).get();
ProjectIssueType projectIssueType = new ProjectIssueType();
projectIssueType.setIssueType(subType);
projectIssueType.setProject(project);
project.getProjectIssueTypes().add(projectIssueType);
issueTypeRepository.save(subType);
projectRepository.save(project);
updateWidgets(project, subType);
messageBus.publishActivity(new DefectTypeCreatedEvent(TO_ACTIVITY_RESOURCE.apply(subType), user.getUserId(), user.getUsername(), project.getId()));
return new IssueSubTypeCreatedRS(subType.getId(), subType.getLocator());
}
Aggregations