1. Project Clover database mar. janv. 20 2026 12:32:22 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 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;
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  1 toggle @Test
29    public void shouldFirstChildReturnNullWhenParentIsNull() {
30  1 assertNull(Xpp3Utils.getFirstChild(null, "", ""));
31    }
32   
 
33  1 toggle @Test
34    public void shouldChildNodeExist() {
35  1 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
36  1 final Xpp3Dom parent = new Xpp3Dom("parent");
37  1 parent.addChild(new Xpp3Dom("child"));
38  1 parent.addChild(expectedChild);
39   
40  1 assertEquals(expectedChild, Xpp3Utils.getFirstChild(parent, "expected-child", ""));
41    }
42   
 
43  1 toggle @Test
44    public void shouldChildNodeNotExist() {
45  1 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
46  1 final Xpp3Dom parent = new Xpp3Dom("parent");
47  1 parent.addChild(new Xpp3Dom("child"));
48  1 parent.addChild(expectedChild);
49   
50  1 assertNull(Xpp3Utils.getFirstChild(parent, "wrong-child", ""));
51    }
52   
 
53  1 toggle @Test
54    public void shouldChildrenNodesReturnEmptyListWhenParentIsNull() {
55  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(null, "");
56  1 assertThat(list, Matchers.empty());
57    }
58   
 
59  1 toggle @Test
60    public void shouldChildrenReturnEmptyListWhenParentIsNull() {
61  1 final List<String> list = Xpp3Utils.getChildren(null);
62  1 assertThat(list, Matchers.empty());
63    }
64   
 
65  1 toggle @Test
66    public void shouldChildrenReturnAllChildrenNodes() {
67  1 final Xpp3Dom parent = new Xpp3Dom("parent");
68  11 for (int i = 0; i < 10; i++) {
69  10 parent.addChild(new Xpp3Dom("child"));
70    }
71   
72  1 final List<String> list = Xpp3Utils.getChildren(parent);
73  1 assertThat(list, Matchers.hasSize(10));
74    }
75   
 
76  1 toggle @Test
77    public void shouldChildrenNodesReturnSpecificChildrenNodes() {
78  1 final Xpp3Dom parent = new Xpp3Dom("parent");
79  11 for (int i = 0; i < 10; i++) {
80  10 parent.addChild(new Xpp3Dom("child"));
81    }
82  11 for (int i = 0; i < 10; i++) {
83  10 parent.addChild(new Xpp3Dom("child-other"));
84    }
85   
86  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
87  1 assertThat(list, Matchers.hasSize(10));
88    }
89   
 
90  1 toggle @Test
91    public void shouldChildrenNodesReturnEmptyChildrenNodes() {
92  1 final Xpp3Dom parent = new Xpp3Dom("parent");
93  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
94  1 assertThat(list, Matchers.empty());
95    }
96    }