| 1 | |
package org.jbehave.core.model; |
| 2 | |
|
| 3 | |
import static java.util.Collections.unmodifiableList; |
| 4 | |
|
| 5 | |
import java.util.Arrays; |
| 6 | |
import java.util.List; |
| 7 | |
import java.util.Properties; |
| 8 | |
|
| 9 | |
import org.apache.commons.lang.builder.ToStringBuilder; |
| 10 | |
import org.apache.commons.lang.builder.ToStringStyle; |
| 11 | |
|
| 12 | |
public class Scenario { |
| 13 | |
|
| 14 | |
private final String title; |
| 15 | |
private final Meta meta; |
| 16 | |
private final GivenStories givenStories; |
| 17 | |
private final ExamplesTable examplesTable; |
| 18 | |
private final List<String> steps; |
| 19 | |
|
| 20 | |
public Scenario() { |
| 21 | 16 | this(Arrays.<String>asList()); |
| 22 | 16 | } |
| 23 | |
|
| 24 | |
public Scenario(List<String> steps) { |
| 25 | 24 | this("", steps); |
| 26 | 24 | } |
| 27 | |
|
| 28 | |
public Scenario(String title, Meta meta) { |
| 29 | 2 | this(title, meta, GivenStories.EMPTY, ExamplesTable.EMPTY, Arrays.<String>asList()); |
| 30 | 2 | } |
| 31 | |
|
| 32 | |
public Scenario(String title, List<String> steps) { |
| 33 | 32 | this(title, Meta.EMPTY, GivenStories.EMPTY, ExamplesTable.EMPTY, steps); |
| 34 | 32 | } |
| 35 | |
|
| 36 | 179 | public Scenario(String title, Meta meta, GivenStories givenStories, ExamplesTable examplesTable, List<String> steps) { |
| 37 | 179 | this.title = title; |
| 38 | 179 | this.meta = meta; |
| 39 | 179 | this.givenStories = givenStories; |
| 40 | 179 | this.examplesTable = examplesTable; |
| 41 | 179 | this.steps = steps; |
| 42 | 179 | } |
| 43 | |
|
| 44 | |
public String getTitle() { |
| 45 | 44 | return title; |
| 46 | |
} |
| 47 | |
|
| 48 | |
public GivenStories getGivenStories() { |
| 49 | 38 | return givenStories; |
| 50 | |
} |
| 51 | |
|
| 52 | |
public ExamplesTable getExamplesTable() { |
| 53 | 32 | return examplesTable; |
| 54 | |
} |
| 55 | |
|
| 56 | |
public Meta asMeta(String prefix){ |
| 57 | 35 | Properties p = new Properties(); |
| 58 | 35 | p.setProperty(prefix+"title", title); |
| 59 | 35 | p.setProperty(prefix+"givenStories", givenStories.asString()); |
| 60 | 35 | p.setProperty(prefix+"examplesTable", examplesTable.asString()); |
| 61 | 35 | return new Meta(p); |
| 62 | |
} |
| 63 | |
|
| 64 | |
public Meta getMeta(){ |
| 65 | 93 | return meta; |
| 66 | |
} |
| 67 | |
|
| 68 | |
public List<String> getSteps() { |
| 69 | 131 | return unmodifiableList(steps); |
| 70 | |
} |
| 71 | |
|
| 72 | |
@Override |
| 73 | |
public String toString() { |
| 74 | 18 | return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); |
| 75 | |
} |
| 76 | |
|
| 77 | |
} |