@Test
public void testNewResultSet_FilterQuery_Contains() throws Exception{

    // Mocks
    FilterQuery<Car, String> filterQuery = mockFilterQuery();
    ConnectionManager connectionManager = mock(ConnectionManager.class);
    Connection connectionContains = mock(Connection.class);
    Connection connectionDoNotContain = mock(Connection.class);
    Connection connectionNoRows = mock(Connection.class);
    PreparedStatement preparedStatementContains = mock(PreparedStatement.class);
    PreparedStatement preparedStatementDoNotContains = mock(PreparedStatement.class);
    PreparedStatement preparedStatementNoRows = mock(PreparedStatement.class);
    java.sql.ResultSet resultSetContains = mock(java.sql.ResultSet.class);
    java.sql.ResultSet resultSetDoNotContain = mock(java.sql.ResultSet.class);
    java.sql.ResultSet resultSetNoRows = mock(java.sql.ResultSet.class);
    // Behaviour
    //SELECT objectKey, value FROM cqtbl_%s WHERE objectKey=?
    when(connectionManager.getConnection(any(SQLiteIndex.class), anyQueryOptions())).thenReturn(connectionContains).thenReturn(connectionDoNotContain).thenReturn(connectionNoRows);
    when(connectionContains.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementContains);
    when(connectionDoNotContain.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementDoNotContains);
    when(connectionNoRows.prepareStatement("SELECT objectKey, value FROM " + TABLE_NAME + " WHERE objectKey = ?")).thenReturn(preparedStatementNoRows);
    when(preparedStatementContains.executeQuery()).thenReturn(resultSetContains);
    when(preparedStatementDoNotContains.executeQuery()).thenReturn(resultSetDoNotContain);
    when(preparedStatementNoRows.executeQuery()).thenReturn(resultSetNoRows);
    when(resultSetContains.next()).thenReturn(true).thenReturn(true).thenReturn(false);
    when(resultSetContains.getInt(1)).thenReturn(1).thenReturn(1);
    when(resultSetContains.getString(2)).thenReturn("abs").thenReturn("gps");
    when(resultSetDoNotContain.next()).thenReturn(true).thenReturn(false);
    when(resultSetDoNotContain.getInt(1)).thenReturn(2);
    when(resultSetDoNotContain.getString(2)).thenReturn("airbags");
    when(resultSetNoRows.next()).thenReturn(false);
    // Iterator
    ResultSet<Car> carsWithAbs = new SQLiteIndex<String, Car, Integer>(
            Car.FEATURES,
            OBJECT_TO_ID,
            ID_TO_OBJECT,
            "")
            .retrieve(filterQuery, createQueryOptions(connectionManager));
    assertNotNull(carsWithAbs);
    boolean resultContains = carsWithAbs.contains(data.get(0));
    assertTrue(resultContains);
    verify(connectionContains, times(0)).close();
    boolean resultDoNotContain = carsWithAbs.contains(data.get(1));
    assertFalse(resultDoNotContain);
    verify(connectionDoNotContain, times(0)).close();
    boolean resultNoRows = carsWithAbs.contains(CarFactory.createCar(100));
    assertFalse(resultNoRows);
    verify(connectionNoRows, times(0)).close();
}