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 | 14 | public abstract class ConfigurableEmbedder implements Embeddable { |
38 | |
|
39 | 14 | private Embedder embedder = new Embedder(); |
40 | 14 | private Configuration configuration = new MostUsefulConfiguration(); |
41 | 14 | private List<CandidateSteps> candidateSteps = new ArrayList<CandidateSteps>(); |
42 | |
private InjectableStepsFactory stepsFactory; |
43 | |
|
44 | |
public void useEmbedder(Embedder embedder) { |
45 | 12 | this.embedder = embedder; |
46 | 12 | } |
47 | |
|
48 | |
public void useConfiguration(Configuration configuration) { |
49 | 7 | this.configuration = configuration; |
50 | 7 | } |
51 | |
|
52 | |
public Configuration configuration() { |
53 | 8 | return configuration; |
54 | |
} |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public void addSteps(CandidateSteps... steps) { |
60 | 4 | addSteps(asList(steps)); |
61 | 4 | } |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public void addSteps(List<CandidateSteps> steps) { |
67 | 6 | this.candidateSteps.addAll(steps); |
68 | 6 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public List<CandidateSteps> candidateSteps() { |
74 | 7 | return candidateSteps; |
75 | |
} |
76 | |
|
77 | |
public void useStepsFactory(InjectableStepsFactory stepsFactory){ |
78 | 2 | this.stepsFactory = stepsFactory; |
79 | 2 | } |
80 | |
|
81 | |
public InjectableStepsFactory stepsFactory(){ |
82 | 6 | return stepsFactory; |
83 | |
} |
84 | |
|
85 | |
public Embedder configuredEmbedder() { |
86 | 7 | embedder.useConfiguration(configuration()); |
87 | 7 | embedder.useCandidateSteps(candidateSteps()); |
88 | 7 | embedder.useStepsFactory(stepsFactory()); |
89 | 7 | return embedder; |
90 | |
} |
91 | |
|
92 | |
} |