@Test
public void testLookupDomainByRole() {

    
    String domainName = "lookupdomainrole";
    
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName,
            "Test Domain1", "testOrg", adminUser);
    dom1.setYpmId(199);
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    DomainList list = zms.dbService.lookupDomainByRole(adminUser, "admin");
    assertNotNull(list.getNames());
    assertTrue(list.getNames().contains(domainName));
    List<String> doms = zms.dbService.listDomains(null, 0, false);
    
    // all domains have admin role
    
    list = zms.dbService.lookupDomainByRole(null, "admin");
    assertNotNull(list.getNames());
    assertEquals(list.getNames().size(), doms.size());
    
    // null role/member gives us the full set
    
    list = zms.dbService.lookupDomainByRole(null, null);
    assertNotNull(list.getNames());
    assertEquals(list.getNames().size(), doms.size());
    
    // unknown role and member in the system
    
    list = zms.dbService.lookupDomainByRole(adminUser, "unknown_role");
    assertEquals(list.getNames().size(), 0);
    
    list = zms.dbService.lookupDomainByRole("unkwown-user", "admin");
    assertEquals(list.getNames().size(), 0);
    
    // lets add a role for joe and jane
    
    Role role1 = createRoleObject(domainName, "list-role", null,
            "user.joe", "user.jane");
    zms.dbService.executePutRole(mockDomRsrcCtx, domainName, "list-role",
            role1, auditRef, "putRole");
    
    list = zms.dbService.lookupDomainByRole("user.joe", "list-role");
    assertNotNull(list.getNames());
    assertEquals(list.getNames().size(), 1);
    assertEquals(list.getNames().get(0), domainName);
    
    list = zms.dbService.lookupDomainByRole(adminUser, "list-role");
    assertEquals(list.getNames().size(), 0);
    
    zms.deleteTopLevelDomain(mockDomRsrcCtx, domainName, auditRef);
}