KickJava   Java API By Example, From Geeks To Geeks.

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


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 junit.framework.*;
36
37 import org.apache.log4j.*;
38
39 public class TestDeletingVisitor extends TestCase {
40     private NodeFactory factory;
41     private DeletingVisitor visitor;
42
43     protected void setUp() throws Exception JavaDoc {
44         super.setUp();
45
46         Logger.getLogger(getClass()).debug("Begin " + getName());
47         
48         factory = new NodeFactory();
49         visitor = new DeletingVisitor(factory);
50     }
51
52     protected void tearDown() throws Exception JavaDoc {
53         Logger.getLogger(getClass()).debug("End " + getName());
54
55         super.tearDown();
56     }
57
58     public void testCreation() {
59         assertSame("factory", factory, visitor.getFactory());
60     }
61     
62     /**
63      * <p>Deleting package really deletes it.</p>
64      *
65      * <pre>
66      * a <-- delete this
67      * </pre>
68      *
69      * <p>becomes:</p>
70      */

71     public void testAcceptEmptyPackage() {
72         PackageNode node = factory.createPackage("a", true);
73         
74         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
75         assertTrue("Missing package value", factory.getPackages().containsValue(node));
76         assertTrue("Package not concrete", node.isConfirmed());
77
78         node.accept(visitor);
79         
80         assertFalse("Did not remove package key", factory.getPackages().containsKey("a"));
81         assertFalse("Did not remove package value", factory.getPackages().containsValue(node));
82         assertFalse("Package is still concrete", node.isConfirmed());
83     }
84
85     /**
86      * <p>Deleting package deletes its classes.</p>
87      *
88      * <pre>
89      * a <-- delete this
90      * +-- A
91      * </pre>
92      *
93      * <p>becomes:</p>
94      */

95     public void testAcceptPackageWithClasses() {
96         ClassNode node = factory.createClass("a.A", true);
97         
98         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
99         assertTrue("Missing package value", factory.getPackages().containsValue(node.getPackageNode()));
100         assertTrue("Package not concrete", node.getPackageNode().isConfirmed());
101         assertTrue("Package node does not contain class node", node.getPackageNode().getClasses().contains(node));
102         
103         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
104         assertTrue("Missing class value", factory.getClasses().containsValue(node));
105         assertTrue("Class not concrete", node.isConfirmed());
106
107         node.getPackageNode().accept(visitor);
108         
109         assertFalse("Did not remove package key", factory.getPackages().containsKey("a"));
110         assertFalse("Did not remove package value", factory.getPackages().containsValue(node.getPackageNode()));
111         assertFalse("Package is still concrete", node.getPackageNode().isConfirmed());
112         assertFalse("Package node still contains class node", node.getPackageNode().getClasses().contains(node));
113
114         assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
115         assertFalse("Did not remove class value", factory.getClasses().containsValue(node));
116         assertFalse("Class is still concrete", node.isConfirmed());
117     }
118
119     /**
120      * <p>Deleting class preserves package and siblings.</p>
121      *
122      * <pre>
123      * a
124      * +-- A <-- delete this
125      * +-- B
126      * </pre>
127      *
128      * <p>becomes:</p>
129      *
130      * <pre>
131      * a
132      * +-- B
133      * </pre>
134      */

135     public void testAcceptEmptyClass() {
136         ClassNode node1 = factory.createClass("a.A", true);
137         ClassNode node2 = factory.createClass("a.B", true);
138         
139         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
140         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getPackageNode()));
141         assertTrue("Package not concrete", node1.getPackageNode().isConfirmed());
142         assertTrue("Package node does not contain class node", node1.getPackageNode().getClasses().contains(node1));
143         assertTrue("Package node does not contain class node", node2.getPackageNode().getClasses().contains(node2));
144         assertSame("Classes have different package", node1.getPackageNode(), node2.getPackageNode());
145         
146         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
147         assertTrue("Missing class value", factory.getClasses().containsValue(node1));
148         assertTrue("Class not concrete", node1.isConfirmed());
149
150         node1.accept(visitor);
151         
152         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
153         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getPackageNode()));
154         assertTrue("Package not concrete", node1.getPackageNode().isConfirmed());
155         assertFalse("Package node still contains class node", node1.getPackageNode().getClasses().contains(node1));
156         assertTrue("Package node does not contain class node", node2.getPackageNode().getClasses().contains(node2));
157         assertSame("Classes have different package", node1.getPackageNode(), node2.getPackageNode());
158
159         assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
160         assertFalse("Did not remove class value", factory.getClasses().containsValue(node1));
161         assertFalse("Class is still concrete", node1.isConfirmed());
162     }
163
164     /**
165      * <p>Deleting single class deletes its package.</p>
166      *
167      * <pre>
168      * a
169      * +-- A <-- delete this
170      * </pre>
171      *
172      * <p>becomes:</p>
173      */

174     public void testAcceptSingleEmptyClass() {
175         ClassNode node = factory.createClass("a.A", true);
176         
177         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
178         assertTrue("Missing package value", factory.getPackages().containsValue(node.getPackageNode()));
179         assertTrue("Package not concrete", node.getPackageNode().isConfirmed());
180         assertTrue("Package node does not contain class node", node.getPackageNode().getClasses().contains(node));
181         
182         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
183         assertTrue("Missing class value", factory.getClasses().containsValue(node));
184         assertTrue("Class not concrete", node.isConfirmed());
185
186         node.accept(visitor);
187         
188         assertFalse("Did not remove package key", factory.getPackages().containsKey("a"));
189         assertFalse("Did not remove package value", factory.getPackages().containsValue(node.getPackageNode()));
190         assertFalse("Package is still concrete", node.getPackageNode().isConfirmed());
191         assertFalse("Package node still contains class node", node.getPackageNode().getClasses().contains(node));
192
193         assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
194         assertFalse("Did not remove class value", factory.getClasses().containsValue(node));
195         assertFalse("Class is still concrete", node.isConfirmed());
196     }
197
198     /**
199      * <p>Deleting class deletes its features and preserves package and siblings.</p>
200      *
201      * <pre>
202      * a
203      * +-- A <-- delete this
204      * | +-- a
205      * +-- B
206      * </pre>
207      *
208      * <p>becomes:</p>
209      *
210      * <pre>
211      * a
212      * +-- B
213      * </pre>
214      */

215     public void testAcceptClassWithFeature() {
216         FeatureNode node1 = factory.createFeature("a.A.a", true);
217         ClassNode node2 = factory.createClass("a.B", true);
218         
219         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
220         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
221         assertTrue("Package not concrete", node1.getClassNode().getPackageNode().isConfirmed());
222         assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
223         assertTrue("Package node does not contain class node", node2.getPackageNode().getClasses().contains(node2));
224
225         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
226         assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
227         assertTrue("Class not concrete", node1.getClassNode().isConfirmed());
228         assertTrue("Class node does not contain feature node", node1.getClassNode().getFeatures().contains(node1));
229         
230         assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
231         assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
232         assertTrue("Feature not concrete", node1.isConfirmed());
233
234         node1.getClassNode().accept(visitor);
235         
236         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
237         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
238         assertTrue("Package not concrete", node1.getClassNode().getPackageNode().isConfirmed());
239         assertFalse("Package node still contains class node", node1.getClassNode().getPackageNode().getClasses().contains(node1));
240         assertTrue("Package node does not contain class node", node2.getPackageNode().getClasses().contains(node2));
241
242         assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
243         assertFalse("Did not remove class value", factory.getClasses().containsValue(node1.getClassNode()));
244         assertFalse("Class is still concrete", node1.getClassNode().isConfirmed());
245         assertFalse("Class node still contains feature node", node1.getClassNode().getFeatures().contains(node1));
246
247         assertFalse("Did not remove feature key", factory.getFeatures().containsKey("a.A.a"));
248         assertFalse("Did not remove feature value", factory.getFeatures().containsValue(node1));
249         assertFalse("Feature is still concrete", node1.isConfirmed());
250     }
251
252     /**
253      * <p>Deleting single class deletes its features and its package.</p>
254      *
255      * <pre>
256      * a
257      * +-- A <-- delete this
258      * +-- a
259      * </pre>
260      *
261      * <p>becomes:</p>
262      */

