Search in sources :

Example 6 with Given

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

the class GoogleSteps method givenGoogleFeed.

@Given("Google feed $uri")
public void givenGoogleFeed(String feedURI) {
    String username = System.getenv("GOOGLE_USER");
    String password = System.getenv("GOOGLE_PASSWORD");
    storyLoader = new LoadOdtFromGoogle(username, password, feedURI);
}
Also used : LoadOdtFromGoogle(org.jbehave.core.io.google.LoadOdtFromGoogle) Given(org.jbehave.core.annotations.Given)

Example 7 with Given

use of org.jbehave.core.annotations.Given 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)

Example 8 with Given

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

the class OrganizationSteps method updateOrganizationWithDefaultAuthPolicy.

@Given("a default authentication policy for $orgName")
public void updateOrganizationWithDefaultAuthPolicy(String orgName) {
    Organization org = organizationDao.findByName(orgName);
    org.setAuthenticationPolicy(new AuthenticationPolicy());
    organizationDao.persist(org);
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) AuthenticationPolicy(org.jbehave.example.spring.security.domain.AuthenticationPolicy) Given(org.jbehave.core.annotations.Given)

Example 9 with Given

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

the class OrganizationSteps method updateOrganizationWithDefaultAuthPolicy.

@Given("authentication policy for $orgName: $authPolicyTable")
public void updateOrganizationWithDefaultAuthPolicy(String orgName, ExamplesTable table) {
    Organization org = organizationDao.findByName(orgName);
    Map<String, String> row = table.getRow(0);
    org.setAuthenticationPolicy(new AuthenticationPolicyBuilder(row).build());
    organizationDao.persist(org);
}
Also used : AuthenticationPolicyBuilder(org.jbehave.example.spring.security.domain.AuthenticationPolicyBuilder) Organization(org.jbehave.example.spring.security.domain.Organization) Given(org.jbehave.core.annotations.Given)

Example 10 with Given

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

the class UserSteps method setUserEnabled.

@Given("user for $orgName $username is enabled")
public void setUserEnabled(String orgName, String username) {
    Organization org = organizationDao.findByName(orgName);
    User user = userDao.findUserByOrganizationAndUsername(org.getId(), username);
    user.setEnabled(true);
    userDao.persist(user);
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) User(org.jbehave.example.spring.security.domain.User) Given(org.jbehave.core.annotations.Given)

Aggregations

Given (org.jbehave.core.annotations.Given)12 Organization (org.jbehave.example.spring.security.domain.Organization)8 User (org.jbehave.example.spring.security.domain.User)4 AuthenticationPolicy (org.jbehave.example.spring.security.domain.AuthenticationPolicy)2 Game (com.lunivore.gameoflife.domain.Game)1 StringRenderer (com.lunivore.gameoflife.view.string.StringRenderer)1 File (java.io.File)1 FileReader (java.io.FileReader)1 Method (java.lang.reflect.Method)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Alias (org.jbehave.core.annotations.Alias)1 Aliases (org.jbehave.core.annotations.Aliases)1 Then (org.jbehave.core.annotations.Then)1 When (org.jbehave.core.annotations.When)1 LoadOdtFromGoogle (org.jbehave.core.io.google.LoadOdtFromGoogle)1 Parameters (org.jbehave.core.steps.Parameters)1 AuthenticationPolicyBuilder (org.jbehave.example.spring.security.domain.AuthenticationPolicyBuilder)1 UserBuilder (org.jbehave.example.spring.security.domain.UserBuilder)1