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

File Xpp3UtilsTest.java

 

Code metrics

6
30
8
1
96
66
11
0,37
3,75
8
1,38

Classes

Class Line # Actions
Xpp3UtilsTest 26 30 0% 11 0
1.0100%
 

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;
17   
18    import static org.hamcrest.MatcherAssert.assertThat;
19   
20    import java.util.List;
21    import org.codehaus.plexus.util.xml.Xpp3Dom;
22    import org.devacfr.testing.jupiter.TestCase;
23    import org.hamcrest.Matchers;
24    import org.junit.jupiter.api.Test;
25   
 
26    public class Xpp3UtilsTest extends TestCase {
27   
 
28  2 toggle @Test
29    public void shouldFirstChildReturnNullWhenParentIsNull() {
30  2 assertNull(Xpp3Utils.getFirstChild(null, "", ""));
31    }
32   
 
33  2 toggle @Test
34    public void shouldChildNodeExist() {
35  2 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
36  2 final Xpp3Dom parent = new Xpp3Dom("parent");
37  2 parent.addChild(new Xpp3Dom("child"));
38  2 parent.addChild(expectedChild);
39   
40  2 assertEquals(expectedChild, Xpp3Utils.getFirstChild(parent, "expected-child", ""));
41    }
42   
 
43  2 toggle @Test
44    public void shouldChildNodeNotExist() {
45  2 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
46  2 final Xpp3Dom parent = new Xpp3Dom("parent");
47  2 parent.addChild(new Xpp3Dom("child"));
48  2 parent.addChild(expectedChild);
49   
50  2 assertNull(Xpp3Utils.getFirstChild(parent, "wrong-child", ""));
51    }
52   
 
53  2 toggle @Test
54    public void shouldChildrenNodesReturnEmptyListWhenParentIsNull() {
55  2 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(null, "");
56  2 assertThat(list, Matchers.empty());
57    }
58   
 
59  2 toggle @Test
60    public void shouldChildrenReturnEmptyListWhenParentIsNull() {
61  2 final List<String> list = Xpp3Utils.getChildren(null);
62  2 assertThat(list, Matchers.empty());
63    }
64   
 
65  2 toggle @Test
66    public void shouldChildrenReturnAllChildrenNodes() {
67  2 final Xpp3Dom parent = new Xpp3Dom("parent");
68  22 for (int i = 0; i < 10; i++) {
69  20 parent.addChild(new Xpp3Dom("child"));
70    }
71   
72  2 final List<String> list = Xpp3Utils.getChildren(parent);
73  2 assertThat(list, Matchers.hasSize(10));
74    }
75   
 
76  2 toggle @Test
77    public void shouldChildrenNodesReturnSpecificChildrenNodes() {
78  2 final Xpp3Dom parent = new Xpp3Dom("parent");
79  22 for (int i = 0; i < 10; i++) {
80  20 parent.addChild(new Xpp3Dom("child"));
81    }
82  22 for (int i = 0; i < 10; i++) {
83  20 parent.addChild(new Xpp3Dom("child-other"));
84    }
85   
86  2 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
87  2 assertThat(list, Matchers.hasSize(10));
88    }
89   
 
90  2 toggle @Test
91    public void shouldChildrenNodesReturnEmptyChildrenNodes() {
92  2 final Xpp3Dom parent = new Xpp3Dom("parent");
93  2 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
94  2 assertThat(list, Matchers.empty());
95    }
96    }