/*
 * Copyright (C) 2004 - 2014 Brian McCallister
 *
 * 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 org.skife.jdbi.v2;

import org.junit.Test;

import java.util.Collections;

public class ConcreteStatementContextTest {


    @Test(expected = IllegalArgumentException.class)
    public void testShouldNotBeAbleToCombineGeneratedKeysAndConcurrentUpdatable() throws Exception {
        final ConcreteStatementContext context =
                new ConcreteStatementContext(Collections.<String, Object>emptyMap(), new MappingRegistry());

        context.setReturningGeneratedKeys(true);
        context.setConcurrentUpdatable(true);
    }

    @Test(expected = IllegalArgumentException.class)
    public void testShouldNotBeAbleToCombineConcurrentUpdatableAndGeneratedKeys() throws Exception {
        final ConcreteStatementContext context =
                new ConcreteStatementContext(Collections.<String, Object>emptyMap(), new MappingRegistry());

        context.setConcurrentUpdatable(true);
        context.setReturningGeneratedKeys(true);
    }
}

@@ -656,37 +656,245 @@
 st;%0A
-%0Aimport java.util.Collections
+import org.skife.jdbi.v2.tweak.ResultSetMapper;%0A%0Aimport java.sql.ResultSet;%0Aimport java.sql.SQLException;%0Aimport java.util.Collections;%0A%0Aimport static org.hamcrest.CoreMatchers.equalTo;%0Aimport static org.hamcrest.MatcherAssert.assertThat
 ;%0A%0Ap
@@ -1766,11 +1766,692 @@
 );%0A    %7D
+%0A%0A    private static class Foo %7B%0A    %7D%0A%0A    private static class FooMapper implements ResultSetMapper%3CFoo%3E %7B%0A        @Override%0A        public Foo map(int index, ResultSet r, StatementContext ctx) throws SQLException %7B%0A            return null;%0A        %7D%0A    %7D%0A%0A    @Test%0A    public void testMapperForDelegatesToRegistry() %7B%0A        ResultSetMapper mapper = new FooMapper();%0A%0A        MappingRegistry registry = new MappingRegistry();%0A        registry.add(mapper);%0A%0A        final ConcreteStatementContext context =%0A                new ConcreteStatementContext(Collections.%3CString, Object%3EemptyMap(), registry);%0A%0A        assertThat(context.mapperFor(Foo.class), equalTo(mapper));%0A    %7D
 %0A%7D%0A

Add unit test for ConcreteStatementContext.mapperFor