263     public void testAcceptSingleClassWithFeature() {
264         FeatureNode node1 = factory.createFeature("a.A.a", true);
265         
266         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
267         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
268         assertTrue("Package not concrete", node1.getClassNode().getPackageNode().isConfirmed());
269         assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
270
271         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
272         assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
273         assertTrue("Class not concrete", node1.getClassNode().isConfirmed());
274         assertTrue("Class node does not contain feature node", node1.getClassNode().getFeatures().contains(node1));
275         
276         assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
277         assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
278         assertTrue("Feature not concrete", node1.isConfirmed());
279
280         node1.getClassNode().accept(visitor);
281         
282         assertFalse("Did not remove package key", factory.getPackages().containsKey("a"));
283         assertFalse("Did not remove package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
284         assertFalse("Package is still concrete", node1.getClassNode().getPackageNode().isConfirmed());
285         assertFalse("Package node still contains class node", node1.getClassNode().getPackageNode().getClasses().contains(node1));
286
287         assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
288         assertFalse("Did not remove class value", factory.getClasses().containsValue(node1.getClassNode()));
289         assertFalse("Class is still concrete", node1.getClassNode().isConfirmed());
290         assertFalse("Class node still contains feature node", node1.getClassNode().getFeatures().contains(node1));
291
292         assertFalse("Did not remove feature key", factory.getFeatures().containsKey("a.A.a"));
293         assertFalse("Did not remove feature value", factory.getFeatures().containsValue(node1));
294         assertFalse("Feature is still concrete", node1.isConfirmed());
295     }
296
297     /**
298      * <p>Deleting feature preserves class and siblings.</p>
299      *
300      * <pre>
301      * a
302      * +-- A
303      * +-- a <-- delete this
304      * +-- b
305      * </pre>
306      *
307      * <p>becomes:</p>
308      *
309      * <pre>
310      * a
311      * +-- A
312      * +-- b
313      * </pre>
314      */

315     public void testAcceptEmptyFeature() {
316         FeatureNode node1 = factory.createFeature("a.A.a", true);
317         FeatureNode node2 = factory.createFeature("a.A.b", true);
318         
319         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
320         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
321         assertTrue("Package not concrete", node1.getClassNode().getPackageNode().isConfirmed());
322         assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
323         
324         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
325         assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
326         assertTrue("Class not concrete", node1.getClassNode().isConfirmed());
327         assertTrue("Class node does not contain feature node", node1.getClassNode().getFeatures().contains(node1));
328         assertTrue("Class node does not contain feature node", node2.getClassNode().getFeatures().contains(node2));
329         assertSame("Features have different class", node1.getClassNode(), node2.getClassNode());
330         
331         assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
332         assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
333         assertTrue("Feature not concrete", node1.isConfirmed());
334
335         node1.accept(visitor);
336         
337         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
338         assertTrue("Missing package value", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
339         assertTrue("Package not concrete", node1.getClassNode().getPackageNode().isConfirmed());
340         assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
341
342         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
343         assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
344         assertTrue("Class not concrete", node1.getClassNode().isConfirmed());
345         assertFalse("Class node still contains feature node", node1.getClassNode().getFeatures().contains(node1));
346         assertTrue("Class node does not contain feature node", node2.getClassNode().getFeatures().contains(node2));
347         assertSame("Features have different class", node1.getClassNode(), node2.getClassNode());
348
349         assertFalse("Did not remove feature key", factory.getFeatures().containsKey("a.A.a"));
350         assertFalse("Did not remove feature value", factory.getFeatures().containsValue(node1));
351         assertFalse("Feature is still concrete", node1.isConfirmed());
352     }
353
354     /**
355      * <p>Deleting single feature of single class deletes entire package.</p>
356      *
357      * <pre>
358      * a
359      * +-- A
360      * +-- a <-- delete this
361      * </pre>
362      *
363      * <p>becomes:</p>
364      *
365      * <pre>
366      * a
367      * +-- A
368      * </pre>
369      */

370     public void testAcceptSingleEmptyFeature() {
371         FeatureNode node = factory.createFeature("a.A.a", true);
372         
373         assertTrue("Missing package key", factory.getPackages().containsKey("a"));
374         assertTrue("Missing package value", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
375         assertTrue("Package not concrete", node.getClassNode().getPackageNode().isConfirmed());
376         assertTrue("Package node does not contain class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
377         
378         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
379         assertTrue("Missing class value", factory.getClasses().containsValue(node.getClassNode()));
380         assertTrue("Class not concrete", node.getClassNode().isConfirmed());
381         assertTrue("Class node does not contain feature node", node.getClassNode().getFeatures().contains(node));
382         
383         assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
384         assertTrue("Missing feature value", factory.getFeatures().containsValue(node));
385         assertTrue("Feature not concrete", node.isConfirmed());
386
387         node.accept(visitor);
388         
389         assertTrue("Removed package key", factory.getPackages().containsKey("a"));
390         assertTrue("Removed package value", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
391         assertTrue("Package is no longer concrete", node.getClassNode().getPackageNode().isConfirmed());
392         assertTrue("Package node no longer contains class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
393
394         assertTrue("Removed class key", factory.getClasses().containsKey("a.A"));
395         assertTrue("Removed class value", factory.getClasses().containsValue(node.getClassNode()));
396         assertTrue("Class is no longer concrete", node.getClassNode().isConfirmed());
397         assertFalse("Class node still contains feature node", node.getClassNode().getFeatures().contains(node));
398
399         assertFalse("Did not remove feature key", factory.getFeatures().containsKey("a.A.a"));
400         assertFalse("Did not remove feature value", factory.getFeatures().containsValue(node));
401         assertFalse("Feature is still concrete", node.isConfirmed());
402     }
403
404     /**
405      * <p>Deleting package leaves other concrete packages intact.</p>
406      *
407      * <pre>
408      * a <-- delete this
409      * <-- b
410      * b
411      * --> a
412      * </pre>
413      *
414      * <p>becomes:</p>
415      *
416      * <pre>
417      * b
418      * </pre>
419      */

420     public void testAcceptPackageWithDependencyOnConcretePackage() {
421         PackageNode a = factory.createPackage("a", true);
422         PackageNode b = factory.createPackage("b", true);
423
424         a.addDependency(b);
425
426         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
427         assertTrue("Missing package value a", factory.getPackages().containsValue(a));
428         assertTrue("Package a not concrete", a.isConfirmed());
429         assertTrue("a --> b is missing", a.getOutboundDependencies().contains(b));
430
431         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
432         assertTrue("Missing package value b", factory.getPackages().containsValue(b));
433         assertTrue("Package b not concrete", b.isConfirmed());
434         assertTrue("b <-- a is missing", b.getInboundDependencies().contains(a));
435
436         a.accept(visitor);
437         
438         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
439         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a));
440         assertFalse("Package a is still concrete", a.isConfirmed());
441         assertFalse("Did not remove a --> b", a.getOutboundDependencies().contains(b));
442         
443         assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
444         assertTrue("Removed package value b", factory.getPackages().containsValue(b));
445         assertTrue("Package b is no longer concrete", b.isConfirmed());
446         assertFalse("Did not remove b <-- a", b.getInboundDependencies().contains(a));
447     }
448
449     /**
450      * <p>Deleting package removes obsolete non-concrete packages.</p>
451      *
452      * <pre>
453      * a <-- delete this
454      * <-- b
455      * b
456      * --> a
457      * </pre>
458      *
459      * <p>becomes:</p>
460      */

461     public void testAcceptPackageWithDependencyOnNonConcretePackage() {
462         PackageNode a = factory.createPackage("a", true);
463         PackageNode b = factory.createPackage("b", false);
464
465         a.addDependency(b);
466
467         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
468         assertTrue("Missing package value a", factory.getPackages().containsValue(a));
469         assertTrue("Package a not concrete", a.isConfirmed());
470         assertTrue("a --> b is missing", a.getOutboundDependencies().contains(b));
471
472         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
473         assertTrue("Missing package value b", factory.getPackages().containsValue(b));
474         assertFalse("Package b is concrete", b.isConfirmed());
475         assertTrue("b <-- a is missing", b.getInboundDependencies().contains(a));
476
477         a.accept(visitor);
478         
479         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
480         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a));
481         assertFalse("Package a is still concrete", a.isConfirmed());
482         assertFalse("Did not remove a --> b", a.getOutboundDependencies().contains(b));
483         
484         assertFalse("Did not remove package key b", factory.getPackages().containsKey("b"));
485         assertFalse("Did not remove package value b", factory.getPackages().containsValue(b));
486         assertFalse("Package b became concrete", b.isConfirmed());
487         assertFalse("Did not remove b <-- a", b.getInboundDependencies().contains(a));
488     }
489
490     /**
491      * <p>Deleting class leaves other concrete classes intact.</p>
492      *
493      * <pre>
494      * a
495      * +-- A <-- delete this
496      * <-- b.B
497      * b
498      * +-- B
499      * --> a.A
500      * </pre>
501      *
502      * <p>becomes:</p>
503      *
504      * <pre>
505      * b
506      * +-- B
507      * </pre>
508      */

509     public void testAcceptClassWithDependencyOnConcreteClass() {
510         ClassNode a_A = factory.createClass("a.A", true);
511         ClassNode b_B = factory.createClass("b.B", true);
512
513         a_A.addDependency(b_B);
514
515         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
516         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A.getPackageNode()));
517         assertTrue("Package a not concrete", a_A.getPackageNode().isConfirmed());
518         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
519         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A));
520         assertTrue("Class a.A not concrete", a_A.isConfirmed());
521         assertTrue("a.A --> b.B is missing", a_A.getOutboundDependencies().contains(b_B));
522
523         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
524         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B.getPackageNode()));
525         assertTrue("Package b not concrete", b_B.getPackageNode().isConfirmed());
526         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
527         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B));
528         assertTrue("Class b.B not concrete", b_B.isConfirmed());
529         assertTrue("b.B <-- a.A is missing", b_B.getInboundDependencies().contains(a_A));
530
531         a_A.accept(visitor);
532         
533         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
534         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a_A.getPackageNode()));
535         assertFalse("Package a is still concrete", a_A.getPackageNode().isConfirmed());
536         assertFalse("Did not remove class key a.A", factory.getClasses().containsKey("a.A"));
537         assertFalse("Did not remove class value a.A", factory.getClasses().containsValue(a_A));
538         assertFalse("Class a.A is still concrete", a_A.isConfirmed());
539         assertFalse("Did not remove a.A --> b.B", a_A.getOutboundDependencies().contains(b_B));
540         
541         assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
542         assertTrue("Removed package value b", factory.getPackages().containsValue(b_B.getPackageNode()));
543         assertTrue("Package b is no longer concrete", b_B.isConfirmed());
544         assertTrue("Removed class key b.B", factory.getClasses().containsKey("b.B"));
545         assertTrue("Removed class value b.B", factory.getClasses().containsValue(b_B));
546         assertTrue("Class b.B is no longer concrete", b_B.isConfirmed());
547         assertFalse("Did not remove b.B <-- a.A", b_B.getInboundDependencies().contains(a_A));
548     }
549
550     /**
551      * <p>Deleting class removes other obsolete classes.</p>
552      *
553      * <pre>
554      * a
555      * +-- A <-- delete this
556      * <-- b.B
557      * b
558      * +-- B
559      * --> a.A
560      * </pre>
561      *
562      * <p>becomes:</p>
563      */

