1. Project Clover database mer. févr. 4 2026 12:48:28 CET
  2. Package org.devacfr.maven.skins.reflow.context

File ContextTest.java

 

Code metrics

0
40
6
1
119
81
6
0,15
6,67
6
1

Classes

Class Line # Actions
ContextTest 30 40 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 10 tests. .

Source view

1    /*
2    * Copyright 2012-2025 Christophe Friederich
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.apache.org/licenses/LICENSE-2.0
9    *
10    * Unless required by applicable law or agreed to in writing, software
11    * distributed under the License is distributed on an "AS IS" BASIS,
12    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13    * See the License for the specific language governing permissions and
14    * limitations under the License.
15    */
16    package org.devacfr.maven.skins.reflow.context;
17   
18    import static org.hamcrest.MatcherAssert.assertThat;
19    import static org.hamcrest.Matchers.isA;
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    public class ContextTest extends MockitoTestCase {
31   
32    @Mock(lenient = true)
33    private ISkinConfig config;
34   
 
35  10 toggle @SuppressWarnings("unchecked")
36    @BeforeEach
37    public void setup() {
38  10 final MavenProject project = new MavenProject();
39  10 project.setName("reflow");
40  10 project.setArtifactId("reflow-artifact");
41  10 when(config.getProject()).thenReturn(project);
42   
43  10 final SiteModel siteModel = new SiteModel();
44  10 when(config.getSiteModel()).thenReturn(siteModel);
45  10 when(config.getFileId()).thenReturn("currentFile");
46  10 when(config.getAttributeValue(any(String.class), any(String.class), any(Class.class), any(Object.class)))
47    .then(invocation -> invocation.getArguments()[3]);
48  10 when(config.getPropertyValue(any(String.class), any(Class.class), any(Object.class)))
49    .then(invocation -> invocation.getArguments()[2]);
50   
51  10 when(config.getHtmlTool()).thenReturn(new HtmlTool());
52    }
53   
 
54  2 toggle @Test
55    public void shouldReplaceTTTag() {
56  2 final Context<?> context = Context.buildContext(config);
57  2 assertThat((PageContext) context, isA(PageContext.class));
58   
59  2 final PageContext pageContext = (PageContext) context;
60   
61  2 verify(content -> {
62  2 when(config.getBodyContent()).thenReturn(content);
63  2 return pageContext.preRender();
64    }, "html");
65    }
66   
 
67  2 toggle @Test
68    public void shouldAddLighboxAttribute() {
69  2 final Context<?> context = Context.buildContext(config);
70  2 assertThat((PageContext) context, isA(PageContext.class));
71   
72  2 final PageContext pageContext = (PageContext) context;
73   
74  2 verify(content -> {
75  2 when(config.getBodyContent()).thenReturn(content);
76  2 return pageContext.preRender();
77    }, "html");
78    }
79   
 
80  2 toggle @Test
81    public void shouldApplyBootstrapCss() {
82  2 final Context<?> context = Context.buildContext(config);
83  2 assertThat((PageContext) context, isA(PageContext.class));
84   
85  2 final PageContext pageContext = (PageContext) context;
86   
87  2 verify(content -> {
88  2 when(config.getBodyContent()).thenReturn(content);
89  2 return pageContext.preRender();
90    }, "html");
91    }
92   
 
93  2 toggle @Test
94    public void shouldReplaceIcons() {
95  2 final Context<?> context = Context.buildContext(config);
96  2 assertThat((PageContext) context, isA(PageContext.class));
97   
98  2 final PageContext pageContext = (PageContext) context;
99   
100  2 verify(content -> {
101  2 when(config.getBodyContent()).thenReturn(content);
102  2 return pageContext.preRender();
103    }, "html");
104    }
105   
 
106  2 toggle @Test
107    public void shouldNotChangeCodePart() {
108  2 final Context<?> context = Context.buildContext(config);
109  2 assertThat((PageContext) context, isA(PageContext.class));
110   
111  2 final PageContext pageContext = (PageContext) context;
112   
113  2 verify(content -> {
114  2 when(config.getBodyContent()).thenReturn(content);
115  2 return pageContext.preRender();
116    }, "html");
117    }
118   
119    }