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.template; |
35 |
|
|
36 |
|
import static org.junit.Assert.assertEquals; |
37 |
|
import static org.junit.Assert.assertNotNull; |
38 |
|
import static org.junit.Assert.assertTrue; |
39 |
|
|
40 |
|
import info.magnolia.module.blossom.annotation.Area; |
41 |
|
import info.magnolia.module.blossom.annotation.AvailableComponentClasses; |
42 |
|
import info.magnolia.module.blossom.annotation.ComponentCategory; |
43 |
|
import info.magnolia.module.blossom.annotation.Template; |
44 |
|
import info.magnolia.module.blossom.suite.AbstractBlossomTestCase; |
45 |
|
import info.magnolia.objectfactory.Components; |
46 |
|
import info.magnolia.registry.RegistrationException; |
47 |
|
import info.magnolia.rendering.template.AreaDefinition; |
48 |
|
import info.magnolia.rendering.template.TemplateDefinition; |
49 |
|
import info.magnolia.rendering.template.registry.TemplateDefinitionRegistry; |
50 |
|
|
51 |
|
import java.lang.annotation.ElementType; |
52 |
|
import java.lang.annotation.Retention; |
53 |
|
import java.lang.annotation.RetentionPolicy; |
54 |
|
import java.lang.annotation.Target; |
55 |
|
|
56 |
|
import org.junit.Test; |
57 |
|
import org.springframework.stereotype.Controller; |
58 |
|
import org.springframework.web.bind.annotation.RequestMapping; |
59 |
|
|
60 |
|
|
61 |
|
@link |
62 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
|
63 |
|
public class ComponentCategoryAnnotationTest extends AbstractBlossomTestCase { |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
65 |
1 |
@Override... |
66 |
|
protected String getDispatcherServletConfigLocation() { |
67 |
1 |
return "classpath:info/magnolia/module/blossom/template/ComponentCategoryAnnotation-test.xml"; |
68 |
|
} |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
70 |
1 |
@Test... |
71 |
|
public void test() throws RegistrationException { |
72 |
|
|
73 |
1 |
TemplateDefinition testTemplate = Components.getComponent(TemplateDefinitionRegistry.class).getTemplateDefinition("myModule:pages/testTemplate"); |
74 |
1 |
assertNotNull(testTemplate); |
75 |
1 |
AreaDefinition promos = testTemplate.getAreas().get("promos"); |
76 |
1 |
assertNotNull(promos); |
77 |
1 |
assertEquals(1, promos.getAvailableComponents().size()); |
78 |
1 |
assertTrue(promos.getAvailableComponents().containsKey("myModule:components/testComponent")); |
79 |
|
} |
80 |
|
|
81 |
|
@Retention(RetentionPolicy.RUNTIME) |
82 |
|
@Target(ElementType.TYPE) |
83 |
|
@ComponentCategory |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
84 |
|
public @interface TestCategory { |
85 |
|
} |
86 |
|
|
87 |
|
@Template(title = "Test Component", id = "myModule:components/testComponent") |
88 |
|
@Controller |
89 |
|
@TestCategory |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
90 |
|
public static class TestComponent { |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0 |
@RequestMapping("/testComponent")... |
93 |
|
public String render() { |
94 |
0 |
return null; |
95 |
|
} |
96 |
|
} |
97 |
|
|
98 |
|
@Template(title = "Test Template", id = "myModule:pages/testTemplate") |
99 |
|
@Controller |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
100 |
|
public static class TestTemplate { |
101 |
|
|
102 |
|
@Controller |
103 |
|
@Area("promos") |
104 |
|
@AvailableComponentClasses({TestCategory.class}) |
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 1 |
|
105 |
|
public static class PromosArea { |
106 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
0 |
@RequestMapping("/mainTemplate/promos")... |
108 |
|
public String render() { |
109 |
0 |
return null; |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
113 |
0 |
@RequestMapping("/testTemplate")... |
114 |
|
public String render() { |
115 |
0 |
return null; |
116 |
|
} |
117 |
|
} |
118 |
|
} |