1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.mybatis.spring.boot.test.autoconfigure;
17
18 import java.util.Collections;
19 import java.util.Set;
20
21 import org.springframework.boot.context.TypeExcludeFilter;
22 import org.springframework.boot.test.autoconfigure.filter.AnnotationCustomizableTypeExcludeFilter;
23 import org.springframework.context.annotation.ComponentScan;
24 import org.springframework.core.annotation.AnnotatedElementUtils;
25
26
27
28
29
30
31
32
33 class MybatisTypeExcludeFilter extends AnnotationCustomizableTypeExcludeFilter {
34 private final MybatisTest annotation;
35
36 MybatisTypeExcludeFilter(Class<?> testClass) {
37 this.annotation = AnnotatedElementUtils.getMergedAnnotation(testClass, MybatisTest.class);
38 }
39
40 @Override
41 protected boolean hasAnnotation() {
42 return this.annotation != null;
43 }
44
45 @Override
46 protected ComponentScan.Filter[] getFilters(FilterType type) {
47 switch (type) {
48 case INCLUDE:
49 return this.annotation.includeFilters();
50 case EXCLUDE:
51 return this.annotation.excludeFilters();
52 default:
53 throw new IllegalStateException("Unsupported type " + type);
54 }
55 }
56
57 @Override
58 protected boolean isUseDefaultFilters() {
59 return this.annotation.useDefaultFilters();
60 }
61
62 @Override
63 protected Set<Class<?>> getDefaultIncludes() {
64 return Collections.emptySet();
65 }
66
67 @Override
68 protected Set<Class<?>> getComponentIncludes() {
69 return Collections.emptySet();
70 }
71
72 }