1. Project Clover database mer. févr. 4 2026 12:48:44 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 5 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  5 toggle @SuppressWarnings("unchecked")
36    @BeforeEach
37    public void setup() {
38  5 final MavenProject project = new MavenProject();
39  5 project.setName("reflow");
40  5 project.setArtifactId("reflow-artifact");
41  5 when(config.getProject()).thenReturn(project);
42   
43  5 final SiteModel siteModel = new SiteModel();
44  5 when(config.getSiteModel()).thenReturn(siteModel);
45  5 when(config.getFileId()).thenReturn("currentFile");
46  5 when(config.getAttributeValue(any(String.class), any(String.class), any(Class.class), any(Object.class)))
47    .then(invocation -> invocation.getArguments()[3]);
48  5 when(config.getPropertyValue(any(String.class), any(Class.class), any(Object.class)))
49    .then(invocation -> invocation.getArguments()[2]);
50   
51  5 when(config.getHtmlTool()).thenReturn(new HtmlTool());
52    }
53   
 
54  1 toggle @Test
55    public void shouldReplaceTTTag() {
56  1 final Context<?> context = Context.buildContext(config);
57  1 assertThat((PageContext) context, isA(PageContext.class));
58   
59  1 final PageContext pageContext = (PageContext) context;
60   
61  1 verify(content -> {
62  1 when(config.getBodyContent()).thenReturn(content);
63  1 return pageContext.preRender();
64    }, "html");
65    }
66   
 
67  1 toggle @Test
68    public void shouldAddLighboxAttribute() {
69  1 final Context<?> context = Context.buildContext(config);
70  1 assertThat((PageContext) context, isA(PageContext.class));
71   
72  1 final PageContext pageContext = (PageContext) context;
73   
74  1 verify(content -> {
75  1 when(config.getBodyContent()).thenReturn(content);
76  1 return pageContext.preRender();
77    }, "html");
78    }
79   
 
80  1 toggle @Test
81    public void shouldApplyBootstrapCss() {
82  1 final Context<?> context = Context.buildContext(config);
83  1 assertThat((PageContext) context, isA(PageContext.class));
84   
85  1 final PageContext pageContext = (PageContext) context;
86   
87  1 verify(content -> {
88  1 when(config.getBodyContent()).thenReturn(content);
89  1 return pageContext.preRender();
90    }, "html");
91    }
92   
 
93  1 toggle @Test
94    public void shouldReplaceIcons() {
95  1 final Context<?> context = Context.buildContext(config);
96  1 assertThat((PageContext) context, isA(PageContext.class));
97   
98  1 final PageContext pageContext = (PageContext) context;
99   
100  1 verify(content -> {
101  1 when(config.getBodyContent()).thenReturn(content);
102  1 return pageContext.preRender();
103    }, "html");
104    }
105   
 
106  1 toggle @Test
107    public void shouldNotChangeCodePart() {
108  1 final Context<?> context = Context.buildContext(config);
109  1 assertThat((PageContext) context, isA(PageContext.class));
110   
111  1 final PageContext pageContext = (PageContext) context;
112   
113  1 verify(content -> {
114  1 when(config.getBodyContent()).thenReturn(content);
115  1 return pageContext.preRender();
116    }, "html");
117    }
118   
119    }