com.github.mkolisnyk.aerial.expressions.value.SingleNumericValueExpression Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aerial Show documentation
Show all versions of aerial Show documentation
Generates Cucumber scenarios based on text descriptions
/**
* .
*/
package com.github.mkolisnyk.aerial.expressions.value;
import java.util.ArrayList;
import java.util.List;
import org.junit.Assert;
import com.github.mkolisnyk.aerial.document.InputRecord;
import com.github.mkolisnyk.aerial.expressions.ValueExpression;
import com.github.mkolisnyk.aerial.expressions.ValueExpressionType;
/**
* @author Myk Kolisnyk
*
*/
public class SingleNumericValueExpression extends ValueExpression {
/**
* @param inputValue
*/
public SingleNumericValueExpression(InputRecord inputValue) {
super(inputValue);
}
/* (non-Javadoc)
* @see com.github.mkolisnyk.aerial.expressions.ValueExpression#generate()
*/
@Override
public List generate() throws Exception {
List result = new ArrayList();
InputRecord testRecord = (InputRecord) this.getInput().clone();
this.validate();
// Value is set explicitly
result.add(testRecord);
result.add(nonCurrentValue(this.getInput()));
return result;
}
private InputRecord nonCurrentValue(InputRecord input) {
InputRecord testRecord;
Integer intValue = new Integer(input.getValue());
String updatedValue = "";
if (intValue == 0) {
updatedValue = "-1";
} else {
updatedValue = "0";
}
testRecord = new InputRecord(
input.getName(),
input.getType(),
updatedValue,
input.getCondition(),
false);
return testRecord;
}
/* (non-Javadoc)
* @see com.github.mkolisnyk.aerial.expressions.ValueExpression#getValueType()
*/
@Override
public ValueExpressionType getValueType() {
return ValueExpressionType.INTEGER;
}
/* (non-Javadoc)
* @see com.github.mkolisnyk.aerial.expressions.ValueExpression#getMatchPattern()
*/
@Override
public String getMatchPattern() {
return "(([-0-9])(\\d*))";
}
/* (non-Javadoc)
* @see com.github.mkolisnyk.aerial.expressions.ValueExpression#validate()
*/
@Override
public void validate() throws Exception {
super.validate();
Assert.assertFalse("Unique attribute isn't applicable for fixed value",
this.getInput().isUnique());
}
}