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 static org.hamcrest.MatcherAssert.assertThat; |
22 |
|
import static org.hamcrest.Matchers.isA; |
23 |
|
|
24 |
|
import java.io.StringReader; |
25 |
|
|
26 |
|
import org.apache.maven.doxia.site.SiteModel; |
27 |
|
import org.apache.maven.project.MavenProject; |
28 |
|
import org.codehaus.plexus.util.xml.Xpp3Dom; |
29 |
|
import org.codehaus.plexus.util.xml.Xpp3DomBuilder; |
30 |
|
import org.devacfr.maven.skins.reflow.ISkinConfig; |
31 |
|
import org.devacfr.maven.skins.reflow.model.NavSideMenu; |
32 |
|
import org.devacfr.testing.jupiter.MockitoTestCase; |
33 |
|
import org.junit.jupiter.api.BeforeEach; |
34 |
|
import org.junit.jupiter.api.Test; |
35 |
|
import org.mockito.Mock; |
36 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 2 |
Complexity Density: 0,11 |
|
37 |
|
public class DocumentContextTest extends MockitoTestCase { |
38 |
|
|
39 |
|
@Mock |
40 |
|
private ISkinConfig config; |
41 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
42 |
1 |
@SuppressWarnings("unchecked")... |
43 |
|
@BeforeEach |
44 |
|
public void setup() { |
45 |
1 |
final MavenProject project = new MavenProject(); |
46 |
1 |
project.setName("reflow"); |
47 |
1 |
project.setArtifactId("reflow-artifact"); |
48 |
1 |
when(config.getProject()).thenReturn(project); |
49 |
|
|
50 |
1 |
final SiteModel model = new SiteModel(); |
51 |
1 |
when(config.getSiteModel()).thenReturn(model); |
52 |
1 |
when(config.getAttributeValue(any(String.class), any(String.class), any(Class.class), any(Object.class))) |
53 |
|
.then(invocation -> invocation.getArguments()[3]); |
54 |
1 |
when(config.getPropertyValue(any(String.class), any(Class.class), any(Object.class))) |
55 |
|
.then(invocation -> invocation.getArguments()[2]); |
56 |
|
} |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1PASS
|
|
58 |
1 |
@Test... |
59 |
|
public void shouldBuildDocumentContext() throws Exception { |
60 |
1 |
final Xpp3Dom pageProperties = Xpp3DomBuilder.build(new StringReader("<document type=\"doc\"></document>")); |
61 |
1 |
when(config.getPageProperties()).thenReturn(pageProperties); |
62 |
|
|
63 |
1 |
final Context<?> context = Context.buildContext(config); |
64 |
1 |
assertThat((DocumentContext) context, isA(DocumentContext.class)); |
65 |
|
|
66 |
1 |
final DocumentContext documentContext = (DocumentContext) context; |
67 |
|
|
68 |
1 |
final NavSideMenu navSideMenu = documentContext.getNavSideMenu(); |
69 |
1 |
assertNotNull(navSideMenu, "NavSideMenu should be exist"); |
70 |
1 |
assertEquals("m-sidenav-enabled", navSideMenu.getCssOptions()); |
71 |
|
|
72 |
1 |
assertEquals("anchorjs-enabled scrolltop-smooth-enabled m-sidenav-enabled", documentContext.getCssOptions()); |
73 |
1 |
assertEquals("", documentContext.getCssClass()); |
74 |
|
} |
75 |
|
} |