1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.component.descriptor

File DefaultComponentDescriptorTest.java

 

Code metrics

0
63
1
5
136
86
1
0.02
63
0.2
1

Classes

Class Line # Actions
DefaultComponentDescriptorTest 33 63 0% 1 0
1.0100%
DefaultComponentDescriptorTest.Role 35 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.OtherRole 39 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.ImplRole 43 0 - 0 0
-1.0 -
DefaultComponentDescriptorTest.ImplOtherRole 47 0 - 0 0
-1.0 -
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.component.descriptor;
21   
22    import org.junit.jupiter.api.Test;
23   
24    import static org.junit.jupiter.api.Assertions.assertEquals;
25    import static org.junit.jupiter.api.Assertions.assertNotEquals;
26   
27    /**
28    * Unit tests for {@link DefaultComponentDescriptor}.
29    *
30    * @version $Id: 5008fa3157b4301f721191736b19d1bc687e038b $
31    * @since 3.3M1
32    */
 
33    public class DefaultComponentDescriptorTest
34    {
 
35    private interface Role
36    {
37    }
38   
 
39    private interface OtherRole
40    {
41    }
42   
 
43    private class ImplRole
44    {
45    }
46   
 
47    private class ImplOtherRole
48    {
49    }
50   
 
51  1 toggle @Test
52    public void equals()
53    {
54  1 DefaultComponentDescriptor cd1 = new DefaultComponentDescriptor();
55  1 cd1.setImplementation(ImplRole.class);
56  1 cd1.setRoleType(Role.class);
57  1 cd1.setRoleHint("hint");
58   
59  1 assertEquals(cd1, cd1);
60   
61  1 DefaultComponentDescriptor cd2 = new DefaultComponentDescriptor();
62  1 cd2.setImplementation(ImplRole.class);
63  1 cd2.setRoleType(Role.class);
64  1 cd2.setRoleHint("hint");
65   
66  1 assertEquals(cd1, cd2);
67   
68  1 DefaultComponentDescriptor cd3 = new DefaultComponentDescriptor();
69  1 cd3.setImplementation(ImplRole.class);
70  1 cd3.setRoleType(OtherRole.class);
71  1 cd3.setRoleHint("hint");
72   
73  1 assertNotEquals(cd1, cd3);
74   
75  1 DefaultComponentDescriptor cd4 = new DefaultComponentDescriptor();
76  1 cd4.setImplementation(ImplOtherRole.class);
77  1 cd4.setRoleType(Role.class);
78  1 cd4.setRoleHint("hint");
79   
80  1 assertNotEquals(cd1, cd4);
81   
82  1 DefaultComponentDescriptor cd5 = new DefaultComponentDescriptor();
83  1 cd5.setImplementation(ImplRole.class);
84  1 cd5.setRoleType(Role.class);
85  1 cd5.setRoleHint("hint");
86  1 cd5.setInstantiationStrategy(ComponentInstantiationStrategy.PER_LOOKUP);
87   
88  1 assertNotEquals(cd1, cd5);
89   
90  1 DefaultComponentDescriptor cd6 = new DefaultComponentDescriptor();
91  1 cd6.setImplementation(ImplRole.class);
92  1 cd6.setRoleType(Role.class);
93  1 cd6.setRoleHint("hint");
94  1 DefaultComponentDependency dep = new DefaultComponentDependency();
95  1 dep.setName("name");
96  1 dep.setRoleType(String.class);
97  1 cd6.addComponentDependency(dep);
98   
99  1 assertNotEquals(cd1, cd6);
100   
101  1 DefaultComponentDescriptor cd7 = new DefaultComponentDescriptor();
102  1 cd7.setImplementation(ImplRole.class);
103  1 cd7.setRoleType(Role.class);
104  1 cd7.setRoleHint("hint");
105  1 DefaultComponentDependency dep2 = new DefaultComponentDependency();
106  1 dep2.setName("name");
107  1 dep2.setRoleType(String.class);
108  1 cd7.addComponentDependency(dep2);
109   
110  1 assertEquals(cd6, cd7);
111   
112  1 DefaultComponentDescriptor cd8 = new DefaultComponentDescriptor();
113  1 cd8.setImplementation(ImplRole.class);
114  1 cd8.setRoleType(Role.class);
115  1 cd8.setRoleHint("hint");
116  1 DefaultComponentDependency dep3 = new DefaultComponentDependency();
117  1 dep3.setName("name");
118  1 dep3.setRoleType(String.class);
119  1 cd8.addComponentDependency(dep3);
120  1 cd8.addComponentDependency(dep3);
121   
122  1 assertNotEquals(cd7, cd8);
123   
124    // Indirectly verify DefaultComponentDependency.equals() when it's not equals
125  1 DefaultComponentDescriptor cd9 = new DefaultComponentDescriptor();
126  1 cd9.setImplementation(ImplRole.class);
127  1 cd9.setRoleType(Role.class);
128  1 cd9.setRoleHint("hint");
129  1 DefaultComponentDependency dep4 = new DefaultComponentDependency();
130  1 dep4.setName("name2");
131  1 dep4.setRoleType(String.class);
132  1 cd9.addComponentDependency(dep4);
133   
134  1 assertNotEquals(cd6, cd9);
135    }
136    }