/*
 * 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.jackson2;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import org.jdbi.v3.json.AbstractJsonMapperTest;
import org.jdbi.v3.postgres.PostgresDbRule;
import org.jdbi.v3.testing.JdbiRule;
import org.junit.Before;
import org.junit.Rule;

public class TestJackson2Plugin extends AbstractJsonMapperTest {
    @Rule
    public JdbiRule db = PostgresDbRule.rule();

    @Before
    public void before() {
        jdbi = db.getJdbi().installPlugin(new Jackson2Plugin());
        jdbi.getConfig(Jackson2Config.class).setMapper(new ObjectMapper().registerModule(new ParameterNamesModule()));
    }
}

@@ -582,16 +582,70 @@
 kson2;%0A%0A
+import com.fasterxml.jackson.annotation.JsonTypeInfo;%0A
 import c
@@ -688,16 +688,16 @@
 Mapper;%0A
-
 import c
@@ -805,16 +805,46 @@
 erTest;%0A
+import org.jdbi.v3.json.Json;%0A
 import o
@@ -875,24 +875,169 @@
 gresDbRule;%0A
+import org.jdbi.v3.sqlobject.customizer.Bind;%0Aimport org.jdbi.v3.sqlobject.statement.SqlQuery;%0Aimport org.jdbi.v3.sqlobject.statement.SqlUpdate;%0A
 import org.j
@@ -1108,16 +1108,98 @@
 it.Rule;
+%0Aimport org.junit.Test;%0A%0Aimport static org.assertj.core.api.Assertions.assertThat;
 %0A%0Apublic
@@ -1257,16 +1257,17 @@
 rTest %7B%0A
+%0A
     @Rul
@@ -1417,24 +1417,24 @@
 2Plugin());%0A
-
         jdbi
@@ -1545,11 +1545,1194 @@
 );%0A    %7D
+%0A%0A    @Test%0A    public void testGenericPolymorphicType() %7B%0A        db.getJdbi().useHandle(h -%3E %7B%0A            ContainerDao dao = h.attach(ContainerDao.class);%0A%0A            dao.table();%0A%0A            Container%3CContained%3E c1 = new Container%3C%3E();%0A            c1.setContained(new A());%0A%0A            dao.insert(c1);%0A%0A            assertThat(dao.get().getContained()).isInstanceOf(A.class);%0A        %7D);%0A    %7D%0A%0A    private interface ContainerDao %7B%0A%0A        @SqlUpdate(%22create table json(contained varchar)%22)%0A        void table();%0A%0A        @SqlUpdate(%22insert into json(contained) values(:json)%22)%0A        void insert(@Bind @Json Container%3CContained%3E json);%0A%0A        @SqlQuery(%22select * from json limit 1%22)%0A        @Json%0A        Container%3CContained%3E get();%0A    %7D%0A%0A    @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS)%0A    public interface Contained %7B%7D%0A%0A    public static class A implements Contained %7B%7D%0A%0A    public static class B implements Contained %7B%7D%0A%0A    public static class Container%3CT%3E %7B%0A%0A        private T contained;%0A%0A        public T getContained() %7B%0A            return contained;%0A        %7D%0A%0A        public void setContained(T contained) %7B%0A            this.contained = contained;%0A        %7D%0A    %7D
 %0A%7D%0A

implement test for jackson generic type