/*
 * 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.jdbi.v3.sqlobject;

import org.jdbi.v3.core.H2DatabaseRule;
import org.jdbi.v3.core.Handle;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;

public class TestSqlMethodAnnotations
{
    @Rule
    public H2DatabaseRule db = new H2DatabaseRule().withPlugin(new SqlObjectPlugin());

    private Handle handle;

    @Before
    public void setUp() throws Exception
    {
        handle = db.getSharedHandle();
    }

    @Test(expected = IllegalStateException.class)
    public void testMutuallyExclusiveAnnotations()
    {
        handle.attach(DAO.class);
    }

    interface DAO {
        @SqlQuery
        @SqlUpdate
        void bogus();
    }
}

@@ -583,16 +583,237 @@
 bject;%0A%0A
+import static org.hamcrest.CoreMatchers.equalTo;%0Aimport static org.hamcrest.MatcherAssert.assertThat;%0A%0Aimport java.lang.annotation.Retention;%0Aimport java.lang.annotation.RetentionPolicy;%0Aimport java.lang.reflect.Method;%0A%0A
 import o
@@ -1348,19 +1348,22 @@
 .attach(
-DAO
+Broken
 .class);
@@ -1388,11 +1388,14 @@
 ace 
-DAO
+Broken
  %7B%0A 
@@ -1457,11 +1457,638 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testCustomAnnotation() %7B%0A        Dao dao = handle.attach(Dao.class);%0A%0A        assertThat(dao.foo(), equalTo(%22foo%22));%0A    %7D%0A%0A    public interface Dao %7B%0A        @Foo%0A        String foo();%0A    %7D%0A%0A    @Retention(RetentionPolicy.RUNTIME)%0A    @SqlMethodAnnotation(Foo.Factory.class)%0A    public @interface Foo %7B%0A        class Factory implements HandlerFactory %7B%0A            @Override%0A            public Handler buildHandler(Class%3C?%3E sqlObjectType, Method method) %7B%0A                return (obj, m, args, config, handle) -%3E %7B%0A                    return %22foo%22;%0A                %7D;%0A            %7D%0A        %7D%0A    %7D
 %0A%7D%0A

Add tests for custom SQL method annotation.