Coverage Report - org.jbehave.core.ConfigurableEmbedder
 
Classes in this File Line Coverage Branch Coverage Complexity
ConfigurableEmbedder
100%
21/21
N/A
1
 
 1  
 package org.jbehave.core;
 2  
 
 3  
 import static java.util.Arrays.asList;
 4  
 
 5  
 import java.util.ArrayList;
 6  
 import java.util.List;
 7  
 
 8  
 import org.jbehave.core.configuration.Configuration;
 9  
 import org.jbehave.core.configuration.MostUsefulConfiguration;
 10  
 import org.jbehave.core.embedder.Embedder;
 11  
 import org.jbehave.core.junit.JUnitStories;
 12  
 import org.jbehave.core.junit.JUnitStory;
 13  
 import org.jbehave.core.steps.CandidateSteps;
 14  
 import org.jbehave.core.steps.InjectableStepsFactory;
 15  
 
 16  
 /**
 17  
  * <p>
 18  
  * Abstract implementation of {@link Embeddable} which allow to configure
 19  
  * the {@link Embedder} used to run the story or stories, using the
 20  
  * {@link Configuration} and the {@link CandidateSteps} specified.
 21  
  * </p>
 22  
  * <p>
 23  
  * By default {@link MostUsefulConfiguration}) is used and be overridden
 24  
  * via the {@link #useConfiguration(Configuration)} method.
 25  
  * </p>
 26  
  * <p>
 27  
  * Users need to add the {@link CandidateSteps} instances, via the
 28  
  * {@link #addSteps(CandidateSteps...)} or {@link
 29  
  * #addSteps(List<CandidateSteps>)} methods.
 30  
  * </p>
 31  
  * <p>
 32  
  * Typically, users that use JUnit will find it easier to extend other
 33  
  * implementations, such as {@link JUnitStory} or {@link JUnitStories}, which
 34  
  * implement the {@link#run()} using the configured embedder and annotate it
 35  
  * with JUnit's {@link Test} annotation.
 36  
  * </p>
 37  
  */
 38  14
 public abstract class ConfigurableEmbedder implements Embeddable {
 39  
 
 40  14
     private Embedder embedder = new Embedder();
 41  14
     private Configuration configuration = new MostUsefulConfiguration();
 42  14
     private List<CandidateSteps> candidateSteps = new ArrayList<CandidateSteps>();
 43  
     private InjectableStepsFactory stepsFactory;
 44  
 
 45  
     public void useEmbedder(Embedder embedder) {
 46  12
         this.embedder = embedder;
 47  12
     }
 48  
 
 49  
     public void useConfiguration(Configuration configuration) {
 50  7
         this.configuration = configuration;
 51  7
     }
 52  
 
 53  
     public void addSteps(CandidateSteps... steps) {
 54  4
         addSteps(asList(steps));
 55  4
     }
 56  
 
 57  
     public void addSteps(List<CandidateSteps> steps) {
 58  6
         this.candidateSteps.addAll(steps);
 59  6
     }
 60  
 
 61  
     public void useStepsFactory(InjectableStepsFactory stepsFactory){
 62  2
         this.stepsFactory = stepsFactory;        
 63  2
     }
 64  
     
 65  
     public Configuration configuration() {
 66  8
         return configuration;
 67  
     }
 68  
 
 69  
     public List<CandidateSteps> candidateSteps() {
 70  7
         return candidateSteps;
 71  
     }
 72  
     
 73  
     public InjectableStepsFactory stepsFactory(){
 74  6
         return stepsFactory;
 75  
     }
 76  
 
 77  
     public Embedder configuredEmbedder() {
 78  7
         embedder.useConfiguration(configuration());
 79  7
         embedder.useCandidateSteps(candidateSteps());
 80  7
         embedder.useStepsFactory(stepsFactory());
 81  7
         return embedder;
 82  
     }
 83  
 
 84  
 }