1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.spring.boot.autoconfigure;
17
18 import static org.assertj.core.api.Assertions.assertThat;
19 import static org.junit.jupiter.api.Assertions.assertAll;
20
21 import com.jayway.jsonpath.DocumentContext;
22 import com.jayway.jsonpath.JsonPath;
23
24 import java.io.IOException;
25 import java.util.List;
26 import java.util.Map;
27
28 import org.junit.jupiter.api.Test;
29 import org.springframework.core.io.FileSystemResource;
30
31
32
33
34
35
36
37
38 class AdditionalConfigurationMetadataTest {
39
40 @Test
41 void testProperties() throws IOException {
42
43 DocumentContext documentContext = JsonPath
44 .parse(new FileSystemResource("src/main/resources/META-INF/additional-spring-configuration-metadata.json")
45 .getInputStream());
46
47 List<Map<String, Object>> properties = documentContext.read("$.properties");
48
49 assertAll(() -> assertThat(properties.size()).isEqualTo(4), () -> {
50
51 Map<String, Object> element = properties.get(0);
52 assertThat(element.get("defaultValue")).isEqualTo(false);
53 assertThat(element.get("name")).isEqualTo("mybatis.lazy-initialization");
54 assertThat(element.get("type")).isEqualTo("java.lang.Boolean");
55 }, () -> {
56
57 Map<String, Object> element = properties.get(1);
58 assertThat(element.get("defaultValue")).isEqualTo("");
59 assertThat(element.get("name")).isEqualTo("mybatis.mapper-default-scope");
60 assertThat(element.get("type")).isEqualTo("java.lang.String");
61 }, () -> {
62
63 Map<String, Object> element = properties.get(2);
64 assertThat(element.get("defaultValue")).isEqualTo(true);
65 assertThat(element.get("name")).isEqualTo("mybatis.inject-sql-session-on-mapper-scan");
66 assertThat(element.get("type")).isEqualTo("java.lang.Boolean");
67 }, () -> {
68
69 Map<String, Object> element = properties.get(3);
70 assertThat(element.get("name")).isEqualTo("mybatis.scripting-language-driver.velocity.userdirective");
71 @SuppressWarnings("unchecked")
72 Map<String, Object> deprecation = (Map<String, Object>) element.get("deprecation");
73 assertThat(deprecation.get("level")).isEqualTo("error");
74 assertThat(deprecation.get("reason")).isEqualTo(
75 "The 'userdirective' is deprecated since Velocity 2.x. This property defined for keeping backward compatibility with older velocity version.");
76 assertThat(deprecation.get("replacement"))
77 .isEqualTo("mybatis.scripting-language-driver.velocity.velocity-settings.runtime.custom_directives");
78 });
79 }
80 }