@Test
public void testValidateRoleUserAuthorityAttributes() {

    Authority savedAuthority = zms.userAuthority;
    zms.userAuthority = null;
    // with authority null we always get exceptions if we have
    // not empty values specified
    zms.validateUserAuthorityAttributes(null, null, "unit-test");
    zms.validateUserAuthorityAttributes(null, "", "unit-test");
    zms.validateUserAuthorityAttributes("", null, "unit-test");
    zms.validateUserAuthorityAttributes("", "", "unit-test");
    try {
        zms.validateUserAuthorityAttributes("attr1", null, "unit-test");
        fail();
    } catch (ResourceException ex) {
        assertTrue(ex.getMessage().contains("User Authority filter specified without a valid user authority"));
    }
    try {
        zms.validateUserAuthorityAttributes(null, "attr1", "unit-test");
        fail();
    } catch (ResourceException ex) {
        assertTrue(ex.getMessage().contains("User Authority expiry specified without a valid user authority"));
    }
    Authority authority = Mockito.mock(Authority.class);
    Set<String> booleanAttrSet = new HashSet<>();
    booleanAttrSet.add("elevated-clearance");
    booleanAttrSet.add("full-time-employee");
    Mockito.when(authority.booleanAttributesSupported()).thenReturn(booleanAttrSet);
    Set<String> dateAttrSet = new HashSet<>();
    dateAttrSet.add("term-date");
    Mockito.when(authority.dateAttributesSupported()).thenReturn(dateAttrSet);
    zms.userAuthority = authority;
    // valid values
    zms.validateUserAuthorityAttributes("elevated-clearance", null, "unit-test");
    zms.validateUserAuthorityAttributes("elevated-clearance", "", "unit-test");
    zms.validateUserAuthorityAttributes("elevated-clearance,full-time-employee", null, "unit-test");
    zms.validateUserAuthorityAttributes("full-time-employee,elevated-clearance", "term-date", "unit-test");
    zms.validateUserAuthorityAttributes("", "term-date", "unit-test");
    zms.validateUserAuthorityAttributes(null, "term-date", "unit-test");
    zms.validateUserAuthorityAttributes(null, null, "unit-test");
    zms.validateUserAuthorityAttributes(null, "", "unit-test");
    zms.validateUserAuthorityAttributes("", null, "unit-test");
    zms.validateUserAuthorityAttributes("", "", "unit-test");
    // invalid values
    try {
        zms.validateUserAuthorityAttributes("elevated-clearance,contractor", null, "unit-test");
        fail();
    } catch (ResourceException ex) {
        assertTrue(ex.getMessage().contains("contractor is not a valid user authority attribute"));
    }
    try {
        zms.validateUserAuthorityAttributes("elevated-clearance", "hire-date", "unit-test");
        fail();
    } catch (ResourceException ex) {
        assertTrue(ex.getMessage().contains("hire-date is not a valid user authority date attribute"));
    }
    zms.userAuthority = savedAuthority;
}