564     public void testAcceptClassWithDependencyOnReferencedClass() {
565         ClassNode a_A = factory.createClass("a.A", true);
566         ClassNode b_B = factory.createClass("b.B", false);
567
568         a_A.addDependency(b_B);
569
570         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
571         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A.getPackageNode()));
572         assertTrue("Package a not concrete", a_A.getPackageNode().isConfirmed());
573         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
574         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A));
575         assertTrue("Class a.A not concrete", a_A.isConfirmed());
576         assertTrue("a.A --> b.B is missing", a_A.getOutboundDependencies().contains(b_B));
577
578         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
579         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B.getPackageNode()));
580         assertFalse("Package b is concrete", b_B.getPackageNode().isConfirmed());
581         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
582         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B));
583         assertFalse("Class b.B is concrete", b_B.isConfirmed());
584         assertTrue("b.B <-- a.A is missing", b_B.getInboundDependencies().contains(a_A));
585
586         a_A.accept(visitor);
587         
588         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
589         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a_A.getPackageNode()));
590         assertFalse("Package a is still concrete", a_A.getPackageNode().isConfirmed());
591         assertFalse("Did not remove class key a.A", factory.getClasses().containsKey("a.A"));
592         assertFalse("Did not remove class value a.A", factory.getClasses().containsValue(a_A));
593         assertFalse("Class a.A is still concrete", a_A.isConfirmed());
594         assertFalse("Did not remove a.A --> b.B", a_A.getOutboundDependencies().contains(b_B));
595         
596         assertFalse("Did not remove package key b", factory.getPackages().containsKey("b"));
597         assertFalse("Did not remove package value b", factory.getPackages().containsValue(b_B.getPackageNode()));
598         assertFalse("Package b is now concrete", b_B.getPackageNode().isConfirmed());
599         assertFalse("Did not remove class key b.B", factory.getClasses().containsKey("b.B"));
600         assertFalse("Did not remove class value b.B", factory.getClasses().containsValue(b_B));
601         assertFalse("Class b.B is now concrete", b_B.isConfirmed());
602         assertFalse("Did not remove b.B <-- a.A", b_B.getInboundDependencies().contains(a_A));
603     }
604
605     /**
606      * <p>Deleting class leaves other concrete features intact.</p>
607      *
608      * <pre>
609      * a
610      * +-- A <-- delete this
611      * +-- a
612      * <-- b.B.b
613      * b
614      * +-- B
615      * +-- b
616      * --> a.A.a
617      * </pre>
618      *
619      * <p>becomes:</p>
620      *
621      * <pre>
622      * b
623      * +-- B
624      * +-- b
625      * </pre>
626      */

