@Test
public void testListPrincipalRolesForAllDomains() throws Exception {

    
    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    
    Mockito.when(mockResultSet.getInt(1))
        .thenReturn(5); // principal id
    
    // principal roles
    Mockito.when(mockResultSet.next())
        .thenReturn(true) // get principal id
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(true)
        .thenReturn(false);
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_NAME))
        .thenReturn("coretech")
        .thenReturn("sports")
        .thenReturn("sports")
        .thenReturn("weather");
    Mockito.when(mockResultSet.getString(ZMSConsts.DB_COLUMN_ROLE_NAME))
        .thenReturn("admin")
        .thenReturn("reader")
        .thenReturn("writer")
        .thenReturn("reader");
    
    List<PrincipalRole> roles = jdbcConn.listPrincipalRoles(null, "user.joe");
    
    assertEquals(4, roles.size());
    
    // get principal id
    Mockito.verify(mockPrepStmt, times(1)).setString(1, "user.joe");
    // get role list
    Mockito.verify(mockPrepStmt, times(1)).setInt(1, 5);
    
    boolean coretech_admin = false;
    boolean sports_reader = false;
    boolean sports_writer = false;
    boolean weather_reader = false;
    for (PrincipalRole role : roles) {
        if (role.getDomainName().equals("coretech") && role.getRoleName().equals("admin")) {
            coretech_admin = true;
        } else if (role.getDomainName().equals("sports") && role.getRoleName().equals("reader")) {
            sports_reader = true;
        } else if (role.getDomainName().equals("sports") && role.getRoleName().equals("writer")) {
            sports_writer = true;
        } else if (role.getDomainName().equals("weather") && role.getRoleName().equals("reader")) {
            weather_reader = true;
        }
    }
    assertTrue(coretech_admin);
    assertTrue(sports_reader);
    assertTrue(sports_writer);
    assertTrue(weather_reader);
    
    jdbcConn.close();
}