1. Project Clover database mar. janv. 20 2026 12:32:22 CET
  2. Package org.devacfr.maven.skins.reflow.snippet

File BaseSnippetTest.java

 

Coverage histogram

../../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
38
2
1
96
72
2
0,05
19
2
1

Classes

Class Line # Actions
BaseSnippetTest 33 38 0% 2 2
0.9595%
 

Contributing tests

This file is covered by 16 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.snippet;
17   
18    import java.sql.Date;
19    import org.apache.maven.doxia.site.Body;
20    import org.apache.maven.doxia.site.LinkItem;
21    import org.apache.maven.doxia.site.PublishDate;
22    import org.apache.maven.doxia.site.SiteModel;
23    import org.apache.maven.doxia.site.Version;
24    import org.apache.maven.project.MavenProject;
25    import org.apache.velocity.tools.ToolContext;
26    import org.devacfr.maven.skins.reflow.ISkinConfig;
27    import org.devacfr.maven.skins.reflow.context.PageContext;
28    import org.devacfr.maven.skins.reflow.context.PositionType;
29    import org.devacfr.testing.jupiter.MockitoTestCase;
30    import org.junit.jupiter.api.BeforeEach;
31    import org.mockito.Mock;
32   
 
33    public abstract class BaseSnippetTest extends MockitoTestCase {
34   
35    @Mock(lenient = true)
36    protected ISkinConfig config;
37   
38    protected ToolContext velocityContext;
39   
40    protected SiteModel siteModel;
41   
42    protected PageContext context;
43   
44    @Mock(lenient = true)
45    protected MavenProject mavenProject;
46   
 
47  8 toggle @SuppressWarnings("unchecked")
48    @BeforeEach
49    public void setup() throws Exception {
50  8 velocityContext = SnippetContext.createToolManaged().createContext();
51  8 siteModel = new SiteModel();
52  8 when(config.getSiteModel()).thenReturn(siteModel);
53  8 when(config.getProject()).thenReturn(mavenProject);
54  8 when(config.getVelocityContext()).thenReturn(velocityContext);
55  8 when(config.getAttributeValue(any(String.class), any(String.class), any(Class.class), any())).then((a) -> {
56  112 Object[] args = a.getArguments();
57  112 return args[3];
58    });
59  8 when(config.getPropertyValue(any(String.class), any(Class.class), any())).then((a) -> {
60  16 Object[] args = a.getArguments();
61  16 return args[2];
62    });
63  8 when(config.relativeLink(any())).then((a) -> {
64  12 Object[] args = a.getArguments();
65  12 return args[0];
66    });
67  8 context = new PageContext(config);
68  8 when(config.getContext()).thenReturn(context);
69  8 when(config.getToolbox(any(), any())).then((a) -> {
70  0 Object[] args = a.getArguments();
71  0 return velocityContext.getToolbox().get(args[0]);
72    });
73  8 when(config.not("breadcrumbs")).thenReturn(false);
74  8 PublishDate publishDate = new PublishDate();
75  8 publishDate.setPosition(PositionType.none.toString());
76  8 siteModel.setPublishDate(publishDate);
77  8 when(config.getVersion()).thenReturn("1.0.0");
78  8 when(config.getVersionMessage()).thenReturn("Version: 1.0.0");
79  8 when(config.getBuildOutputTimestamp()).thenReturn(Date.valueOf("2025-11-16"));
80  8 when(config.getPublishDateMessage()).thenReturn("Last Published: 2025-11-16");
81  8 when(config.getShortTitle()).thenReturn("Documentation");
82  8 Body body = new Body();
83  8 Version version = new Version();
84  8 version.setPosition(PositionType.none.toString());
85  8 siteModel.setVersion(version);
86  8 LinkItem linkItem = new LinkItem();
87  8 linkItem.setName("Reflow");
88  8 linkItem.setHref("../..");
89  8 body.addBreadcrumb(linkItem);
90  8 siteModel.setBody(body);
91    }
92   
 
93  16 toggle protected SnippetParser createParser() {
94  16 return new SnippetParser().insertResourcePath(getPackagePath().toString(), 0);
95    }
96    }