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 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
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 | |
} |