Search in sources :

Example 26 with When

use of org.jbehave.core.annotations.When in project javaparser by javaparser.

the class VisitorSteps method whenTheCompilationUnitIsVisitedByTheVisitorThatReturnsVariableNames.

@When("the CompilationUnit is visited by the visitor that returns variable names")
public void whenTheCompilationUnitIsVisitedByTheVisitorThatReturnsVariableNames() {
    CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
    returnedVariableName = nameReturningVisitor.visit(compilationUnit, null);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) When(org.jbehave.core.annotations.When)

Example 27 with When

use of org.jbehave.core.annotations.When in project javaparser by javaparser.

the class VisitorSteps method whenTheCompilationUnitIsVisitedByThePositionTestVisitor.

@When("the CompilationUnit is visited by the PositionTestVisitor")
public void whenTheCompilationUnitIsVisitedByThePositionTestVisitor() {
    CompilationUnit compilationUnit = (CompilationUnit) state.get("cu1");
    compilationUnit.accept(positionTestVisitor, null);
}
Also used : CompilationUnit(com.github.javaparser.ast.CompilationUnit) When(org.jbehave.core.annotations.When)

Example 28 with When

use of org.jbehave.core.annotations.When in project tutorials by eugenp.

the class GithubUserResponsePayloadSteps method whenILookForEugenpViaTheApi.

@When("I look for $user via the api")
public void whenILookForEugenpViaTheApi(String user) throws IOException {
    HttpResponse httpResponse = getGithubUserProfile(api, user);
    resource = RetrieveUtil.retrieveResourceFromResponse(httpResponse, GitHubUser.class);
}
Also used : GitHubUser(org.baeldung.rest.GitHubUser) HttpResponse(org.apache.http.HttpResponse) When(org.jbehave.core.annotations.When)

Example 29 with When

use of org.jbehave.core.annotations.When in project jbehave-core by jbehave.

the class RESTSteps method storyIsLoaded.

@When("story $name text contains '$text'")
public void storyIsLoaded(String name, String text) {
    ResourceLoader loader = resourceLoader();
    Resource resource = index.get(name);
    String asText = loader.loadResourceAsText(resource.getURI());
    assertThat(asText, containsString(text));
}
Also used : ResourceLoader(org.jbehave.core.io.ResourceLoader) Resource(org.jbehave.core.io.rest.Resource) Matchers.containsString(org.hamcrest.Matchers.containsString) When(org.jbehave.core.annotations.When)

Example 30 with When

use of org.jbehave.core.annotations.When in project jbehave-core by jbehave.

the class Steps method listCandidates.

public List<StepCandidate> listCandidates() {
    List<StepCandidate> candidates = new ArrayList<>();
    for (Method method : allMethods()) {
        if (method.isAnnotationPresent(Given.class)) {
            Given annotation = method.getAnnotation(Given.class);
            String value = annotation.value();
            int priority = annotation.priority();
            addCandidatesFromVariants(candidates, method, GIVEN, value, priority);
            addCandidatesFromAliases(candidates, method, GIVEN, priority);
        }
        if (method.isAnnotationPresent(When.class)) {
            When annotation = method.getAnnotation(When.class);
            String value = annotation.value();
            int priority = annotation.priority();
            addCandidatesFromVariants(candidates, method, WHEN, value, priority);
            addCandidatesFromAliases(candidates, method, WHEN, priority);
        }
        if (method.isAnnotationPresent(Then.class)) {
            Then annotation = method.getAnnotation(Then.class);
            String value = annotation.value();
            int priority = annotation.priority();
            addCandidatesFromVariants(candidates, method, THEN, value, priority);
            addCandidatesFromAliases(candidates, method, THEN, priority);
        }
    }
    return candidates;
}
Also used : When(org.jbehave.core.annotations.When) Given(org.jbehave.core.annotations.Given) ArrayList(java.util.ArrayList) Then(org.jbehave.core.annotations.Then) Method(java.lang.reflect.Method)

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