| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 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 |
|
|
| |
|
| 95% |
Uncovered Elements: 2 (40) |
Complexity: 2 |
Complexity Density: 0,05 |
|
| 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 |
|
|
| |
|
| 94,6% |
Uncovered Elements: 2 (37) |
Complexity: 1 |
Complexity Density: 0,03 |
|
| 47 |
8 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 93 |
16 |
protected SnippetParser createParser() {... |
| 94 |
16 |
return new SnippetParser().insertResourcePath(getPackagePath().toString(), 0); |
| 95 |
|
} |
| 96 |
|
} |