use of com.synopsys.integration.alert.common.enumeration.DefaultUserRole in project hub-alert by blackducksoftware.
the class UserModelTest method testUserModel.
@Test
public void testUserModel() {
String expectedUserName = "expectedUser";
String expectedPassword = "expectedPassword";
String expectedEmail = "expectedEmail";
Set<String> roleNames = new LinkedHashSet<>(Arrays.asList(DefaultUserRole.values()).stream().map(DefaultUserRole::name).collect(Collectors.toList()));
Set<UserRoleModel> expectedRoles = roleNames.stream().map(UserRoleModel::of).collect(Collectors.toSet());
UserModel userModel = UserModel.newUser(expectedUserName, expectedPassword, expectedEmail, AuthenticationType.DATABASE, expectedRoles, true);
assertEquals(expectedUserName, userModel.getName());
assertEquals(expectedPassword, userModel.getPassword());
assertEquals(expectedEmail, userModel.getEmailAddress());
assertEquals(expectedRoles.size(), userModel.getRoles().size());
assertTrue(userModel.hasRole(DefaultUserRole.ALERT_ADMIN.name()));
assertFalse(userModel.hasRole("UNKNOWN_ROLE"));
assertFalse(userModel.isExpired());
assertFalse(userModel.isLocked());
assertFalse(userModel.isPasswordExpired());
assertTrue(userModel.isEnabled());
assertFalse(userModel.isExternal());
}
Aggregations