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

File SnippetParserTest.java

 

Code metrics

0
38
10
1
127
99
18
0,47
3,8
10
1,8

Classes

Class Line # Actions
SnippetParserTest 23 38 0% 18 8
0.833333383,3%
 

Contributing tests

This file is covered by 18 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.io.IOException;
19    import org.jsoup.nodes.Element;
20    import org.junit.jupiter.api.BeforeEach;
21    import org.junit.jupiter.api.Test;
22   
 
23    public class SnippetParserTest extends BaseSnippetTest {
24   
 
25  18 toggle @BeforeEach
26    public void setup() {
27  18 velocityContext = SnippetContext.createToolManaged().createContext();
28  18 when(config.getVelocityContext()).thenReturn(velocityContext);
29    }
30   
 
31  2 toggle @Test
32    public void shouldContainSnippetComponent() {
33  2 SnippetParser parser = createParser();
34  2 parser.addResourcePath(getPackagePath().toString());
35  2 assertEquals(true, parser.hasIncludedSnippetComponent(new Element("body").append("<test class=\"cl\"></test>")));
36  2 assertEquals(false, parser.hasIncludedSnippetComponent(new Element("body").append("<test1></test1>")));
37    }
38   
 
39  2 toggle @Test
40    public void shouldReplaceSnippetByHtml() throws Exception {
41  2 verify((htmlSource) -> {
42  2 try {
43  2 return createParser().parse(config, htmlSource).html();
44    } catch (final IOException e) {
45  0 throw new RuntimeException(e.getMessage(), e);
46    }
47    }, "html");
48    }
49   
 
50  2 toggle @Test
51    public void shouldRenderCard() {
52  2 verify((htmlSource) -> {
53  2 try {
54  2 return createParser().parse(config, htmlSource).html();
55    } catch (final IOException e) {
56  0 throw new RuntimeException(e.getMessage(), e);
57    }
58    }, "html");
59    }
60   
 
61  2 toggle @Test
62    public void shouldRenderDebug() {
63  2 verify((htmlSource) -> {
64  2 try {
65  2 return createParser().parse(config, htmlSource).html();
66    } catch (final IOException e) {
67  0 throw new RuntimeException(e.getMessage(), e);
68    }
69    }, "html");
70    }
71   
 
72  2 toggle @Test
73    public void shouldRenderCardRecursively() {
74  2 verify((htmlSource) -> {
75  2 try {
76  2 return createParser().parse(config, htmlSource).html();
77    } catch (final IOException e) {
78  0 throw new RuntimeException(e.getMessage(), e);
79    }
80    }, "html");
81    }
82   
 
83  2 toggle @Test
84    public void shouldRenderRecursively() {
85  2 verify((htmlSource) -> {
86  2 try {
87  2 return createParser().parse(config, htmlSource).html();
88    } catch (final IOException e) {
89  0 throw new RuntimeException(e.getMessage(), e);
90    }
91    }, "html");
92    }
93   
 
94  2 toggle @Test
95    public void shouldRenderBadge() {
96  2 verify((htmlSource) -> {
97  2 try {
98  2 return createParser().parse(config, htmlSource).html();
99    } catch (final IOException e) {
100  0 throw new RuntimeException(e.getMessage(), e);
101    }
102    }, "html");
103    }
104   
 
105  2 toggle @Test
106    public void shouldRenderLayout() {
107  2 verify((htmlSource) -> {
108  2 try {
109  2 return createParser().parse(config, htmlSource).html();
110    } catch (final IOException e) {
111  0 throw new RuntimeException(e.getMessage(), e);
112    }
113    }, "html");
114    }
115   
 
116  2 toggle @Test
117    public void shouldRenderNestedComponent() {
118  2 verify((htmlSource) -> {
119  2 try {
120  2 return createParser().parse(config, htmlSource).html();
121    } catch (final IOException e) {
122  0 throw new RuntimeException(e.getMessage(), e);
123    }
124    }, "html");
125    }
126   
127    }