/*
 *      Copyright (C) 2012-2015 DataStax Inc.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */
package com.datastax.driver.core.exceptions;

import java.util.Collection;

import com.google.common.collect.Lists;
import org.testng.annotations.Test;

import com.datastax.driver.core.CCMBridge;
import com.datastax.driver.core.utils.CassandraVersion;

@CassandraVersion(major = 2.2)
public class FunctionExecutionExceptionTest extends CCMBridge.PerClassSingleNodeCluster {

    @Override
    protected Collection<String> getTableDefinitions() {
        return Lists.newArrayList(
            "CREATE TABLE foo (k int primary key)",
            "INSERT INTO foo (k) VALUES (0)",
            "CREATE FUNCTION inverse(i int) RETURNS NULL ON NULL INPUT RETURNS double LANGUAGE java AS 'return 1.0/i;'"
        );
    }

    @Test(groups = "short", expectedExceptions = FunctionExecutionException.class)
    public void should_throw_when_function_execution_fails() {
        session.execute("SELECT inverse(k) FROM foo");
    }
}
@@ -1150,16 +1150,36 @@
 mary key
+, i int, l list%3Cint%3E
 )%22,%0A    
@@ -1205,16 +1205,22 @@
 O foo (k
+, i, l
 ) VALUES
@@ -1221,17 +1221,25 @@
 VALUES (
-0
+1, 1, %5B1%5D
 )%22,%0A    
@@ -1263,24 +1263,40 @@
 UNCTION 
-inverse(
+element_at(l list%3Cint%3E, 
 i int) R
@@ -1333,14 +1333,11 @@
 RNS 
-double
+int
  LAN
@@ -1362,13 +1362,26 @@
 urn 
-1.0/i
+(Integer) l.get(i)
 ;'%22%0A
@@ -1580,27 +1580,45 @@
 ECT 
-inverse(k) FROM foo
+element_at(l, i) FROM foo WHERE k = 1
 %22);%0A
@@ -1623,9 +1623,10 @@
 ;%0A    %7D%0A
-
 %7D
+%0A

Fix failing test.