1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.simplelistparameter;
17
18 import java.io.Reader;
19 import java.util.Arrays;
20 import java.util.List;
21
22 import org.apache.ibatis.BaseDataTest;
23 import org.apache.ibatis.io.Resources;
24 import org.apache.ibatis.session.SqlSession;
25 import org.apache.ibatis.session.SqlSessionFactory;
26 import org.apache.ibatis.session.SqlSessionFactoryBuilder;
27 import org.junit.jupiter.api.Assertions;
28 import org.junit.jupiter.api.BeforeAll;
29 import org.junit.jupiter.api.Test;
30
31 class SimpleListParameterTest {
32
33 private static SqlSessionFactory sqlSessionFactory;
34
35 @BeforeAll
36 static void setUp() throws Exception {
37
38 try (Reader reader = Resources
39 .getResourceAsReader("org/apache/ibatis/submitted/simplelistparameter/mybatis-config.xml")) {
40 sqlSessionFactory = new SqlSessionFactoryBuilder().build(reader);
41 }
42
43
44 BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(),
45 "org/apache/ibatis/submitted/simplelistparameter/CreateDB.sql");
46 }
47
48 @Test
49 void shouldGetACar() {
50 try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
51 CarMapper carMapper = sqlSession.getMapper(CarMapper.class);
52 Car car = new Car();
53 car.setDoors(Arrays.asList("2", "4"));
54 List<Car> cars = carMapper.getCar(car);
55 Assertions.assertNotNull(cars);
56 }
57 }
58
59 @Test
60 void shouldResolveGenericFieldGetterType() {
61 try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
62 CarMapper carMapper = sqlSession.getMapper(CarMapper.class);
63 Rv rv = new Rv();
64 rv.doors1 = Arrays.asList("2", "4");
65 List<Rv> rvs = carMapper.getRv1(rv);
66 Assertions.assertNotNull(rvs);
67 }
68 }
69
70 @Test
71 void shouldResolveGenericMethodGetterType() {
72 try (SqlSession sqlSession = sqlSessionFactory.openSession()) {
73 CarMapper carMapper = sqlSession.getMapper(CarMapper.class);
74 Rv rv = new Rv();
75 rv.setDoors2(Arrays.asList("2", "4"));
76 List<Rv> rvs = carMapper.getRv2(rv);
77 Assertions.assertNotNull(rvs);
78 }
79 }
80 }