Clover coverage report - Dependency Finder
Coverage timestamp: Mon Nov 29 2010 15:00:50 PST
file stats: LOC: 162   Methods: 11
NCLOC: 102   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
TestFeatureResolver.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 org.jmock.*;
 38    import org.jmock.integration.junit3.*;
 39    import org.jmock.lib.legacy.*;
 40   
 41    public class TestFeatureResolver extends MockObjectTestCase {
 42    private FeatureResolver sut;
 43   
 44  10 protected void setUp() throws Exception {
 45  10 super.setUp();
 46   
 47  10 setImposteriser(ClassImposteriser.INSTANCE);
 48   
 49  10 sut = new FeatureResolver();
 50    }
 51   
 52  1 public void testTraverseNodes() {
 53  1 final Node mockNode1 = mock(Node.class, "node1");
 54  1 final Node mockNode2 = mock(Node.class, "node2");
 55   
 56  1 final Collection<Node> nodes = new LinkedList<Node>();
 57  1 nodes.add(mockNode1);
 58  1 nodes.add(mockNode2);
 59   
 60  1 checking(new Expectations() {{
 61  1 one (mockNode1).accept(sut);
 62  1 one (mockNode2).accept(sut);
 63    }});
 64   
 65  1 sut.traverseNodes(nodes);
 66    }
 67   
 68  1 public void testVisitPackageNode() {
 69  1 final PackageNode mockPackageNode = mock(PackageNode.class);
 70  1 final ClassNode mockClassNode1 = mock(ClassNode.class, "class1");
 71  1 final ClassNode mockClassNode2 = mock(ClassNode.class, "class2");
 72   
 73  1 final Collection<ClassNode> classes = new LinkedList<ClassNode>();
 74  1 classes.add(mockClassNode1);
 75  1 classes.add(mockClassNode2);
 76   
 77  1 checking(new Expectations() {{
 78  1 one (mockPackageNode).getClasses();
 79  1 will(returnValue(classes));
 80  1 one (mockClassNode1).accept(sut);
 81  1 one (mockClassNode2).accept(sut);
 82    }});
 83   
 84  1 sut.visitPackageNode(mockPackageNode);
 85    }
 86   
 87  1 public void testVisitInboundPackageNode() {
 88  1 final PackageNode mockPackageNode = mock(PackageNode.class);
 89  1 sut.visitInboundPackageNode(mockPackageNode);
 90    }
 91   
 92  1 public void testVisitOutboundPackageNode() {
 93  1 final PackageNode mockPackageNode = mock(PackageNode.class);
 94  1 sut.visitOutboundPackageNode(mockPackageNode);
 95    }
 96   
 97  1 public void testVisitClassNode() {
 98  1 final ClassNode mockClassNode = mock(ClassNode.class);
 99  1 final FeatureNode mockFeatureNode1 = mock(FeatureNode.class, "feature1");
 100  1 final FeatureNode mockFeatureNode2 = mock(FeatureNode.class, "feature2");
 101   
 102  1 final Collection<FeatureNode> features = new LinkedList<FeatureNode>();
 103  1 features.add(mockFeatureNode1);
 104  1 features.add(mockFeatureNode2);
 105   
 106  1 checking(new Expectations() {{
 107  1 one (mockClassNode).getFeatures();
 108  1 will(returnValue(features));
 109  1 one (mockFeatureNode1).accept(sut);
 110  1 one (mockFeatureNode2).accept(sut);
 111    }});
 112   
 113  1 sut.visitClassNode(mockClassNode);
 114    }
 115   
 116  1 public void testVisitInboundClassNode() {
 117  1 final ClassNode mockClassNode = mock(ClassNode.class);
 118  1 sut.visitInboundClassNode(mockClassNode);
 119    }
 120   
 121  1 public void testVisitOutboundClassNode() {
 122  1 final ClassNode mockClassNode = mock(ClassNode.class);
 123  1 sut.visitOutboundClassNode(mockClassNode);
 124    }
 125   
 126  1 public void testVisitFeatureNode() {
 127  1 final String TARGET_SIMPLE_NAME = "target()";
 128  1 final String CHILD_NAME = "Child";
 129  1 final String CHILD_TARGET_NAME = CHILD_NAME + "." + TARGET_SIMPLE_NAME;
 130  1 final String PARENT_NAME = "Parent";
 131  1 final String PARENT_TARGET_NAME = PARENT_NAME + "." + TARGET_SIMPLE_NAME;
 132   
 133  1 final FeatureNode mockCallerSource = mock(FeatureNode.class, "Caller.source()");
 134  1 final FeatureNode mockParentTarget = mock(FeatureNode.class, PARENT_TARGET_NAME);
 135  1 final ClassNode mockChild = mock(ClassNode.class, CHILD_NAME);
 136  1 final FeatureNode mockChildTarget = mock(FeatureNode.class, CHILD_TARGET_NAME);
 137   
 138  1 checking(new Expectations() {{
 139  1 atLeast(1).of (mockChildTarget).getSimpleName();
 140  1 will(returnValue(TARGET_SIMPLE_NAME));
 141  1 atLeast(1).of (mockChildTarget).getClassNode();
 142  1 will(returnValue(mockChild));
 143  1 one (mockChild).getInheritedFeatures(TARGET_SIMPLE_NAME);
 144  1 will(returnValue(Collections.singleton(mockParentTarget)));
 145  1 one (mockChildTarget).getInboundDependencies();
 146  1 will(returnValue(Collections.singleton(mockCallerSource)));
 147  1 one (mockCallerSource).addDependency(mockParentTarget);
 148    }});
 149   
 150  1 sut.visitFeatureNode(mockChildTarget);
 151    }
 152   
 153  1 public void testVisitInboundFeatureNode() {
 154  1 final FeatureNode mockFeatureNode = mock(FeatureNode.class);
 155  1 sut.visitInboundFeatureNode(mockFeatureNode);
 156    }
 157   
 158  1 public void testVisitOutboundFeatureNode() {
 159  1 final FeatureNode mockFeatureNode = mock(FeatureNode.class);
 160  1 sut.visitOutboundFeatureNode(mockFeatureNode);
 161    }
 162    }