Coverage Report - org.doxla.spring.automock.resolver.ListedInterfaceMockClassResolver
 
Classes in this File Line Coverage Branch Coverage Complexity
ListedInterfaceMockClassResolver
100% 
100% 
0
 
 1  
 /**
 2  
    Copyright 2007 Dan Oxlade
 3  
 
 4  
    Licensed under the Apache License, Version 2.0 (the "License");
 5  
    you may not use this file except in compliance with the License.
 6  
    You may obtain a copy of the License at
 7  
 
 8  
        http://www.apache.org/licenses/LICENSE-2.0
 9  
 
 10  
    Unless required by applicable law or agreed to in writing, software
 11  
    distributed under the License is distributed on an "AS IS" BASIS,
 12  
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
    See the License for the specific language governing permissions and
 14  
    limitations under the License.
 15  
  */
 16  
 package org.doxla.spring.automock.resolver;
 17  
 
 18  
 import java.util.Collection;
 19  
 import java.util.HashSet;
 20  
 import java.util.Set;
 21  
 
 22  
 import org.springframework.beans.factory.annotation.Required;
 23  
 import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 24  
 
 25  
 /**
 26  
  * Return all classes in the specified list that are interfaces.
 27  
  * TODO resolve the correct interface class based on a naming strategy in
 28  
  * the case where an implementation class is specified.
 29  
  * 
 30  
  * @author dano
 31  
  */
 32  2
 public class ListedInterfaceMockClassResolver implements MockClassResolver {
 33  
         
 34  
         private Class[] classesToMock;
 35  
 
 36  
         public Collection<Class> resolveClassesToMock(ConfigurableListableBeanFactory beanFactory) {
 37  2
                 Set<Class> classesToMock = new HashSet<Class>();
 38  
                 
 39  8
                 for (Class clazz : this.classesToMock) {
 40  6
                         if(clazz.isInterface()){
 41  4
                                 classesToMock.add(clazz);
 42  
                         }
 43  
                 }
 44  
                 
 45  2
                 return classesToMock;
 46  
         }
 47  
         
 48  
         @Required
 49  
         public void setClassesToMock(Class[] classesToMock) {
 50  2
                 this.classesToMock = classesToMock;
 51  2
         }
 52  
 
 53  
 }