1. Project Clover database mar. avr. 16 2024 08:19:06 CEST
  2. Package org.devacfr.maven.skins.reflow

File Xpp3UtilsTest.java

 

Code metrics

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

Classes

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

Contributing tests

This file is covered by 8 tests. .

Source view

1    /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements. See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership. The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License. You may obtain a copy of the License at
9    *
10    * http://www.apache.org/licenses/LICENSE-2.0
11    *
12    * Unless required by applicable law or agreed to in writing,
13    * software distributed under the License is distributed on an
14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15    * KIND, either express or implied. See the License for the
16    * specific language governing permissions and limitations
17    * under the License.
18    */
19    package org.devacfr.maven.skins.reflow;
20   
21    import java.util.List;
22   
23    import org.codehaus.plexus.util.xml.Xpp3Dom;
24    import org.devacfr.testing.jupiter.TestCase;
25    import org.hamcrest.Matchers;
26    import org.junit.jupiter.api.Test;
27   
28    import static org.hamcrest.MatcherAssert.assertThat;
29   
 
30    public class Xpp3UtilsTest extends TestCase {
31   
 
32  1 toggle @Test
33    public void shouldFirstChildReturnNullWhenParentIsNull() {
34  1 assertNull(Xpp3Utils.getFirstChild(null, "", ""));
35    }
36   
 
37  1 toggle @Test
38    public void shouldChildNodeExist() {
39  1 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
40  1 final Xpp3Dom parent = new Xpp3Dom("parent");
41  1 parent.addChild(new Xpp3Dom("child"));
42  1 parent.addChild(expectedChild);
43   
44  1 assertEquals(expectedChild, Xpp3Utils.getFirstChild(parent, "expected-child", ""));
45    }
46   
 
47  1 toggle @Test
48    public void shouldChildNodeNotExist() {
49  1 final Xpp3Dom expectedChild = new Xpp3Dom("expected-child");
50  1 final Xpp3Dom parent = new Xpp3Dom("parent");
51  1 parent.addChild(new Xpp3Dom("child"));
52  1 parent.addChild(expectedChild);
53   
54  1 assertNull(Xpp3Utils.getFirstChild(parent, "wrong-child", ""));
55    }
56   
 
57  1 toggle @Test
58    public void shouldChildrenNodesReturnEmptyListWhenParentIsNull() {
59  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(null, "");
60  1 assertThat(list, Matchers.empty());
61    }
62   
 
63  1 toggle @Test
64    public void shouldChildrenReturnEmptyListWhenParentIsNull() {
65  1 final List<String> list = Xpp3Utils.getChildren(null);
66  1 assertThat(list, Matchers.empty());
67    }
68   
 
69  1 toggle @Test
70    public void shouldChildrenReturnAllChildrenNodes() {
71  1 final Xpp3Dom parent = new Xpp3Dom("parent");
72  11 for (int i = 0; i < 10; i++) {
73  10 parent.addChild(new Xpp3Dom("child"));
74    }
75   
76  1 final List<String> list = Xpp3Utils.getChildren(parent);
77  1 assertThat(list, Matchers.hasSize(10));
78    }
79   
 
80  1 toggle @Test
81    public void shouldChildrenNodesReturnSpecificChildrenNodes() {
82  1 final Xpp3Dom parent = new Xpp3Dom("parent");
83  11 for (int i = 0; i < 10; i++) {
84  10 parent.addChild(new Xpp3Dom("child"));
85    }
86  11 for (int i = 0; i < 10; i++) {
87  10 parent.addChild(new Xpp3Dom("child-other"));
88    }
89   
90  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
91  1 assertThat(list, Matchers.hasSize(10));
92    }
93   
 
94  1 toggle @Test
95    public void shouldChildrenNodesReturnEmptyChildrenNodes() {
96  1 final Xpp3Dom parent = new Xpp3Dom("parent");
97  1 final List<Xpp3Dom> list = Xpp3Utils.getChildrenNodes(parent, "child");
98  1 assertThat(list, Matchers.empty());
99    }
100    }