KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jeantessier > dependency > TestGraphSummarizer


1 /*
2  * Copyright (c) 2001-2005, Jean Tessier
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Jean Tessier nor the names of his contributors
17  * may be used to endorse or promote products derived from this software
18  * without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */

32
33 package com.jeantessier.dependency;
34
35 import java.io.*;
36 import java.util.*;
37
38 import junit.framework.*;
39
40 import org.apache.log4j.*;
41
42 public class TestGraphSummarizer extends TestCase {
43     private RegularExpressionSelectionCriteria scopeCriteria;
44     private RegularExpressionSelectionCriteria filterCriteria;
45     private NodeFactory factory;
46     
47     private Node a_package;
48     private Node a_A_class;
49     private Node a_A_a_method;
50     private Node a_B_class;
51
52     private Node b_package;
53     private Node b_B_class;
54     private Node b_B_b_method;
55
56     private GraphSummarizer summarizer;
57
58     protected void setUp() throws Exception JavaDoc {
59         Logger.getLogger(getClass()).info("Starting test: " + getName());
60
61         scopeCriteria = new RegularExpressionSelectionCriteria();
62         filterCriteria = new RegularExpressionSelectionCriteria();
63         factory = new NodeFactory();
64
65         a_package = factory.createPackage("a");
66         a_A_class = factory.createClass("a.A");
67         a_A_a_method = factory.createFeature("a.A.a");
68         a_B_class = factory.createClass("a.B");
69         
70         b_package = factory.createPackage("b");
71         b_B_class = factory.createClass("b.B");
72         b_B_b_method = factory.createFeature("b.B.b");
73         
74         summarizer = new GraphSummarizer(scopeCriteria, filterCriteria);
75     }
76
77     protected void tearDown() throws Exception JavaDoc {
78         Logger.getLogger(getClass()).info("End of " + getName());
79     }
80
81     public void testP2PasP2P() {
82         a_package.addDependency(b_package);
83         
84         scopeCriteria.setMatchingClasses(false);
85         scopeCriteria.setMatchingFeatures(false);
86         filterCriteria.setMatchingClasses(false);
87         filterCriteria.setMatchingFeatures(false);
88
89         summarizer.traverseNodes(factory.getPackages().values());
90
91         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
92         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
93         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().isEmpty());
94         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().isEmpty());
95
96         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
97         assertEquals(1, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
98         assertTrue(summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().contains(summarizer.getScopeFactory().createPackage("b")));
99         assertEquals(1, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
100         assertTrue(summarizer.getScopeFactory().createPackage("b").getInboundDependencies().contains(summarizer.getScopeFactory().createPackage("a")));
101         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
102     }
103
104     public void testP2PasC2C() {
105         a_package.addDependency(b_package);
106         
107         scopeCriteria.setMatchingPackages(false);
108         scopeCriteria.setMatchingFeatures(false);
109         filterCriteria.setMatchingPackages(false);
110         filterCriteria.setMatchingFeatures(false);
111
112         summarizer.traverseNodes(factory.getPackages().values());
113
114         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
115         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
116         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
117         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
118         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().isEmpty());
119
120         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
121         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
122         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
123         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
124
125         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
126         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
127         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
128         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
129     }
130
131     public void testP2PasF2F() {
132         a_package.addDependency(b_package);
133         
134         scopeCriteria.setMatchingPackages(false);
135         scopeCriteria.setMatchingClasses(false);
136         filterCriteria.setMatchingPackages(false);
137         filterCriteria.setMatchingClasses(false);
138
139         summarizer.traverseNodes(factory.getPackages().values());
140
141         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
142         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
143         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
144         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
145         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
146         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
147
148         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
149         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
150         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
151         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
152
153         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
154         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
155         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
156         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
157
158         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
159         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
160         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
161         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
162     }
163
164     public void testC2CasP2P() {
165         a_A_class.addDependency(b_B_class);
166         
167         scopeCriteria.setMatchingClasses(false);
168         scopeCriteria.setMatchingFeatures(false);
169         filterCriteria.setMatchingClasses(false);
170         filterCriteria.setMatchingFeatures(false);
171
172         summarizer.traverseNodes(factory.getPackages().values());
173
174         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
175         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
176         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().isEmpty());
177         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
178
179         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
180         assertEquals(1, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
181         assertTrue(summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().contains(summarizer.getScopeFactory().createPackage("b")));
182         assertEquals(1, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
183         assertTrue(summarizer.getScopeFactory().createPackage("b").getInboundDependencies().contains(summarizer.getScopeFactory().createPackage("a")));
184         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
185     }
186
187     public void testC2CasP2CSamePackage() {
188         a_A_class.addDependency(a_B_class);
189         
190         scopeCriteria.setMatchingClasses(false);
191         scopeCriteria.setMatchingFeatures(false);
192         filterCriteria.setMatchingPackages(false);
193         filterCriteria.setMatchingFeatures(false);
194
195         summarizer.traverseNodes(factory.getPackages().values());
196
197         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
198         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
199         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().isEmpty());
200         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
201
202         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
203         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
204         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
205         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
206     }
207
208     public void testC2CasC2C() {
209         a_A_class.addDependency(b_B_class);
210         
211         scopeCriteria.setMatchingPackages(false);
212         scopeCriteria.setMatchingFeatures(false);
213         filterCriteria.setMatchingPackages(false);
214         filterCriteria.setMatchingFeatures(false);
215
216         summarizer.traverseNodes(factory.getPackages().values());
217
218         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
219         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
220         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
221         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
222         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
223
224         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
225         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
226         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
227         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
228
229         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
230         assertEquals(1, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
231         assertTrue(summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().contains(summarizer.getScopeFactory().createClass("b.B")));
232         assertEquals(1, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
233         assertTrue(summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().contains(summarizer.getScopeFactory().createClass("a.A")));
234         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
235     }
236
237     public void testC2CasF2F() {
238         a_A_class.addDependency(b_B_class);
239         
240         scopeCriteria.setMatchingPackages(false);
241         scopeCriteria.setMatchingClasses(false);
242         filterCriteria.setMatchingPackages(false);
243         filterCriteria.setMatchingClasses(false);
244
245         summarizer.traverseNodes(factory.getPackages().values());
246
247         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
248         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
249         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
250         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
251         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
252         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
253
254         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
255         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
256         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
257         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
258
259         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
260         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
261         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
262         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
263
264         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
265         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
266         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
267         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
268     }
269
270     public void testF2FasP2P() {
271         a_A_a_method.addDependency(b_B_b_method);
272         
273         scopeCriteria.setMatchingClasses(false);
274         scopeCriteria.setMatchingFeatures(false);
275         filterCriteria.setMatchingClasses(false);
276         filterCriteria.setMatchingFeatures(false);
277
278         summarizer.traverseNodes(factory.getPackages().values());
279
280         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
281         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
282         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().isEmpty());
283         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
284
285         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
286         assertEquals(1, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
287         assertTrue(summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().contains(summarizer.getScopeFactory().createPackage("b")));
288         assertEquals(1, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
289         assertTrue(summarizer.getScopeFactory().createPackage("b").getInboundDependencies().contains(summarizer.getScopeFactory().createPackage("a")));
290         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
291     }
292
293     public void testF2FasC2C() {
294         a_A_a_method.addDependency(b_B_b_method);
295         
296         scopeCriteria.setMatchingPackages(false);
297         scopeCriteria.setMatchingFeatures(false);
298         filterCriteria.setMatchingPackages(false);
299         filterCriteria.setMatchingFeatures(false);
300
301         summarizer.traverseNodes(factory.getPackages().values());
302
303         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
304         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
305         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
306         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
307         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
308
309         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
310         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
311         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
312         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
313
314         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
315         assertEquals(1, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
316         assertTrue(summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().contains(summarizer.getScopeFactory().createClass("b.B")));
317         assertEquals(1, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
318         assertTrue(summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().contains(summarizer.getScopeFactory().createClass("a.A")));
319         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
320     }
321
322     public void testF2FasF2F() {
323         a_A_a_method.addDependency(b_B_b_method);
324         
325         scopeCriteria.setMatchingPackages(false);
326         scopeCriteria.setMatchingClasses(false);
327         filterCriteria.setMatchingPackages(false);
328         filterCriteria.setMatchingClasses(false);
329
330         summarizer.traverseNodes(factory.getPackages().values());
331
332         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
333         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
334         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
335         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
336         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
337         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
338
339         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
340         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
341         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
342         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
343
344         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
345         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
346         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
347         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
348
349         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
350         assertEquals(1, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
351         assertTrue(summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().contains(summarizer.getScopeFactory().createFeature("b.B.b")));
352         assertEquals(1, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
353         assertTrue(summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().contains(summarizer.getScopeFactory().createFeature("a.A.a")));
354         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
355     }
356
357     public void testF2CasP2P() {
358         a_A_a_method.addDependency(b_B_class);
359         
360         scopeCriteria.setMatchingClasses(false);
361         scopeCriteria.setMatchingFeatures(false);
362         filterCriteria.setMatchingClasses(false);
363         filterCriteria.setMatchingFeatures(false);
364
365         summarizer.traverseNodes(factory.getPackages().values());
366
367         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
368         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
369         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().isEmpty());
370         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
371
372         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
373         assertEquals(1, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
374         assertTrue(summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().contains(summarizer.getScopeFactory().createPackage("b")));
375         assertEquals(1, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
376         assertTrue(summarizer.getScopeFactory().createPackage("b").getInboundDependencies().contains(summarizer.getScopeFactory().createPackage("a")));
377         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
378     }
379
380     public void testF2CasC2C() {
381         a_A_a_method.addDependency(b_B_class);
382         
383         scopeCriteria.setMatchingPackages(false);
384         scopeCriteria.setMatchingFeatures(false);
385         filterCriteria.setMatchingPackages(false);
386         filterCriteria.setMatchingFeatures(false);
387
388         summarizer.traverseNodes(factory.getPackages().values());
389
390         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
391         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
392         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
393         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
394         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().isEmpty());
395
396         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
397         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
398         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
399         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
400
401         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
402         assertEquals(1, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
403         assertTrue(summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().contains(summarizer.getScopeFactory().createClass("b.B")));
404         assertEquals(1, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
405         assertTrue(summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().contains(summarizer.getScopeFactory().createClass("a.A")));
406         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
407     }
408
409     public void testF2CasF2F() {
410         a_A_a_method.addDependency(b_B_class);
411         
412         scopeCriteria.setMatchingPackages(false);
413         scopeCriteria.setMatchingClasses(false);
414         filterCriteria.setMatchingPackages(false);
415         filterCriteria.setMatchingClasses(false);
416
417         summarizer.traverseNodes(factory.getPackages().values());
418
419         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
420         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
421         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
422         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
423         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
424         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
425
426         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
427         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
428         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
429         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
430
431         assertEquals(0, summarizer.getScopeFactory().createClass("a").getInboundDependencies().size());
432         assertEquals(0, summarizer.getScopeFactory().createClass("a").getOutboundDependencies().size());
433         assertEquals(0, summarizer.getScopeFactory().createClass("b").getInboundDependencies().size());
434         assertEquals(0, summarizer.getScopeFactory().createClass("b").getOutboundDependencies().size());
435
436         assertEquals(0, summarizer.getScopeFactory().createFeature("a").getInboundDependencies().size());
437         assertEquals(0, summarizer.getScopeFactory().createFeature("a").getOutboundDependencies().size());
438         assertEquals(0, summarizer.getScopeFactory().createFeature("b").getInboundDependencies().size());
439         assertEquals(0, summarizer.getScopeFactory().createFeature("b").getOutboundDependencies().size());
440     }
441
442     public void testF2FasPCF2PCF() {
443         a_A_a_method.addDependency(b_B_b_method);
444         
445         summarizer.traverseNodes(factory.getPackages().values());
446
447         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
448         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
449         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
450         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
451         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
452         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
453
454         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
455         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
456         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
457         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
458
459         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
460         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
461         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
462         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
463
464         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
465         assertEquals(1, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
466         assertTrue(summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().contains(summarizer.getScopeFactory().createFeature("b.B.b")));
467         assertEquals(1, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
468         assertTrue(summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().contains(summarizer.getScopeFactory().createFeature("a.A.a")));
469         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
470     }
471
472     public void testC2CasPCF2PCF() {
473         a_A_class.addDependency(b_B_class);
474         
475         summarizer.traverseNodes(factory.getPackages().values());
476
477         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
478         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
479         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
480         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
481         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
482         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
483
484         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
485         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
486         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
487         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
488
489         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
490         assertEquals(1, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
491         assertTrue(summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().contains(summarizer.getScopeFactory().createClass("b.B")));
492         assertEquals(1, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
493         assertTrue(summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().contains(summarizer.getScopeFactory().createClass("a.A")));
494         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
495
496         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
497         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
498         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
499         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
500     }
501
502     public void testP2PasPCF2PCF() {
503         a_package.addDependency(b_package);
504         
505         summarizer.traverseNodes(factory.getPackages().values());
506
507         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("a"));
508         assertTrue(summarizer.getScopeFactory().getPackages().keySet().toString(), summarizer.getScopeFactory().getPackages().keySet().contains("b"));
509         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("a.A"));
510         assertTrue(summarizer.getScopeFactory().getClasses().keySet().toString(), summarizer.getScopeFactory().getClasses().keySet().contains("b.B"));
511         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("a.A.a"));
512         assertTrue(summarizer.getScopeFactory().getFeatures().keySet().toString(), summarizer.getScopeFactory().getFeatures().keySet().contains("b.B.b"));
513
514         assertEquals(0, summarizer.getScopeFactory().createPackage("a").getInboundDependencies().size());
515         assertEquals(1, summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().size());
516         assertTrue(summarizer.getScopeFactory().createPackage("a").getOutboundDependencies().contains(summarizer.getScopeFactory().createPackage("b")));
517         assertEquals(1, summarizer.getScopeFactory().createPackage("b").getInboundDependencies().size());
518         assertTrue(summarizer.getScopeFactory().createPackage("b").getInboundDependencies().contains(summarizer.getScopeFactory().createPackage("a")));
519         assertEquals(0, summarizer.getScopeFactory().createPackage("b").getOutboundDependencies().size());
520
521         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getInboundDependencies().size());
522         assertEquals(0, summarizer.getScopeFactory().createClass("a.A").getOutboundDependencies().size());
523         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getInboundDependencies().size());
524         assertEquals(0, summarizer.getScopeFactory().createClass("b.B").getOutboundDependencies().size());
525
526         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getInboundDependencies().size());
527         assertEquals(0, summarizer.getScopeFactory().createFeature("a.A.a").getOutboundDependencies().size());
528         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getInboundDependencies().size());
529         assertEquals(0, summarizer.getScopeFactory().createFeature("b.B.b").getOutboundDependencies().size());
530     }
531 }
532
Popular Tags