1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.submitted.inline_association_with_dot;
17
18 import static org.junit.jupiter.api.Assertions.assertEquals;
19
20 import java.io.Reader;
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.AfterEach;
28 import org.junit.jupiter.api.Test;
29
30 class InlineCollectionWithDotTest {
31
32 private SqlSession sqlSession;
33
34 public void openSession(String aConfig) throws Exception {
35
36 final String resource = "org/apache/ibatis/submitted/inline_association_with_dot/ibatis-" + aConfig + ".xml";
37 try (Reader batisConfigReader = Resources.getResourceAsReader(resource)) {
38
39 SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(batisConfigReader);
40
41 BaseDataTest.runScript(sqlSessionFactory.getConfiguration().getEnvironment().getDataSource(),
42 "org/apache/ibatis/submitted/inline_association_with_dot/create.sql");
43
44 sqlSession = sqlSessionFactory.openSession();
45 }
46 }
47
48 @AfterEach
49 void closeSession() {
50 if (sqlSession != null) {
51 sqlSession.close();
52 }
53 }
54
55
56
57
58
59 @Test
60 void selectElementValueInContainerUsingInline() throws Exception {
61 openSession("inline");
62
63 Element myElement = sqlSession.getMapper(ElementMapperUsingInline.class).selectElement();
64
65 assertEquals("value", myElement.getElement().getElement().getValue());
66 }
67
68
69
70
71
72 @Test
73 void selectElementValueInContainerUsingSubMap() throws Exception {
74 openSession("submap");
75
76 Element myElement = sqlSession.getMapper(ElementMapperUsingSubMap.class).selectElement();
77
78 assertEquals("value", myElement.getElement().getElement().getValue());
79 }
80 }