@Test
public void testListGroupsWithUserAuthorityRestrictions() throws Exception {

    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    // we have 3 entries being returned
    Mockito.when(mockResultSet.next())
            .thenReturn(true)
            .thenReturn(true)
            .thenReturn(true)
            .thenReturn(false);
    Mockito.when(mockResultSet.getString("domain_name"))
            .thenReturn("athenz")
            .thenReturn("athenz.subdomain")
            .thenReturn("sports");
    Mockito.when(mockResultSet.getString("group_name"))
            .thenReturn("admin")
            .thenReturn("readers")
            .thenReturn("readers");
    Mockito.when(mockResultSet.getString("domain_user_authority_filter"))
            .thenReturn("OnShore-US")
            .thenReturn("")
            .thenReturn("");
    List<PrincipalGroup> groups = jdbcConn.listGroupsWithUserAuthorityRestrictions();
    // data back is sorted
    assertEquals(3, groups.size());
    assertEquals("athenz", groups.get(0).getDomainName());
    assertEquals("admin", groups.get(0).getGroupName());
    assertEquals("OnShore-US", groups.get(0).getDomainUserAuthorityFilter());
    assertEquals("athenz.subdomain", groups.get(1).getDomainName());
    assertEquals("readers", groups.get(1).getGroupName());
    assertTrue(groups.get(1).getDomainUserAuthorityFilter().isEmpty());
    assertEquals("sports", groups.get(2).getDomainName());
    assertEquals("readers", groups.get(2).getGroupName());
    assertTrue(groups.get(2).getDomainUserAuthorityFilter().isEmpty());
    jdbcConn.close();
}