Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 117   Methods: 3
NCLOC: 64   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestGraphSummarizerWithFiltering.java - 100% 100% 100%
coverage
 1    /*
 2    * Copyright (c) 2001-2009, 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.util.*;
 36   
 37    import junit.framework.*;
 38   
 39    public class TestGraphSummarizerWithFiltering extends TestCase {
 40    private RegularExpressionSelectionCriteria scopeCriteria;
 41    private RegularExpressionSelectionCriteria filterCriteria;
 42    private NodeFactory factory;
 43   
 44    private Node a_A_a;
 45    private Node b;
 46    private Node b_B_b;
 47    private Node c_C_c;
 48   
 49    private List<String> includeScope;
 50    private List<String> includeFilter;
 51    private List<String> excludeFilter;
 52   
 53    private GraphCopier copier;
 54   
 55  2 protected void setUp() throws Exception {
 56  2 scopeCriteria = new RegularExpressionSelectionCriteria("//");
 57  2 filterCriteria = new RegularExpressionSelectionCriteria("//");
 58  2 factory = new NodeFactory();
 59   
 60  2 a_A_a = factory.createFeature("a.A.a");
 61  2 b = factory.createPackage("b");
 62  2 b_B_b = factory.createFeature("b.B.b");
 63  2 c_C_c = factory.createFeature("c.C.c");
 64   
 65  2 includeScope = new LinkedList<String>();
 66  2 includeScope.add("/^a/");
 67   
 68  2 includeFilter = new LinkedList<String>();
 69  2 includeFilter.add("/^b/");
 70   
 71  2 excludeFilter = new LinkedList<String>();
 72  2 excludeFilter.add("/^c/");
 73   
 74  2 copier = new GraphSummarizer(scopeCriteria, filterCriteria);
 75    }
 76   
 77  1 public void testIncludeFilterF2FtoP2P() {
 78  1 a_A_a.addDependency(b_B_b);
 79  1 a_A_a.addDependency(c_C_c);
 80   
 81  1 scopeCriteria.setMatchingClasses(false);
 82  1 scopeCriteria.setMatchingFeatures(false);
 83  1 filterCriteria.setMatchingClasses(false);
 84  1 filterCriteria.setMatchingFeatures(false);
 85  1 filterCriteria.setGlobalIncludes(includeFilter);
 86   
 87  1 copier.traverseNodes(factory.getPackages().values());
 88   
 89  1 assertTrue(copier.getScopeFactory().createPackage("a").getInboundDependencies().isEmpty());
 90  1 assertEquals(copier.getScopeFactory().createPackage("a").getOutboundDependencies().toString(),
 91    1,
 92    copier.getScopeFactory().createPackage("a").getOutboundDependencies().size());
 93  1 assertTrue(copier.getScopeFactory().createPackage("a").getOutboundDependencies().contains(b));
 94    }
 95   
 96  1 public void testExcludeFilterF2FtoP2P() {
 97  1 a_A_a.addDependency(b_B_b);
 98  1 a_A_a.addDependency(c_C_c);
 99   
 100  1 scopeCriteria.setMatchingClasses(false);
 101  1 scopeCriteria.setMatchingFeatures(false);
 102  1 scopeCriteria.setGlobalIncludes(includeScope);
 103  1 filterCriteria.setMatchingClasses(false);
 104  1 filterCriteria.setMatchingFeatures(false);
 105  1 filterCriteria.setGlobalExcludes(excludeFilter);
 106   
 107  1 assertTrue(!filterCriteria.matchesFeatureName(c_C_c.getName()));
 108   
 109  1 copier.traverseNodes(factory.getPackages().values());
 110   
 111  1 assertTrue(copier.getScopeFactory().createPackage("a").getInboundDependencies().isEmpty());
 112  1 assertEquals(copier.getScopeFactory().createPackage("a").getOutboundDependencies().toString(),
 113    1,
 114    copier.getScopeFactory().createPackage("a").getOutboundDependencies().size());
 115  1 assertTrue(copier.getScopeFactory().createPackage("a").getOutboundDependencies().contains(b));
 116    }
 117    }