@Test
public void testValidateRoleMemberPrincipalUser() {

    Authority savedAuthority = zms.userAuthority;
    zms.userAuthority = new TestUserPrincipalAuthority();
    zms.validateUserRoleMembers = true;
    // valid users no exception
    zms.validateRoleMemberPrincipal("user.joe", Principal.Type.USER.getValue(), null, null, null, false, "unittest");
    zms.validateRoleMemberPrincipal("user.jane", Principal.Type.USER.getValue(), null, null, null, false, "unittest");
    // invalid user request error
    try {
        zms.validateRoleMemberPrincipal("user.john", Principal.Type.USER.getValue(), null, null, null, false, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.BAD_REQUEST);
    }
    // non - user principals by default are accepted
    zms.validateRoleMemberPrincipal("coretech.api", Principal.Type.SERVICE.getValue(),
            null, null, null, false, "unittest");
    // valid employee and contractor users
    zms.validateRoleMemberPrincipal("user.joe", Principal.Type.USER.getValue(), "employee",
            null, null, false, "unittest");
    zms.validateRoleMemberPrincipal("user.jane", Principal.Type.USER.getValue(), "employee",
            null, null, false, "unittest");
    zms.validateRoleMemberPrincipal("user.jack", Principal.Type.USER.getValue(), "contractor",
            null, null, false, "unittest");
    // valid multiple attribute users
    zms.validateRoleMemberPrincipal("user.joe", Principal.Type.USER.getValue(), "employee,local",
            null, null, false, "unittest");
    zms.validateRoleMemberPrincipal("user.jane", Principal.Type.USER.getValue(), "employee,local",
            null, null, false, "unittest");
    zms.validateRoleMemberPrincipal("user.jack", Principal.Type.USER.getValue(), "contractor,local",
            null, null, false, "unittest");
    // invalid employee type
    try {
        zms.validateRoleMemberPrincipal("user.jack", Principal.Type.USER.getValue(), "employee",
                null, null, false, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.BAD_REQUEST);
    }
    // invalid multiple types
    try {
        zms.validateRoleMemberPrincipal("user.jack", Principal.Type.USER.getValue(), "local,employee",
                null, null, false, "unittest");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), ResourceException.BAD_REQUEST);
    }
    zms.userAuthority = savedAuthority;
}