1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
package info.magnolia.module.blossom.web; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertFalse; |
37 |
|
import static org.junit.Assert.assertTrue; |
38 |
|
|
39 |
|
import info.magnolia.module.blossom.view.UuidRedirectViewResolver; |
40 |
|
|
41 |
|
import org.junit.Test; |
42 |
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext; |
43 |
|
import org.springframework.context.annotation.Bean; |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
@since |
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 2 |
Complexity Density: 0.09 |
|
50 |
|
public class BlossomRequestMappingHandlerAdapterTest { |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
|
public static class BlossomRequestMappingHandlerAdapterTestConfig { |
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
2 |
@Bean... |
55 |
|
public BlossomRequestMappingHandlerAdapter handlerAdapter() { |
56 |
2 |
return new BlossomRequestMappingHandlerAdapter(); |
57 |
|
} |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
60 |
1 |
@Test... |
61 |
|
public void testDetection() { |
62 |
|
|
63 |
1 |
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); |
64 |
1 |
wac.register(BlossomRequestMappingHandlerAdapterTestConfig.class); |
65 |
1 |
wac.refresh(); |
66 |
|
|
67 |
1 |
BlossomRequestMappingHandlerAdapter handlerAdapter = wac.getBean(BlossomRequestMappingHandlerAdapter.class); |
68 |
|
|
69 |
1 |
assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_MAIN_CONTENT_PLACEHOLDER)); |
70 |
1 |
assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_CURRENT_CONTENT_PLACEHOLDER)); |
71 |
|
|
72 |
1 |
assertTrue(handlerAdapter.isRedirectViewName("website:123")); |
73 |
1 |
assertTrue(handlerAdapter.isRedirectViewName("dms:123")); |
74 |
|
|
75 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("main.ftl")); |
76 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("main.jsp")); |
77 |
|
|
78 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("workspace:123")); |
79 |
|
} |
80 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
81 |
1 |
@Test... |
82 |
|
public void testDetectionWithCustomPatterns() { |
83 |
|
|
84 |
1 |
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext(); |
85 |
1 |
wac.register(BlossomRequestMappingHandlerAdapterTestConfig.class); |
86 |
1 |
wac.refresh(); |
87 |
|
|
88 |
1 |
BlossomRequestMappingHandlerAdapter handlerAdapter = wac.getBean(BlossomRequestMappingHandlerAdapter.class); |
89 |
1 |
handlerAdapter.setRedirectPatterns("prefix:*"); |
90 |
|
|
91 |
1 |
assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_MAIN_CONTENT_PLACEHOLDER)); |
92 |
1 |
assertTrue(handlerAdapter.isRedirectViewName(UuidRedirectViewResolver.REDIRECT_CURRENT_CONTENT_PLACEHOLDER)); |
93 |
|
|
94 |
1 |
assertTrue(handlerAdapter.isRedirectViewName("prefix:123")); |
95 |
|
|
96 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("website:123")); |
97 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("dms:123")); |
98 |
|
|
99 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("main.ftl")); |
100 |
1 |
assertFalse(handlerAdapter.isRedirectViewName("main.jsp")); |
101 |
|
} |
102 |
|
} |