@Test
public void testGetPrincipalRolesDomain() throws SQLException {

    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Mockito.when(mockResultSet.getInt(1))
            .thenReturn(1)  // Principal id will be 1
            .thenReturn(1); // Domain id will be 1
    // domain role members
    Mockito.when(mockResultSet.next())
            .thenReturn(true) // True for getting principal_id
            .thenReturn(true) // True for getting domain_id
            .thenReturn(true) // True for the returned members (3 total)
            .thenReturn(true)
            .thenReturn(true)
            .thenReturn(false);
    Mockito.when(mockResultSet.getString(1)) // role names
            .thenReturn("role2")  // role2 in domain3
            .thenReturn("role3")  // role3 in domain3
            .thenReturn("role4"); // role4 in domain3
    Mockito.when(mockResultSet.getString(2)) // domain names
            .thenReturn("domain3")
            .thenReturn("domain3")
            .thenReturn("domain3");
    java.sql.Timestamp testTimestamp = new java.sql.Timestamp(1454358916);
    Mockito.when(mockResultSet.getTimestamp(3)) // expiration
            .thenReturn(null)
            .thenReturn(null)
            .thenReturn(testTimestamp);
    Mockito.when(mockResultSet.getTimestamp(4)) // review reminder
            .thenReturn(null)
            .thenReturn(null)
            .thenReturn(null);
    Mockito.when(mockResultSet.getInt(5)) // System disabled
            .thenReturn(1)
            .thenReturn(0)
            .thenReturn(0);
    String principalName = "user.testUser";
    MemberRole memberRole3 = new MemberRole();
    memberRole3.setRoleName("role2");
    memberRole3.setDomainName("domain3");
    memberRole3.setExpiration(null);
    memberRole3.setReviewReminder(null);
    memberRole3.setSystemDisabled(1);
    MemberRole memberRole4 = new MemberRole();
    memberRole4.setRoleName("role3");
    memberRole4.setDomainName("domain3");
    memberRole4.setExpiration(null);
    memberRole4.setReviewReminder(null);
    MemberRole memberRole5 = new MemberRole();
    memberRole5.setRoleName("role4");
    memberRole5.setDomainName("domain3");
    memberRole5.setExpiration(Timestamp.fromMillis(testTimestamp.getTime()));
    memberRole5.setReviewReminder(null);
    DomainRoleMember roleMember = jdbcConn.getPrincipalRoles(principalName, "domain3");
    assertEquals(roleMember.getMemberName(), principalName);
    assertEquals(roleMember.getMemberRoles().size(), 3);
    assertEquals(roleMember.getMemberRoles().get(0), memberRole3);
    assertEquals(roleMember.getMemberRoles().get(1), memberRole4);
    assertEquals(roleMember.getMemberRoles().get(2), memberRole5);
}