@Test
public void testGetPrincipalGroups() {

    final String domainName1 = "principal-groups-dom1";
    final String groupName1 = "group1";
    TopLevelDomain dom1 = createTopLevelDomainObject(domainName1, "Test Domain1", "testOrg", "user.user1");
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom1);
    Group group1 = createGroupObject(domainName1, groupName1, "user.john", "user.joe");
    zms.putGroup(mockDomRsrcCtx, domainName1, groupName1, auditRef, group1);
    final String domainName2 = "principal-groups-dom2";
    final String groupName2 = "group2";
    TopLevelDomain dom2 = createTopLevelDomainObject(domainName2, "Test Domain1", "testOrg", "user.user1");
    zms.postTopLevelDomain(mockDomRsrcCtx, auditRef, dom2);
    Group group2 = createGroupObject(domainName2, groupName2, "user.john", "user.user1");
    zms.putGroup(mockDomRsrcCtx, domainName2, groupName2, auditRef, group2);
    DomainGroupMember dgm = zms.getPrincipalGroups(mockDomRsrcCtx, "user.john", domainName1);
    assertNotNull(dgm);
    List<GroupMember> memberGroups = dgm.getMemberGroups();
    assertEquals(memberGroups.size(), 1);
    assertEquals(memberGroups.get(0).getGroupName(), groupName1);
    assertEquals(memberGroups.get(0).getDomainName(), domainName1);
    dgm = zms.getPrincipalGroups(mockDomRsrcCtx, "user.john", null);
    assertNotNull(dgm);
    memberGroups = dgm.getMemberGroups();
    assertEquals(memberGroups.size(), 2);
    dgm = zms.getPrincipalGroups(mockDomRsrcCtx, null, domainName1);
    assertNotNull(dgm);
    assertTrue(dgm.getMemberGroups().isEmpty());
    dgm = zms.getPrincipalGroups(mockDomRsrcCtx, null, domainName2);
    assertNotNull(dgm);
    memberGroups = dgm.getMemberGroups();
    assertEquals(memberGroups.size(), 1);
    assertEquals(memberGroups.get(0).getGroupName(), groupName2);
    assertEquals(memberGroups.get(0).getDomainName(), domainName2);
}