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 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
20 | |
|
21 | |
|
22 | |
|
23 | |
|
24 | |
|
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | 25 | public abstract class ConfigurableEmbedder implements Embeddable { |
38 | |
|
39 | 25 | private Embedder embedder = new Embedder(); |
40 | 25 | private Configuration configuration = new MostUsefulConfiguration(); |
41 | 25 | private List<CandidateSteps> candidateSteps = new ArrayList<CandidateSteps>(); |
42 | |
|
43 | |
public void useEmbedder(Embedder embedder) { |
44 | 19 | this.embedder = embedder; |
45 | 19 | } |
46 | |
|
47 | |
public void useConfiguration(Configuration configuration) { |
48 | 6 | this.configuration = configuration; |
49 | 6 | } |
50 | |
|
51 | |
public void addSteps(CandidateSteps... steps) { |
52 | 4 | addSteps(asList(steps)); |
53 | 4 | } |
54 | |
|
55 | |
public void addSteps(List<CandidateSteps> steps) { |
56 | 5 | this.candidateSteps.addAll(steps); |
57 | 5 | } |
58 | |
|
59 | |
public Configuration configuration() { |
60 | 17 | return configuration; |
61 | |
} |
62 | |
|
63 | |
public List<CandidateSteps> candidateSteps() { |
64 | 15 | return candidateSteps; |
65 | |
} |
66 | |
|
67 | |
public Embedder configuredEmbedder() { |
68 | 15 | embedder.useConfiguration(configuration()); |
69 | 15 | embedder.useCandidateSteps(candidateSteps()); |
70 | 15 | return embedder; |
71 | |
} |
72 | |
|
73 | |
} |