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

File SnippetParserTest.java

 

Code metrics

0
35
9
1
117
90
16
0,46
3,89
9
1,78

Classes

Class Line # Actions
SnippetParserTest 23 35 0% 16 7
0.8409090684,1%
 

Contributing tests

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