@Test
public void testGetPrincipalGroupsInvalidDomain() throws SQLException {

    JDBCConnection jdbcConn = new JDBCConnection(mockConn, true);
    Mockito.when(mockResultSet.getInt(1))
            .thenReturn(1); // Principal id will be 1
    // domain group members
    Mockito.when(mockResultSet.next())
            .thenReturn(true) // True for getting principal_id
            .thenThrow(new SQLException("error getting domain_id")); // Throw exception when trying to get domain_id
    String principalName = "user.testUser";
    try {
        jdbcConn.getPrincipalGroups(principalName, "unknownDomain");
        fail();
    } catch (ResourceException ex) {
        assertEquals(ex.getCode(), 404);
        assertEquals(ex.getData().toString(), "{code: 404, message: \"unknown domain - unknownDomain\"}");
    }
}