use of org.jbehave.core.annotations.When in project javaparser by javaparser.
the class CommentParsingSteps method givenTheClassWithEncoding.
@When("read sample \"$sampleName\" using encoding \"$encoding\"")
public void givenTheClassWithEncoding(String sampleName, String encoding) throws IOException {
sourceUnderTest = null;
ParseResult<CompilationUnit> parseResult = new JavaParser(new ParserConfiguration()).parse(COMPILATION_UNIT, provider(getSampleStream(sampleName), Charset.forName(encoding)));
commentsCollection = parseResult.getCommentsCollection().orElse(new CommentsCollection());
}
use of org.jbehave.core.annotations.When in project javaparser by javaparser.
the class ManipulationSteps method whenTheVisitorVisitsToCompilationUnit.
@When("the ChangeNameToUpperCaseVisitor visits to compilation unit")
public void whenTheVisitorVisitsToCompilationUnit() {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
changeMethodNameToUpperCaseVisitor.visit(compilationUnit, null);
state.put("cu1", compilationUnit);
}
use of org.jbehave.core.annotations.When in project javaparser by javaparser.
the class ManipulationSteps method whenVarargsCalledAreAddedToMethodInClass.
@When("$typeName varargs called \"$parameterName\" are added to method $methodPosition in class $classPosition")
public void whenVarargsCalledAreAddedToMethodInClass(String typeName, String parameterName, int methodPosition, int classPosition) {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
getMethodByPositionAndClassPosition(compilationUnit, methodPosition, classPosition).addAndGetParameter(typeName, parameterName).setVarArgs(true);
}
use of org.jbehave.core.annotations.When in project javaparser by javaparser.
the class ManipulationSteps method whenTheAddNewParameterCalledValueVisitorVisitsToCompilationUnit.
@When("the AddNewIntParameterCalledValueVisitor visits to compilation unit")
public void whenTheAddNewParameterCalledValueVisitorVisitsToCompilationUnit() {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
addNewIntParameterCalledValueVisitor.visit(compilationUnit, null);
state.put("cu1", compilationUnit);
}
use of org.jbehave.core.annotations.When in project javaparser by javaparser.
the class ManipulationSteps method whenHelloWorldIsAddedToTheBodyOfMethodInClass.
@When("$className.$fieldName.$methodName(\"$stringValue\"); is added to the body of method $methodPosition in class $classPosition")
public void whenHelloWorldIsAddedToTheBodyOfMethodInClass(String className, String fieldName, String methodName, String stringValue, int methodPosition, int classPosition) {
CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
MethodDeclaration method = getMethodByPositionAndClassPosition(compilationUnit, methodPosition, classPosition);
NameExpr clazz = new NameExpr(className);
FieldAccessExpr field = new FieldAccessExpr(clazz, fieldName);
MethodCallExpr call = new MethodCallExpr(field, methodName);
call.addArgument(new StringLiteralExpr(stringValue));
method.getBody().get().addStatement(call);
}
Aggregations