use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class ProjectUtilsTest method isAssignedNegativeTest.
@Test
void isAssignedNegativeTest() {
User user = new User();
ProjectUser projectUser = new ProjectUser();
projectUser.setUser(user);
Project project = new Project();
project.setId(1L);
projectUser.setProject(project);
user.setProjects(Sets.newHashSet(projectUser));
assertFalse(ProjectUtils.isAssignedToProject(user, 2L));
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class ProjectUtilsTest method getProjectWithRecipients.
private Project getProjectWithRecipients() {
User firstUser = new User();
firstUser.setLogin(userLoginsToExclude[0]);
firstUser.setEmail(userEmailsToExclude[0]);
User secondUser = new User();
secondUser.setLogin(userLoginsToExclude[1]);
secondUser.setEmail(userEmailsToExclude[1]);
User thirdUser = new User();
thirdUser.setLogin(userLoginsToExclude[2]);
thirdUser.setEmail(userEmailsToExclude[2]);
Set<User> users = Sets.newHashSet(firstUser, secondUser, thirdUser);
Project project = new Project();
Set<ProjectUser> projectUsers = users.stream().map(u -> {
ProjectUser projectUser = new ProjectUser();
projectUser.setUser(u);
projectUser.setProject(project);
return projectUser;
}).collect(Collectors.toSet());
project.setUsers(projectUsers);
return project;
}
use of com.epam.ta.reportportal.entity.user.User in project commons-dao by reportportal.
the class ProjectUtilsTest method getTestUser.
private static User getTestUser() {
User user = new User();
user.setLogin("test_user");
return user;
}
use of com.epam.ta.reportportal.entity.user.User in project service-authorization by reportportal.
the class DetailsContextMapper method mapUserFromContext.
@Override
@Transactional
public UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<? extends GrantedAuthority> authorities) {
UserDetails userDetails = super.mapUserFromContext(ctx, username, authorities);
User user = ldapUserReplicator.replicateUser(userDetails.getUsername(), ctx, attributes.get());
return ReportPortalUser.userBuilder().fromUser(user);
}
use of com.epam.ta.reportportal.entity.user.User in project service-authorization by reportportal.
the class GitHubUserReplicator method replicateUser.
/**
* Replicates GitHub user to internal database (if does NOT exist). Updates if exist. Creates personal project for that user
*
* @param userResource GitHub user to be replicated
* @param gitHubClient Configured github client
* @return Internal User representation
*/
@Transactional
public ReportPortalUser replicateUser(UserResource userResource, GitHubClient gitHubClient) {
String login = normalizeId(userResource.getLogin());
User user = userRepository.findByLogin(login).map(u -> {
if (UserType.GITHUB.equals(u.getUserType())) {
updateUser(u, userResource, gitHubClient);
} else {
// if user with such login exists, but it's not GitHub user than throw an exception
throw new UserSynchronizationException("User with login '" + u.getLogin() + "' already exists");
}
return u;
}).orElseGet(() -> userRepository.save(createUser(userResource, gitHubClient)));
return ReportPortalUser.userBuilder().fromUser(user);
}
Aggregations