use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class LaunchPatternAnalysisStrategyTest method analyzeTest.
@Test
void analyzeTest() {
when(launchRepository.findById(1L)).thenReturn(Optional.of(launch));
when(launch.getProjectId()).thenReturn(1L);
when(launch.getMode()).thenReturn(LaunchModeEnum.DEFAULT);
when(projectRepository.findById(1L)).thenReturn(Optional.of(project));
ProjectAttribute projectAttribute = new ProjectAttribute();
projectAttribute.setValue("true");
Attribute attribute = new Attribute();
projectAttribute.setAttribute(attribute);
when(project.getProjectAttributes()).thenReturn(Sets.newHashSet(projectAttribute));
ReportPortalUser user = getRpUser("user", UserRole.USER, ProjectRole.PROJECT_MANAGER, 1L);
ReportPortalUser.ProjectDetails projectDetails = new ReportPortalUser.ProjectDetails(1L, "name", ProjectRole.PROJECT_MANAGER);
AnalyzeLaunchRQ analyzeLaunchRQ = new AnalyzeLaunchRQ();
analyzeLaunchRQ.setLaunchId(1L);
analyzeLaunchRQ.setAnalyzeItemsModes(Lists.newArrayList("TO_INVESTIGATE"));
analyzeLaunchRQ.setAnalyzerTypeName("patternAnalyzer");
launchPatternAnalysisStrategy.analyze(analyzeLaunchRQ, projectDetails, user);
verify(patternAnalyzer, times(1)).analyzeTestItems(launch, Sets.newHashSet(AnalyzeItemsMode.TO_INVESTIGATE));
}
use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class CreateProjectHandlerImpl method createProject.
@Override
public EntryCreatedRS createProject(CreateProjectRQ createProjectRQ, ReportPortalUser user) {
String projectName = createProjectRQ.getProjectName().toLowerCase().trim();
expect(projectName, not(equalTo(RESERVED_PROJECT_NAME))).verify(ErrorType.INCORRECT_REQUEST, Suppliers.formattedSupplier("Project with name '{}' is reserved by system", projectName));
expect(projectName, com.epam.ta.reportportal.util.Predicates.SPECIAL_CHARS_ONLY.negate()).verify(ErrorType.INCORRECT_REQUEST, Suppliers.formattedSupplier("Project name '{}' consists only of special characters", projectName));
Optional<Project> existProject = projectRepository.findByName(projectName);
expect(existProject, not(isPresent())).verify(ErrorType.PROJECT_ALREADY_EXISTS, projectName);
ProjectType projectType = ProjectType.findByName(createProjectRQ.getEntryType()).orElseThrow(() -> new ReportPortalException(ErrorType.BAD_REQUEST_ERROR, createProjectRQ.getEntryType()));
expect(projectType, equalTo(ProjectType.INTERNAL)).verify(ErrorType.BAD_REQUEST_ERROR, "Only internal projects can be created via API");
User dbUser = userRepository.findRawById(user.getUserId()).orElseThrow(() -> new ReportPortalException(ErrorType.USER_NOT_FOUND, user.getUsername()));
Project project = new Project();
project.setName(projectName);
project.setCreationDate(new Date());
project.setProjectIssueTypes(ProjectUtils.defaultIssueTypes(project, issueTypeRepository.getDefaultIssueTypes()));
Set<ProjectAttribute> projectAttributes = ProjectUtils.defaultProjectAttributes(project, attributeRepository.getDefaultProjectAttributes());
project.setProjectType(projectType);
project.setProjectAttributes(projectAttributes);
ProjectUser projectUser = new ProjectUser().withProject(project).withUser(dbUser).withProjectRole(ProjectRole.PROJECT_MANAGER);
projectRepository.save(project);
projectUserRepository.save(projectUser);
applicationEventPublisher.publishEvent(new ProjectEvent(project.getId(), CREATE_KEY));
return new EntryCreatedRS(project.getId());
}
use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class ProjectControllerTest method updateProjectPositive.
@Test
void updateProjectPositive() throws Exception {
final UpdateProjectRQ rq = new UpdateProjectRQ();
ProjectConfigurationUpdate configuration = new ProjectConfigurationUpdate();
HashMap<String, String> projectAttributes = new HashMap<>();
projectAttributes.put("notifications.enabled", "false");
// 2 weeks in seconds
projectAttributes.put("job.keepLaunches", String.valueOf(3600 * 24 * 14));
// 2 weeks in seconds
projectAttributes.put("job.keepLogs", String.valueOf(3600 * 24 * 14));
// 1 week in seconds
projectAttributes.put("job.interruptJobTime", String.valueOf(3600 * 24 * 7));
// 1 week in seconds
projectAttributes.put("job.keepScreenshots", String.valueOf(3600 * 24 * 7));
projectAttributes.put("analyzer.autoAnalyzerMode", "CURRENT_LAUNCH");
projectAttributes.put("analyzer.minShouldMatch", "5");
projectAttributes.put("analyzer.numberOfLogLines", "5");
projectAttributes.put("analyzer.isAutoAnalyzerEnabled", "false");
configuration.setProjectAttributes(projectAttributes);
rq.setConfiguration(configuration);
HashMap<String, String> userRoles = new HashMap<>();
userRoles.put("test_user", "PROJECT_MANAGER");
rq.setUserRoles(userRoles);
mockMvc.perform(put("/v1/project/test_project").content(objectMapper.writeValueAsBytes(rq)).contentType(APPLICATION_JSON).with(token(oAuthHelper.getSuperadminToken()))).andExpect(status().isOk());
Project project = projectRepository.findByName("test_project").get();
projectAttributes.forEach((key, value) -> {
Optional<ProjectAttribute> pa = project.getProjectAttributes().stream().filter(it -> it.getAttribute().getName().equalsIgnoreCase(key)).findAny();
assertTrue(pa.isPresent());
assertEquals(value, pa.get().getValue());
});
}
use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class InterruptBrokenLaunchesJobTest method noInProgressItemsTest.
@Test
void noInProgressItemsTest() {
String name = "name";
Project project = new Project();
final ProjectAttribute projectAttribute = new ProjectAttribute();
final Attribute attribute = new Attribute();
attribute.setName("job.interruptJobTime");
projectAttribute.setAttribute(attribute);
// 1 day in seconds
projectAttribute.setValue(String.valueOf(3600 * 24));
project.setProjectAttributes(Sets.newHashSet(projectAttribute));
project.setName(name);
long launchId = 1L;
when(projectRepository.findAllIdsAndProjectAttributes(any())).thenReturn(new PageImpl<>(Collections.singletonList(project)));
when(launchRepository.streamIdsWithStatusAndStartTimeBefore(any(), any(), any())).thenReturn(Stream.of(launchId));
when(testItemRepository.hasItemsInStatusByLaunch(launchId, StatusEnum.IN_PROGRESS)).thenReturn(false);
when(launchRepository.findById(launchId)).thenReturn(Optional.of(new Launch()));
interruptBrokenLaunchesJob.execute(null);
verify(launchRepository, times(1)).findById(launchId);
verify(launchRepository, times(1)).save(any());
}
use of com.epam.ta.reportportal.entity.project.ProjectAttribute in project service-api by reportportal.
the class ProjectActivityConverterTest method getProject.
private static Project getProject() {
Project project = new Project();
project.setId(1L);
project.setName("name");
final Attribute attribute = new Attribute();
attribute.setId(2L);
attribute.setName("attr.lol");
final ProjectAttribute projectAttribute = new ProjectAttribute().withProject(project).withValue("value").withAttribute(attribute);
project.setProjectAttributes(Sets.newHashSet(projectAttribute));
return project;
}
Aggregations