627     public void testAcceptClassWithFeatureWithDependencyOnConcreteFeature() {
628         FeatureNode a_A_a = factory.createFeature("a.A.a", true);
629         FeatureNode b_B_b = factory.createFeature("b.B.b", true);
630
631         a_A_a.addDependency(b_B_b);
632
633         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
634         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
635         assertTrue("Package a not concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
636         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
637         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
638         assertTrue("Class a.A not concrete", a_A_a.getClassNode().isConfirmed());
639         assertTrue("Missing feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
640         assertTrue("Missing feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
641         assertTrue("Feature a.A.a not concrete", a_A_a.isConfirmed());
642         assertTrue("a.A.a --> b.B.b is missing", a_A_a.getOutboundDependencies().contains(b_B_b));
643
644         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
645         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
646         assertTrue("Package b not concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
647         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
648         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
649         assertTrue("Class b.B not concrete", b_B_b.getClassNode().isConfirmed());
650         assertTrue("Missing feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
651         assertTrue("Missing feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
652         assertTrue("Feature b.B.b not concrete", b_B_b.isConfirmed());
653         assertTrue("b.B <-- a.A is missing", b_B_b.getInboundDependencies().contains(a_A_a));
654
655         a_A_a.getClassNode().accept(visitor);
656         
657         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
658         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
659         assertFalse("Package a is still concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
660         assertFalse("Did not remove class key a.A", factory.getClasses().containsKey("a.A"));
661         assertFalse("Did not remove class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
662         assertFalse("Class a.A is still concrete", a_A_a.getClassNode().isConfirmed());
663         assertFalse("Did not remove feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
664         assertFalse("Did not remove feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
665         assertFalse("Feature a.A.a is still concrete", a_A_a.isConfirmed());
666         assertFalse("Did not remove a.A --> b.B", a_A_a.getOutboundDependencies().contains(b_B_b));
667         
668         assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
669         assertTrue("Removed package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
670         assertTrue("Package b is no longer concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
671         assertTrue("Removed class key b.B", factory.getClasses().containsKey("b.B"));
672         assertTrue("Removed class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
673         assertTrue("Class b.B is no longer concrete", b_B_b.getClassNode().isConfirmed());
674         assertTrue("Removed feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
675         assertTrue("Removed feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
676         assertTrue("Feature b.B.b is no longer concrete", b_B_b.isConfirmed());
677         assertFalse("Did not remove b.B <-- a.A", b_B_b.getInboundDependencies().contains(a_A_a));
678     }
679
680     /**
681      * <p>Deleting feature leaves other concrete features intact.</p>
682      *
683      * <pre>
684      * a
685      * +-- A
686      * +-- a <-- delete this
687      * <-- b.B.b
688      * b
689      * +-- B
690      * +-- b
691      * --> a.A.a
692      * </pre>
693      *
694      * <p>becomes:</p>
695      *
696      * <pre>
697      * a
698      * +-- A
699      *
700      * b
701      * +-- B
702      * +-- b
703      * </pre>
704      */

705     public void testAcceptFeatureWithDependencyOnConcreteFeature() {
706         FeatureNode a_A_a = factory.createFeature("a.A.a", true);
707         FeatureNode b_B_b = factory.createFeature("b.B.b", true);
708
709         a_A_a.addDependency(b_B_b);
710
711         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
712         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
713         assertTrue("Package a not concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
714         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
715         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
716         assertTrue("Class a.A not concrete", a_A_a.getClassNode().isConfirmed());
717         assertTrue("Missing feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
718         assertTrue("Missing feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
719         assertTrue("Feature a.A.a not concrete", a_A_a.isConfirmed());
720         assertTrue("a.A.a --> b.B.b is missing", a_A_a.getOutboundDependencies().contains(b_B_b));
721
722         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
723         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
724         assertTrue("Package b not concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
725         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
726         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
727         assertTrue("Class b.B not concrete", b_B_b.getClassNode().isConfirmed());
728         assertTrue("Missing feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
729         assertTrue("Missing feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
730         assertTrue("Feature b.B.b not concrete", b_B_b.isConfirmed());
731         assertTrue("b.B <-- a.A is missing", b_B_b.getInboundDependencies().contains(a_A_a));
732
733         a_A_a.accept(visitor);
734         
735         assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
736         assertTrue("Removed package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
737         assertTrue("Package a is no longer concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
738         assertTrue("Removed class key a.A", factory.getClasses().containsKey("a.A"));
739         assertTrue("Removed class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
740         assertTrue("Class a.A is no longer concrete", a_A_a.getClassNode().isConfirmed());
741         assertFalse("Did not remove feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
742         assertFalse("Did not remove feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
743         assertFalse("Feature a.A.a is still concrete", a_A_a.isConfirmed());
744         assertFalse("Did not remove a.A --> b.B", a_A_a.getOutboundDependencies().contains(b_B_b));
745         
746         assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
747         assertTrue("Removed package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
748         assertTrue("Package b is no longer concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
749         assertTrue("Removed class key b.B", factory.getClasses().containsKey("b.B"));
750         assertTrue("Removed class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
751         assertTrue("Class b.B is no longer concrete", b_B_b.getClassNode().isConfirmed());
752         assertTrue("Removed feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
753         assertTrue("Removed feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
754         assertTrue("Feature b.B.b is no longer concrete", b_B_b.isConfirmed());
755         assertFalse("Did not remove b.B <-- a.A", b_B_b.getInboundDependencies().contains(a_A_a));
756     }
757
758     /**
759      * <p>Deleting class removes obsolete features.</p>
760      *
761      * <pre>
762      * a
763      * +-- A <-- delete this
764      * +-- a
765      * <-- b.B.b
766      * b
767      * +-- B
768      * +-- b
769      * --> a.A.a
770      * </pre>
771      *
772      * <p>becomes:</p>
773      */

774     public void testAcceptClassWithFeatureWithDependencyOnReferencedFeature() {
775         FeatureNode a_A_a = factory.createFeature("a.A.a", true);
776         FeatureNode b_B_b = factory.createFeature("b.B.b", false);
777
778         a_A_a.addDependency(b_B_b);
779
780         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
781         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
782         assertTrue("Package a not concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
783         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
784         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
785         assertTrue("Class a.A not concrete", a_A_a.getClassNode().isConfirmed());
786         assertTrue("Missing feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
787         assertTrue("Missing feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
788         assertTrue("Feature a.A.a not concrete", a_A_a.isConfirmed());
789         assertTrue("a.A.a --> b.B.b is missing", a_A_a.getOutboundDependencies().contains(b_B_b));
790
791         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
792         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
793         assertFalse("Package b is concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
794         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
795         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
796         assertFalse("Class b.B is concrete", b_B_b.getClassNode().isConfirmed());
797         assertTrue("Missing feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
798         assertTrue("Missing feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
799         assertFalse("Feature b.B.b is concrete", b_B_b.isConfirmed());
800         assertTrue("b.B <-- a.A is missing", b_B_b.getInboundDependencies().contains(a_A_a));
801
802         a_A_a.getClassNode().accept(visitor);
803         
804         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
805         assertFalse("Did not remove package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
806         assertFalse("Package a is still concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
807         assertFalse("Did not remove class key a.A", factory.getClasses().containsKey("a.A"));
808         assertFalse("Did not remove class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
809         assertFalse("Class a.A is still concrete", a_A_a.getClassNode().isConfirmed());
810         assertFalse("Did not remove feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
811         assertFalse("Did not remove feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
812         assertFalse("Feature a.A.a is still concrete", a_A_a.isConfirmed());
813         assertFalse("Did not remove a.A --> b.B", a_A_a.getOutboundDependencies().contains(b_B_b));
814         
815         assertFalse("Did not remove package key b", factory.getPackages().containsKey("b"));
816         assertFalse("Did not remove package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
817         assertFalse("Package b is now concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
818         assertFalse("Did not remove class key b.B", factory.getClasses().containsKey("b.B"));
819         assertFalse("Did not remove class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
820         assertFalse("Class b.B is now concrete", b_B_b.getClassNode().isConfirmed());
821         assertFalse("Did not remove feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
822         assertFalse("Did not remove feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
823         assertFalse("Feature b.B.b is now concrete", b_B_b.isConfirmed());
824         assertFalse("Did not remove b.B <-- a.A", b_B_b.getInboundDependencies().contains(a_A_a));
825     }
826
827     /**
828      * <p>Deleting feature removes obsolete features.</p>
829      *
830      * <pre>
831      * a
832      * +-- A
833      * +-- a <-- delete this
834      * <-- b.B.b
835      * b
836      * +-- B
837      * +-- b
838      * --> a.A.a
839      * </pre>
840      *
841      * <p>becomes:</p>
842      *
843      * <pre>
844      * a
845      * +-- A
846      * </pre>
847      */

848     public void testAcceptFeatureWithDependencyOnReferencedFeature() {
849         FeatureNode a_A_a = factory.createFeature("a.A.a", true);
850         FeatureNode b_B_b = factory.createFeature("b.B.b", false);
851
852         a_A_a.addDependency(b_B_b);
853
854         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
855         assertTrue("Missing package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
856         assertTrue("Package a not concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
857         assertTrue("Missing class key a.A", factory.getClasses().containsKey("a.A"));
858         assertTrue("Missing class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
859         assertTrue("Class a.A not concrete", a_A_a.getClassNode().isConfirmed());
860         assertTrue("Missing feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
861         assertTrue("Missing feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
862         assertTrue("Feature a.A.a not concrete", a_A_a.isConfirmed());
863         assertTrue("a.A.a --> b.B.b is missing", a_A_a.getOutboundDependencies().contains(b_B_b));
864
865         assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
866         assertTrue("Missing package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
867         assertFalse("Package b is concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
868         assertTrue("Missing class key b.B", factory.getClasses().containsKey("b.B"));
869         assertTrue("Missing class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
870         assertFalse("Class b.B is concrete", b_B_b.getClassNode().isConfirmed());
871         assertTrue("Missing feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
872         assertTrue("Missing feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
873         assertFalse("Feature b.B.b is concrete", b_B_b.isConfirmed());
874         assertTrue("b.B <-- a.A is missing", b_B_b.getInboundDependencies().contains(a_A_a));
875
876         a_A_a.accept(visitor);
877         
878         assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
879         assertTrue("Removed package value a", factory.getPackages().containsValue(a_A_a.getClassNode().getPackageNode()));
880         assertTrue("Package a is no longer concrete", a_A_a.getClassNode().getPackageNode().isConfirmed());
881         assertTrue("Removed class key a.A", factory.getClasses().containsKey("a.A"));
882         assertTrue("Removed class value a.A", factory.getClasses().containsValue(a_A_a.getClassNode()));
883         assertTrue("Class a.A is no longer concrete", a_A_a.getClassNode().isConfirmed());
884         assertFalse("Did not remove feature key a.A.a", factory.getFeatures().containsKey("a.A.a"));
885         assertFalse("Did not remove feature value a.A.a", factory.getFeatures().containsValue(a_A_a));
886         assertFalse("Feature a.A.a is still concrete", a_A_a.isConfirmed());
887         assertFalse("Did not remove a.A --> b.B", a_A_a.getOutboundDependencies().contains(b_B_b));
888         
889         assertFalse("Did not remove package key b", factory.getPackages().containsKey("b"));
890         assertFalse("Did not remove package value b", factory.getPackages().containsValue(b_B_b.getClassNode().getPackageNode()));
891         assertFalse("Package b is now concrete", b_B_b.getClassNode().getPackageNode().isConfirmed());
892         assertFalse("Did not remove class key b.B", factory.getClasses().containsKey("b.B"));
893         assertFalse("Did not remove class value b.B", factory.getClasses().containsValue(b_B_b.getClassNode()));
894         assertFalse("Class b.B is now concrete", b_B_b.getClassNode().isConfirmed());
895         assertFalse("Did not remove feature key b.B.b", factory.getFeatures().containsKey("b.B.b"));
896         assertFalse("Did not remove feature value b.B.b", factory.getFeatures().containsValue(b_B_b));
897         assertFalse("Feature b.B.b is now concrete", b_B_b.isConfirmed());
898         assertFalse("Did not remove b.B <-- a.A", b_B_b.getInboundDependencies().contains(a_A_a));
899     }
900
901     public void testAcceptOutboundConcretePackage() {
902         PackageNode node = factory.createPackage("a", true);
903
904         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
905         assertTrue("Missing package value a", factory.getPackages().containsValue(node));
906         assertTrue("Package a not concrete", node.isConfirmed());
907
908         node.acceptOutbound(visitor);
909         
910         assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
911         assertTrue("Removed package value a", factory.getPackages().containsValue(node));
912         assertTrue("Package a is no longer concrete", node.isConfirmed());
913     }
914
915     public void testAcceptOutboundConcreteClass() {
916         ClassNode node = factory.createClass("a.A", true);
917
918         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
919         assertTrue("Missing package value a", factory.getPackages().containsValue(node.getPackageNode()));
920         assertTrue("Package a not concrete", node.getPackageNode().isConfirmed());
921         assertTrue("Package node does not contain class node", node.getPackageNode().getClasses().contains(node));
922         
923         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
924         assertTrue("Missing class value", factory.getClasses().containsValue(node));
925         assertTrue("Class not concrete", node.isConfirmed());
926
927         node.acceptOutbound(visitor);
928         
929         assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
930         assertTrue("Removed package value a", factory.getPackages().containsValue(node.getPackageNode()));
931         assertTrue("Package a is no longer concrete", node.getPackageNode().isConfirmed());
932         assertTrue("Package node no longer contains class node", node.getPackageNode().getClasses().contains(node));
933         
934         assertTrue("Removed class key", factory.getClasses().containsKey("a.A"));
935         assertTrue("Removed class value", factory.getClasses().containsValue(node));
936         assertTrue("Class a.A is no longer concrete", node.isConfirmed());
937     }
938
939     public void testAcceptOutboundConcreteFeature() {
940         FeatureNode node = factory.createFeature("a.A.a", true);
941
942         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
943         assertTrue("Missing package value a", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
944         assertTrue("Package a not concrete", node.getClassNode().getPackageNode().isConfirmed());
945         assertTrue("Package node does not contain class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
946         
947         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
948         assertTrue("Missing class value", factory.getClasses().containsValue(node.getClassNode()));
949         assertTrue("Class not concrete", node.getClassNode().isConfirmed());
950         assertTrue("Class node does not contain feature node", node.getClassNode().getFeatures().contains(node));
951         
952         assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
953         assertTrue("Missing feature value", factory.getFeatures().containsValue(node));
954         assertTrue("Feature not concrete", node.isConfirmed());
955
956         node.acceptOutbound(visitor);
957         
958         assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
959         assertTrue("Removed package value a", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
960         assertTrue("Package a is no longer concrete", node.getClassNode().getPackageNode().isConfirmed());
961         assertTrue("Package node no longer contains class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
962         
963         assertTrue("Removed class key", factory.getClasses().containsKey("a.A"));
964         assertTrue("Removed class value", factory.getClasses().containsValue(node.getClassNode()));
965         assertTrue("Class a.A is no longer concrete", node.getClassNode().isConfirmed());
966         assertTrue("Class node no longer contains feature node", node.getClassNode().getFeatures().contains(node));
967         
968         assertTrue("Removed feature key", factory.getFeatures().containsKey("a.A.a"));
969         assertTrue("Removed feature value", factory.getFeatures().containsValue(node));
970         assertTrue("Feature a.A.a is no longer concrete", node.isConfirmed());
971     }
972
973     public void testAcceptOutboundEmptyNonConcretePackage() {
974         PackageNode node = factory.createPackage("a", false);
975
976         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
977         assertTrue("Missing package value a", factory.getPackages().containsValue(node));
978         assertFalse("Package a concrete", node.isConfirmed());
979
980         node.acceptOutbound(visitor);
981         
982         assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
983         assertFalse("Did not remove package value a", factory.getPackages().containsValue(node));
984         assertFalse("Package a is now concrete", node.isConfirmed());
985     }
986
987     public void testAcceptOutboundEmptyNonConcreteClass() {
988         ClassNode node = factory.createClass("a.A", false);
989
990         assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
991         assertTrue("Missing package value a", factory.getPackages().containsValue(node.getPackageNode()));
992         assertFalse("Package a is concrete", node.getPackageNode().isConfirmed());
993         assertTrue("Package node does not contain class node", node.getPackageNode().getClasses().contains(node));
994         
995         assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
996         assertTrue("Missing class value", factory.getClasses().containsValue(node));
997         assertFalse("Class a.A is concrete", node.isConfirmed());
998
999         node.acceptOutbound(visitor);
1000        
1001        assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
1002        assertFalse("Did not remove package value a", factory.getPackages().containsValue(node.getPackageNode()));
1003        assertFalse("Package a is now concrete", node.getPackageNode().isConfirmed());
1004        assertFalse("Package node still contains class node", node.getPackageNode().getClasses().contains(node));
1005        
1006        assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
1007        assertFalse("Did not remove class value", factory.getClasses().containsValue(node));
1008        assertFalse("Class a.A is now concrete", node.isConfirmed());
1009    }
1010
1011    public void testAcceptOutboundEmptyNonConcreteFeature() {
1012        FeatureNode node = factory.createFeature("a.A.a", false);
1013
1014        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1015        assertTrue("Missing package value a", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
1016        assertFalse("Package a is concrete", node.getClassNode().getPackageNode().isConfirmed());
1017        assertTrue("Package node does not contain class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
1018        
1019        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1020        assertTrue("Missing class value", factory.getClasses().containsValue(node.getClassNode()));
1021        assertFalse("Class a.A is concrete", node.getClassNode().isConfirmed());
1022        assertTrue("Class node does not contain feature node", node.getClassNode().getFeatures().contains(node));
1023        
1024        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
1025        assertTrue("Missing feature value", factory.getFeatures().containsValue(node));
1026        assertFalse("Feature a.A.a is concrete", node.isConfirmed());
1027
1028        node.acceptOutbound(visitor);
1029        
1030        assertFalse("Did not remove package key a", factory.getPackages().containsKey("a"));
1031        assertFalse("Did not remove package value a", factory.getPackages().containsValue(node.getClassNode().getPackageNode()));
1032        assertFalse("Package a is now concrete", node.getClassNode().getPackageNode().isConfirmed());
1033        assertFalse("Package node still contains class node", node.getClassNode().getPackageNode().getClasses().contains(node.getClassNode()));
1034        
1035        assertFalse("Did not remove class key", factory.getClasses().containsKey("a.A"));
1036        assertFalse("Did not remove class value", factory.getClasses().containsValue(node.getClassNode()));
1037        assertFalse("Class a.A is now concrete", node.getClassNode().isConfirmed());
1038        assertFalse("Class node still contains feature node", node.getClassNode().getFeatures().contains(node));
1039        
1040        assertFalse("Did not remove feature key", factory.getFeatures().containsKey("a.A.a"));
1041        assertFalse("Did not remove feature value", factory.getFeatures().containsValue(node));
1042        assertFalse("Feature a.A.a is now concrete", node.isConfirmed());
1043    }
1044
1045    public void testAcceptOutboundEmptyNonConcretePackageWithInboundDependency() {
1046        PackageNode node1 = factory.createPackage("a", true);
1047        PackageNode node2 = factory.createPackage("b", false);
1048
1049        node1.addDependency(node2);
1050        
1051        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1052        assertTrue("Missing package value a", factory.getPackages().containsValue(node1));
1053        assertTrue("Package a is not concrete", node1.isConfirmed());
1054        assertTrue("a --> b is missing", node1.getOutboundDependencies().contains(node2));
1055        
1056        assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
1057        assertTrue("Missing package value b", factory.getPackages().containsValue(node2));
1058        assertFalse("Package b is concrete", node2.isConfirmed());
1059        assertTrue("b <-- a is missing", node2.getInboundDependencies().contains(node1));
1060
1061        node2.acceptOutbound(visitor);
1062        
1063        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1064        assertTrue("Removed package value a", factory.getPackages().containsValue(node1));
1065        assertTrue("Package a is no longer concrete", node1.isConfirmed());
1066        assertTrue("Removed a --> b", node1.getOutboundDependencies().contains(node2));
1067
1068        assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
1069        assertTrue("Removed package value b", factory.getPackages().containsValue(node2));
1070        assertFalse("Package b is now concrete", node2.isConfirmed());
1071        assertTrue("Removed b <-- a", node2.getInboundDependencies().contains(node1));
1072    }
1073
1074    public void testAcceptOutboundEmptyNonConcreteClassWithInboundDependency() {
1075        ClassNode node1 = factory.createClass("a.A", true);
1076        ClassNode node2 = factory.createClass("a.B", false);
1077
1078        node1.addDependency(node2);
1079
1080        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1081        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1082        assertTrue("Package a is not concrete", node1.getPackageNode().isConfirmed());
1083        assertTrue("Package node does not contain class node a.A", node1.getPackageNode().getClasses().contains(node1));
1084        assertTrue("Package node does not contain class node a.B", node2.getPackageNode().getClasses().contains(node2));
1085
1086        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1087        assertTrue("Missing class value", factory.getClasses().containsValue(node1));
1088        assertTrue("Class a.A is not concrete", node1.isConfirmed());
1089        assertTrue("a.A --> a.B is missing", node1.getOutboundDependencies().contains(node2));
1090
1091        assertTrue("Missing class key", factory.getClasses().containsKey("a.B"));
1092        assertTrue("Missing class value", factory.getClasses().containsValue(node2));
1093        assertFalse("Class a.B is concrete", node2.isConfirmed());
1094        assertTrue("a.B <-- a.A is missing", node2.getInboundDependencies().contains(node1));
1095
1096        node2.acceptOutbound(visitor);
1097        
1098        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1099        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1100        assertTrue("Package a is no longer concrete", node1.getPackageNode().isConfirmed());
1101        assertTrue("Package node no longer contains class node a.A", node1.getPackageNode().getClasses().contains(node1));
1102        assertTrue("Package node no longer contains class node a.B", node2.getPackageNode().getClasses().contains(node2));
1103
1104        assertTrue("Removed class key a.A", factory.getClasses().containsKey("a.A"));
1105        assertTrue("Removed class value a.A", factory.getClasses().containsValue(node1));
1106        assertTrue("Class a.A is no longer concrete", node1.isConfirmed());
1107        assertTrue("Removed a.A --> a.B", node1.getOutboundDependencies().contains(node2));
1108
1109        assertTrue("Removed class key a.B", factory.getClasses().containsKey("a.B"));
1110        assertTrue("Removed class value a.B", factory.getClasses().containsValue(node2));
1111        assertFalse("Class a.B is now concrete", node2.isConfirmed());
1112        assertTrue("Removed a.B <-- a.A", node2.getInboundDependencies().contains(node1));
1113    }
1114
1115    public void testAcceptOutboundEmptyNonConcreteFeatureWithInboundDependency() {
1116        FeatureNode node1 = factory.createFeature("a.A.a", true);
1117        FeatureNode node2 = factory.createFeature("a.A.b", false);
1118
1119        node1.addDependency(node2);
1120
1121        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1122        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1123        assertTrue("Package a is not concrete", node1.getClassNode().getPackageNode().isConfirmed());
1124        assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1125        
1126        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1127        assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
1128        assertTrue("Class a.A is not concrete", node1.getClassNode().isConfirmed());
1129        assertTrue("Class node does not contain feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1130        assertTrue("Class node does not contain feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1131        
1132        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
1133        assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
1134        assertTrue("Feature a.A.a is not concrete", node1.isConfirmed());
1135        assertTrue("a.A.a --> a.A.b is missing", node1.getOutboundDependencies().contains(node2));
1136        
1137        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.b"));
1138        assertTrue("Missing feature value", factory.getFeatures().containsValue(node2));
1139        assertFalse("Feature a.A.b is concrete", node2.isConfirmed());
1140        assertTrue("a.A.b <-- a.A.a is missing", node2.getInboundDependencies().contains(node1));
1141
1142        node2.acceptOutbound(visitor);
1143        
1144        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1145        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1146        assertTrue("Package a is no longer concrete", node1.getClassNode().getPackageNode().isConfirmed());
1147        assertTrue("Package node no longer contains class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1148        
1149        assertTrue("Did not remove class key", factory.getClasses().containsKey("a.A"));
1150        assertTrue("Did not remove class value", factory.getClasses().containsValue(node1.getClassNode()));
1151        assertTrue("Class a.A is no longer concrete", node1.getClassNode().isConfirmed());
1152        assertTrue("Class node no longer contains feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1153        assertTrue("Class node no longer contains feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1154        
1155        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.a"));
1156        assertTrue("Remove feature value", factory.getFeatures().containsValue(node1));
1157        assertTrue("Feature a.A.a is no longer concrete", node1.isConfirmed());
1158        assertTrue("Removed a.A.a --> a.A.b", node1.getOutboundDependencies().contains(node2));
1159        
1160        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.b"));
1161        assertTrue("Remove feature value", factory.getFeatures().containsValue(node2));
1162        assertFalse("Feature a.A.b is now concrete", node2.isConfirmed());
1163        assertTrue("Removed a.A.b <-- a.A.a", node2.getInboundDependencies().contains(node1));
1164    }
1165
1166    public void testAcceptEmptyNonConcretePackageWithInboundDependency() {
1167        PackageNode node1 = factory.createPackage("a", true);
1168        PackageNode node2 = factory.createPackage("b", false);
1169
1170        node1.addDependency(node2);
1171        
1172        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1173        assertTrue("Missing package value a", factory.getPackages().containsValue(node1));
1174        assertTrue("Package a is not concrete", node1.isConfirmed());
1175        assertTrue("a --> b is missing", node1.getOutboundDependencies().contains(node2));
1176        
1177        assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
1178        assertTrue("Missing package value b", factory.getPackages().containsValue(node2));
1179        assertFalse("Package b is concrete", node2.isConfirmed());
1180        assertTrue("b <-- a is missing", node2.getInboundDependencies().contains(node1));
1181
1182        node2.accept(visitor);
1183        
1184        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1185        assertTrue("Removed package value a", factory.getPackages().containsValue(node1));
1186        assertTrue("Package a is no longer concrete", node1.isConfirmed());
1187        assertTrue("Removed a --> b", node1.getOutboundDependencies().contains(node2));
1188
1189        assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
1190        assertTrue("Removed package value b", factory.getPackages().containsValue(node2));
1191        assertFalse("Package b is now concrete", node2.isConfirmed());
1192        assertTrue("Removed b <-- a", node2.getInboundDependencies().contains(node1));
1193    }
1194
1195    public void testAcceptEmptyNonConcreteClassWithInboundDependency() {
1196        ClassNode node1 = factory.createClass("a.A", true);
1197        ClassNode node2 = factory.createClass("a.B", false);
1198
1199        node1.addDependency(node2);
1200
1201        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1202        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1203        assertTrue("Package a is not concrete", node1.getPackageNode().isConfirmed());
1204        assertTrue("Package node does not contain class node a.A", node1.getPackageNode().getClasses().contains(node1));
1205        assertTrue("Package node does not contain class node a.B", node2.getPackageNode().getClasses().contains(node2));
1206
1207        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1208        assertTrue("Missing class value", factory.getClasses().containsValue(node1));
1209        assertTrue("Class a.A is not concrete", node1.isConfirmed());
1210        assertTrue("a.A --> a.B is missing", node1.getOutboundDependencies().contains(node2));
1211
1212        assertTrue("Missing class key", factory.getClasses().containsKey("a.B"));
1213        assertTrue("Missing class value", factory.getClasses().containsValue(node2));
1214        assertFalse("Class a.B is concrete", node2.isConfirmed());
1215        assertTrue("a.B <-- a.A is missing", node2.getInboundDependencies().contains(node1));
1216
1217        node2.accept(visitor);
1218        
1219        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1220        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1221        assertTrue("Package a is no longer concrete", node1.getPackageNode().isConfirmed());
1222        assertTrue("Package node no longer contains class node a.A", node1.getPackageNode().getClasses().contains(node1));
1223        assertTrue("Package node no longer contains class node a.B", node2.getPackageNode().getClasses().contains(node2));
1224
1225        assertTrue("Removed class key a.A", factory.getClasses().containsKey("a.A"));
1226        assertTrue("Removed class value a.A", factory.getClasses().containsValue(node1));
1227        assertTrue("Class a.A is no longer concrete", node1.isConfirmed());
1228        assertTrue("Removed a.A --> a.B", node1.getOutboundDependencies().contains(node2));
1229
1230        assertTrue("Removed class key a.B", factory.getClasses().containsKey("a.B"));
1231        assertTrue("Removed class value a.B", factory.getClasses().containsValue(node2));
1232        assertFalse("Class a.B is now concrete", node2.isConfirmed());
1233        assertTrue("Removed a.B <-- a.A", node2.getInboundDependencies().contains(node1));
1234    }
1235
1236    public void testAcceptEmptyNonConcreteFeatureWithInboundDependency() {
1237        FeatureNode node1 = factory.createFeature("a.A.a", true);
1238        FeatureNode node2 = factory.createFeature("a.A.b", false);
1239
1240        node1.addDependency(node2);
1241
1242        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1243        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1244        assertTrue("Package a is not concrete", node1.getClassNode().getPackageNode().isConfirmed());
1245        assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1246        
1247        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1248        assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
1249        assertTrue("Class a.A is not concrete", node1.getClassNode().isConfirmed());
1250        assertTrue("Class node does not contain feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1251        assertTrue("Class node does not contain feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1252        
1253        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
1254        assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
1255        assertTrue("Feature a.A.a is not concrete", node1.isConfirmed());
1256        assertTrue("a.A.a --> a.A.b is missing", node1.getOutboundDependencies().contains(node2));
1257        
1258        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.b"));
1259        assertTrue("Missing feature value", factory.getFeatures().containsValue(node2));
1260        assertFalse("Feature a.A.b is concrete", node2.isConfirmed());
1261        assertTrue("a.A.b <-- a.A.a is missing", node2.getInboundDependencies().contains(node1));
1262
1263        node2.accept(visitor);
1264        
1265        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1266        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1267        assertTrue("Package a is no longer concrete", node1.getClassNode().getPackageNode().isConfirmed());
1268        assertTrue("Package node no longer contains class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1269        
1270        assertTrue("Did not remove class key", factory.getClasses().containsKey("a.A"));
1271        assertTrue("Did not remove class value", factory.getClasses().containsValue(node1.getClassNode()));
1272        assertTrue("Class a.A is no longer concrete", node1.getClassNode().isConfirmed());
1273        assertTrue("Class node no longer contains feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1274        assertTrue("Class node no longer contains feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1275        
1276        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.a"));
1277        assertTrue("Remove feature value", factory.getFeatures().containsValue(node1));
1278        assertTrue("Feature a.A.a is no longer concrete", node1.isConfirmed());
1279        assertTrue("Removed a.A.a --> a.A.b", node1.getOutboundDependencies().contains(node2));
1280        
1281        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.b"));
1282        assertTrue("Remove feature value", factory.getFeatures().containsValue(node2));
1283        assertFalse("Feature a.A.b is now concrete", node2.isConfirmed());
1284        assertTrue("Removed a.A.b <-- a.A.a", node2.getInboundDependencies().contains(node1));
1285    }
1286
1287    public void testAcceptEmptyConcretePackageWithInboundDependency() {
1288        PackageNode node1 = factory.createPackage("a", true);
1289        PackageNode node2 = factory.createPackage("b", true);
1290
1291        node1.addDependency(node2);
1292        
1293        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1294        assertTrue("Missing package value a", factory.getPackages().containsValue(node1));
1295        assertTrue("Package a is not concrete", node1.isConfirmed());
1296        assertTrue("a --> b is missing", node1.getOutboundDependencies().contains(node2));
1297        
1298        assertTrue("Missing package key b", factory.getPackages().containsKey("b"));
1299        assertTrue("Missing package value b", factory.getPackages().containsValue(node2));
1300        assertTrue("Package b is not concrete", node2.isConfirmed());
1301        assertTrue("b <-- a is missing", node2.getInboundDependencies().contains(node1));
1302
1303        node2.accept(visitor);
1304        
1305        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1306        assertTrue("Removed package value a", factory.getPackages().containsValue(node1));
1307        assertTrue("Package a is no longer concrete", node1.isConfirmed());
1308        assertTrue("Removed a --> b", node1.getOutboundDependencies().contains(node2));
1309
1310        assertTrue("Removed package key b", factory.getPackages().containsKey("b"));
1311        assertTrue("Removed package value b", factory.getPackages().containsValue(node2));
1312        assertFalse("Package b is still concrete", node2.isConfirmed());
1313        assertTrue("Removed b <-- a", node2.getInboundDependencies().contains(node1));
1314    }
1315
1316    public void testAcceptEmptyConcreteClassWithInboundDependency() {
1317        ClassNode node1 = factory.createClass("a.A", true);
1318        ClassNode node2 = factory.createClass("a.B", true);
1319
1320        node1.addDependency(node2);
1321
1322        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1323        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1324        assertTrue("Package a is not concrete", node1.getPackageNode().isConfirmed());
1325        assertTrue("Package node does not contain class node a.A", node1.getPackageNode().getClasses().contains(node1));
1326        assertTrue("Package node does not contain class node a.B", node2.getPackageNode().getClasses().contains(node2));
1327
1328        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1329        assertTrue("Missing class value", factory.getClasses().containsValue(node1));
1330        assertTrue("Class a.A is not concrete", node1.isConfirmed());
1331        assertTrue("a.A --> a.B is missing", node1.getOutboundDependencies().contains(node2));
1332
1333        assertTrue("Missing class key", factory.getClasses().containsKey("a.B"));
1334        assertTrue("Missing class value", factory.getClasses().containsValue(node2));
1335        assertTrue("Class a.B is not concrete", node2.isConfirmed());
1336        assertTrue("a.B <-- a.A is missing", node2.getInboundDependencies().contains(node1));
1337
1338        node2.accept(visitor);
1339        
1340        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1341        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1342        assertTrue("Package a is no longer concrete", node1.getPackageNode().isConfirmed());
1343        assertTrue("Package node no longer contains class node a.A", node1.getPackageNode().getClasses().contains(node1));
1344        assertTrue("Package node no longer contains class node a.B", node2.getPackageNode().getClasses().contains(node2));
1345
1346        assertTrue("Removed class key a.A", factory.getClasses().containsKey("a.A"));
1347        assertTrue("Removed class value a.A", factory.getClasses().containsValue(node1));
1348        assertTrue("Class a.A is no longer concrete", node1.isConfirmed());
1349        assertTrue("Removed a.A --> a.B", node1.getOutboundDependencies().contains(node2));
1350
1351        assertTrue("Removed class key a.B", factory.getClasses().containsKey("a.B"));
1352        assertTrue("Removed class value a.B", factory.getClasses().containsValue(node2));
1353        assertFalse("Class a.B is still concrete", node2.isConfirmed());
1354        assertTrue("Removed a.B <-- a.A", node2.getInboundDependencies().contains(node1));
1355    }
1356
1357    public void testAcceptEmptyConcreteFeatureWithInboundDependency() {
1358        FeatureNode node1 = factory.createFeature("a.A.a", true);
1359        FeatureNode node2 = factory.createFeature("a.A.b", true);
1360
1361        node1.addDependency(node2);
1362
1363        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1364        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1365        assertTrue("Package a is not concrete", node1.getClassNode().getPackageNode().isConfirmed());
1366        assertTrue("Package node does not contain class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1367        
1368        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1369        assertTrue("Missing class value", factory.getClasses().containsValue(node1.getClassNode()));
1370        assertTrue("Class a.A is not concrete", node1.getClassNode().isConfirmed());
1371        assertTrue("Class node does not contain feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1372        assertTrue("Class node does not contain feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1373        
1374        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
1375        assertTrue("Missing feature value", factory.getFeatures().containsValue(node1));
1376        assertTrue("Feature a.A.a is not concrete", node1.isConfirmed());
1377        assertTrue("a.A.a --> a.A.b is missing", node1.getOutboundDependencies().contains(node2));
1378        
1379        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.b"));
1380        assertTrue("Missing feature value", factory.getFeatures().containsValue(node2));
1381        assertTrue("Feature a.A.b is not concrete", node2.isConfirmed());
1382        assertTrue("a.A.b <-- a.A.a is missing", node2.getInboundDependencies().contains(node1));
1383
1384        node2.accept(visitor);
1385        
1386        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1387        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getClassNode().getPackageNode()));
1388        assertTrue("Package a is no longer concrete", node1.getClassNode().getPackageNode().isConfirmed());
1389        assertTrue("Package node no longer contains class node", node1.getClassNode().getPackageNode().getClasses().contains(node1.getClassNode()));
1390        
1391        assertTrue("Did not remove class key", factory.getClasses().containsKey("a.A"));
1392        assertTrue("Did not remove class value", factory.getClasses().containsValue(node1.getClassNode()));
1393        assertTrue("Class a.A is no longer concrete", node1.getClassNode().isConfirmed());
1394        assertTrue("Class node no longer contains feature node a.A.a", node1.getClassNode().getFeatures().contains(node1));
1395        assertTrue("Class node no longer contains feature node a.A.b", node2.getClassNode().getFeatures().contains(node2));
1396        
1397        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.a"));
1398        assertTrue("Remove feature value", factory.getFeatures().containsValue(node1));
1399        assertTrue("Feature a.A.a is no longer concrete", node1.isConfirmed());
1400        assertTrue("Removed a.A.a --> a.A.b", node1.getOutboundDependencies().contains(node2));
1401        
1402        assertTrue("Remove feature key", factory.getFeatures().containsKey("a.A.b"));
1403        assertTrue("Remove feature value", factory.getFeatures().containsValue(node2));
1404        assertFalse("Feature a.A.b is still concrete", node2.isConfirmed());
1405        assertTrue("Removed a.A.b <-- a.A.a", node2.getInboundDependencies().contains(node1));
1406    }
1407
1408    public void testAcceptOutboundNonEmptyPackage() {
1409        PackageNode node1 = factory.createPackage("a", false);
1410        ClassNode node2 = factory.createClass("a.A", false);
1411
1412        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1413        assertTrue("Missing package value a", factory.getPackages().containsValue(node1));
1414        assertFalse("Package a concrete", node1.isConfirmed());
1415        assertTrue("Package node does not contain class node", node1.getClasses().contains(node2));
1416        
1417        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1418        assertTrue("Missing class value", factory.getClasses().containsValue(node2));
1419        assertFalse("Class a.A is concrete", node2.isConfirmed());
1420
1421        node1.acceptOutbound(visitor);
1422        
1423        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1424        assertTrue("Removed package value a", factory.getPackages().containsValue(node1));
1425        assertFalse("Package a is now concrete", node1.isConfirmed());
1426        assertTrue("Package node no longer contains class node", node1.getClasses().contains(node2));
1427        
1428        assertTrue("Removed class key", factory.getClasses().containsKey("a.A"));
1429        assertTrue("Removed class value", factory.getClasses().containsValue(node2));
1430        assertFalse("Class a.A is now concrete", node2.isConfirmed());
1431    }
1432
1433    public void testAcceptOutboundNonEmptyClass() {
1434        ClassNode node1 = factory.createClass("a.A", false);
1435        FeatureNode node2 = factory.createFeature("a.A.a", false);
1436
1437        assertTrue("Missing package key a", factory.getPackages().containsKey("a"));
1438        assertTrue("Missing package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1439        assertFalse("Package a is concrete", node1.getPackageNode().isConfirmed());
1440        assertTrue("Package node does not contain class node", node1.getPackageNode().getClasses().contains(node1));
1441        
1442        assertTrue("Missing class key", factory.getClasses().containsKey("a.A"));
1443        assertTrue("Missing class value", factory.getClasses().containsValue(node1));
1444        assertFalse("Class a.A is concrete", node1.isConfirmed());
1445        assertTrue("Class node does not contain feature node", node1.getFeatures().contains(node2));
1446        
1447        assertTrue("Missing feature key", factory.getFeatures().containsKey("a.A.a"));
1448        assertTrue("Missing feature value", factory.getFeatures().containsValue(node2));
1449        assertFalse("Feature a.A.a is concrete", node2.isConfirmed());
1450
1451        node1.acceptOutbound(visitor);
1452        
1453        assertTrue("Removed package key a", factory.getPackages().containsKey("a"));
1454        assertTrue("Removed package value a", factory.getPackages().containsValue(node1.getPackageNode()));
1455        assertFalse("Package a is now concrete", node1.getPackageNode().isConfirmed());
1456        assertTrue("Package node no longer contains class node", node1.getPackageNode().getClasses().contains(node1));
1457        
1458        assertTrue("Removed class key", factory.getClasses().containsKey("a.A"));
1459        assertTrue("Removed class value", factory.getClasses().containsValue(node1));
1460        assertFalse("Class a.A is now concrete", node1.isConfirmed());
1461        assertTrue("Class node no longer contains feature node", node1.getFeatures().contains(node2));
1462        
1463        assertTrue("Removed feature key", factory.getFeatures().containsKey("a.A.a"));
1464        assertTrue("Removed feature value", factory.getFeatures().containsValue(node2));
1465        assertFalse("Feature a.A.a is now concrete", node2.isConfirmed());
1466    }
1467}
1468
Popular Tags