1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
package org.devacfr.maven.skins.reflow.context; |
20 |
|
|
21 |
|
import org.apache.maven.doxia.site.SiteModel; |
22 |
|
import org.apache.maven.project.MavenProject; |
23 |
|
import org.devacfr.maven.skins.reflow.HtmlTool; |
24 |
|
import org.devacfr.maven.skins.reflow.ISkinConfig; |
25 |
|
import org.devacfr.testing.jupiter.MockitoTestCase; |
26 |
|
import org.junit.jupiter.api.BeforeEach; |
27 |
|
import org.junit.jupiter.api.Test; |
28 |
|
import org.mockito.Mock; |
29 |
|
|
30 |
|
import static org.hamcrest.MatcherAssert.assertThat; |
31 |
|
import static org.hamcrest.Matchers.isA; |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (45) |
Complexity: 6 |
Complexity Density: 0,15 |
|
33 |
|
public class ContextTest extends MockitoTestCase { |
34 |
|
|
35 |
|
@Mock |
36 |
|
private ISkinConfig config; |
37 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
|
38 |
5 |
@SuppressWarnings("unchecked")... |
39 |
|
@BeforeEach |
40 |
|
public void setup() { |
41 |
5 |
final MavenProject project = new MavenProject(); |
42 |
5 |
project.setName("reflow"); |
43 |
5 |
project.setArtifactId("reflow-artifact"); |
44 |
5 |
when(config.getProject()).thenReturn(project); |
45 |
|
|
46 |
5 |
final SiteModel siteModel = new SiteModel(); |
47 |
5 |
when(config.getSiteModel()).thenReturn(siteModel); |
48 |
5 |
when(config.getAttributeValue(any(String.class), any(String.class), any(Class.class), any(Object.class))) |
49 |
|
.then(invocation -> invocation.getArguments()[3]); |
50 |
5 |
when(config.getPropertyValue(any(String.class), any(Class.class), any(Object.class))) |
51 |
|
.then(invocation -> invocation.getArguments()[2]); |
52 |
|
|
53 |
5 |
when(config.getToolbox("htmlTool", HtmlTool.class)).thenReturn(new HtmlTool()); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
56 |
1 |
@Test... |
57 |
|
public void shouldReplaceTTTag() { |
58 |
1 |
final Context<?> context = Context.buildContext(config); |
59 |
1 |
assertThat((PageContext) context, isA(PageContext.class)); |
60 |
|
|
61 |
1 |
final PageContext pageContext = (PageContext) context; |
62 |
|
|
63 |
1 |
verify(content -> { |
64 |
1 |
when(config.getContextValue("bodyContent", String.class)).thenReturn(content); |
65 |
1 |
return pageContext.preRender(config); |
66 |
|
}, "html"); |
67 |
|
} |
68 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
69 |
1 |
@Test... |
70 |
|
public void shouldAddLighboxAttribute() { |
71 |
1 |
final Context<?> context = Context.buildContext(config); |
72 |
1 |
assertThat((PageContext) context, isA(PageContext.class)); |
73 |
|
|
74 |
1 |
final PageContext pageContext = (PageContext) context; |
75 |
|
|
76 |
1 |
verify(content -> { |
77 |
1 |
when(config.getContextValue("bodyContent", String.class)).thenReturn(content); |
78 |
1 |
return pageContext.preRender(config); |
79 |
|
}, "html"); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
82 |
1 |
@Test... |
83 |
|
public void shouldApplyBootstrapCss() { |
84 |
1 |
final Context<?> context = Context.buildContext(config); |
85 |
1 |
assertThat((PageContext) context, isA(PageContext.class)); |
86 |
|
|
87 |
1 |
final PageContext pageContext = (PageContext) context; |
88 |
|
|
89 |
1 |
verify(content -> { |
90 |
1 |
when(config.getContextValue("bodyContent", String.class)).thenReturn(content); |
91 |
1 |
return pageContext.preRender(config); |
92 |
|
}, "html"); |
93 |
|
} |
94 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
95 |
1 |
@Test... |
96 |
|
public void shouldReplaceIcons() { |
97 |
1 |
final Context<?> context = Context.buildContext(config); |
98 |
1 |
assertThat((PageContext) context, isA(PageContext.class)); |
99 |
|
|
100 |
1 |
final PageContext pageContext = (PageContext) context; |
101 |
|
|
102 |
1 |
verify(content -> { |
103 |
1 |
when(config.getContextValue("bodyContent", String.class)).thenReturn(content); |
104 |
1 |
return pageContext.preRender(config); |
105 |
|
}, "html"); |
106 |
|
} |
107 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
108 |
1 |
@Test... |
109 |
|
public void shouldNotChangeCodePart() { |
110 |
1 |
final Context<?> context = Context.buildContext(config); |
111 |
1 |
assertThat((PageContext) context, isA(PageContext.class)); |
112 |
|
|
113 |
1 |
final PageContext pageContext = (PageContext) context; |
114 |
|
|
115 |
1 |
verify(content -> { |
116 |
1 |
when(config.getContextValue("bodyContent", String.class)).thenReturn(content); |
117 |
1 |
return pageContext.preRender(config); |
118 |
|
}, "html"); |
119 |
|
} |
120 |
|
} |