Coverage Report - org.jbehave.core.steps.spring.SpringStepsFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
SpringStepsFactory
100%
9/9
100%
4/4
2
 
 1  
 package org.jbehave.core.steps.spring;
 2  
 
 3  
 import java.util.ArrayList;
 4  
 import java.util.List;
 5  
 
 6  
 import org.jbehave.core.configuration.Configuration;
 7  
 import org.jbehave.core.steps.AbstractStepsFactory;
 8  
 import org.jbehave.core.steps.InjectableStepsFactory;
 9  
 import org.springframework.context.ApplicationContext;
 10  
 
 11  
 /**
 12  
  * An {@link InjectableStepsFactory} that uses Spring's
 13  
  * {@link ApplicationContext} for the composition and instantiation of all
 14  
  * components that contain JBehave annotated methods.
 15  
  * 
 16  
  * @author Paul Hammant
 17  
  * @author Mauro Talevi
 18  
  */
 19  
 public class SpringStepsFactory extends AbstractStepsFactory {
 20  
 
 21  
     private final ApplicationContext context;
 22  
 
 23  
     public SpringStepsFactory(Configuration configuration, ApplicationContext context) {
 24  5
         super(configuration);
 25  5
         this.context = context;
 26  5
     }
 27  
 
 28  
     @Override
 29  
     protected List<Object> stepsInstances() {
 30  5
         List<Object> steps = new ArrayList<Object>();
 31  24
         for (String name : context.getBeanDefinitionNames()) {
 32  19
             Object bean = context.getBean(name);
 33  19
             if (hasAnnotatedMethods(bean.getClass())) {
 34  4
                 steps.add(bean);
 35  
             }
 36  
         }
 37  5
         return steps;
 38  
     }
 39  
 
 40  
 }