| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 6 |
Complexity Density: 0,15 |
|
| 30 |
|
public class ContextTest extends MockitoTestCase { |
| 31 |
|
|
| 32 |
|
@Mock(lenient = true) |
| 33 |
|
private ISkinConfig config; |
| 34 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
|
| 35 |
10 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
| 54 |
2 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
| 67 |
2 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
| 80 |
2 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
| 93 |
2 |
@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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1PASS
|
|
| 106 |
2 |
@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 |
|
} |