Search in sources :

Example 1 with When

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());
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) JavaParser(com.github.javaparser.JavaParser) ParserConfiguration(com.github.javaparser.ParserConfiguration) When(org.jbehave.core.annotations.When)

Example 2 with When

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) When(org.jbehave.core.annotations.When)

Example 3 with When

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) When(org.jbehave.core.annotations.When)

Example 4 with When

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) When(org.jbehave.core.annotations.When)

Example 5 with When

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);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) When(org.jbehave.core.annotations.When)

Aggregations

When (org.jbehave.core.annotations.When)30 CompilationUnit (com.github.javaparser.ast.CompilationUnit)21 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)5 JavaParser (com.github.javaparser.JavaParser)3 ParserConfiguration (com.github.javaparser.ParserConfiguration)2 File (java.io.File)2 Resource (org.jbehave.core.io.rest.Resource)2 Modifier (com.github.javaparser.ast.Modifier)1 PackageDeclaration (com.github.javaparser.ast.PackageDeclaration)1 ClassOrInterfaceDeclaration (com.github.javaparser.ast.body.ClassOrInterfaceDeclaration)1 BlockStmt (com.github.javaparser.ast.stmt.BlockStmt)1 VoidType (com.github.javaparser.ast.type.VoidType)1 CloneVisitor (com.github.javaparser.ast.visitor.CloneVisitor)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 HttpResponse (org.apache.http.HttpResponse)1