com.technophobia.substeps.model.Scenario Maven / Gradle / Ivy
/*
* Copyright Technophobia Ltd 2012
*
* This file is part of Substeps.
*
* Substeps is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Substeps is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Substeps. If not, see .
*/
package com.technophobia.substeps.model;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Scenario extends RootFeature {
private String description;
private Background background = null;
private List steps;
private List exampleParameters = null;
private String[] paramNames = null;
private boolean outline;
private int scenarioLineNumber;
private int exampleKeysLineNumber;
private int sourceStartOffset = -1;
private int sourceStartLineNumber = -1;
@Override
public String toString() {
return "Scenario: " + this.description;
}
/**
* @return the background
*/
public Background getBackground() {
return this.background;
}
public void setBackground(final Background background) {
this.background = background;
}
public boolean hasBackground() {
return this.background != null;
}
public String getDescription() {
return this.description;
}
public void setDescription(final String description) {
this.description = description;
}
public List getSteps() {
return this.steps;
}
public List getExampleParameters() {
return this.exampleParameters;
}
public void setOutline(final boolean outline) {
this.outline = outline;
}
public int getScenarioLineNumber() {
return this.scenarioLineNumber;
}
public int getExampleKeysLineNumber() {
return this.exampleKeysLineNumber;
}
public void setScenarioLineNumber(final int scenarioLineNumber) {
this.scenarioLineNumber = scenarioLineNumber;
}
public void setExampleKeysLineNumber(final int exampleKeysLineNumber) {
this.exampleKeysLineNumber = exampleKeysLineNumber;
}
public void addStep(final Step cukeArg) {
if (cukeArg != null) {
if (this.steps == null) {
this.steps = new ArrayList();
}
this.steps.add(cukeArg);
}
}
public void addExampleKeys(final String[] split) {
this.paramNames = split;
this.exampleParameters = new ArrayList();
}
public void addExampleValues(final int lineNumber, final String[] split) {
// Cucumber compatibility - with cuke you can get away with not defining
// all your columns of data, so we'll do the same
final Map row = new HashMap();
for (int i = 1; i < split.length; i++) {
row.put(this.paramNames[i].trim(), split[i].trim());
}
this.exampleParameters.add(new ExampleParameter(lineNumber, row));
}
/**
* @return if it is an outline scenario
*/
public boolean isOutline() {
return this.outline;
}
/**
* @return the sourceStartOffset
*/
public int getSourceStartOffset() {
return this.sourceStartOffset;
}
/**
* @param sourceStartOffset the sourceStartOffset to set
*/
public void setSourceStartOffset(final int sourceStartOffset) {
this.sourceStartOffset = sourceStartOffset;
}
/**
* @return the sourceStartLineNumber
*/
public int getSourceStartLineNumber() {
return this.sourceStartLineNumber;
}
/**
* @param sourceStartLineNumber the sourceStartLineNumber to set
*/
public void setSourceStartLineNumber(final int sourceStartLineNumber) {
this.sourceStartLineNumber = sourceStartLineNumber;
}
public boolean hasSteps() {
return steps != null && !steps.isEmpty();
}
}