Search in sources :

Example 1 with DefaultUserRole

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());
}
Also used : LinkedHashSet(java.util.LinkedHashSet) UserModel(com.synopsys.integration.alert.common.persistence.model.UserModel) DefaultUserRole(com.synopsys.integration.alert.common.enumeration.DefaultUserRole) UserRoleModel(com.synopsys.integration.alert.common.persistence.model.UserRoleModel) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultUserRole (com.synopsys.integration.alert.common.enumeration.DefaultUserRole)1 UserModel (com.synopsys.integration.alert.common.persistence.model.UserModel)1 UserRoleModel (com.synopsys.integration.alert.common.persistence.model.UserRoleModel)1 LinkedHashSet (java.util.LinkedHashSet)1 Test (org.junit.jupiter.api.Test)1