Search in sources :

Example 11 with Parameters

use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.

the class UserSteps method createUsersFromTable.

@Given("the users for $orgName: $userTable")
public void createUsersFromTable(String orgName, ExamplesTable table) {
    Organization org = organizationDao.findByName(orgName);
    List<Parameters> parametersList = table.getRowsAsParameters(true);
    for (Parameters parameters : parametersList) {
        userDao.persist(new UserBuilder(org, parameters, table.getHeaders()).build());
    }
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) Parameters(org.jbehave.core.steps.Parameters) UserBuilder(org.jbehave.example.spring.security.domain.UserBuilder) Given(org.jbehave.core.annotations.Given)

Example 12 with Parameters

use of org.jbehave.core.steps.Parameters in project javaparser by javaparser.

the class CommentParsingSteps method thenTheLineCommentsHaveTheFollowingPositions.

@Then("the line comments have the following positions: $table")
public void thenTheLineCommentsHaveTheFollowingPositions(ExamplesTable examplesTable) {
    int index = 0;
    for (Parameters exampleRow : examplesTable.getRowsAsParameters()) {
        Comment expectedLineComment = toComment(exampleRow, new LineComment());
        Comment lineCommentUnderTest = getCommentAt(commentsCollection.getLineComments(), index);
        Range underTestRange = lineCommentUnderTest.getRange().get();
        Range expectedRange = expectedLineComment.getRange().get();
        assertThat(underTestRange.begin.line, is(expectedRange.begin.line));
        assertThat(underTestRange.begin.column, is(expectedRange.begin.column));
        assertThat(underTestRange.end.line, is(expectedRange.end.line));
        assertThat(underTestRange.end.column, is(expectedRange.end.column));
        index++;
    }
}
Also used : Parameters(org.jbehave.core.steps.Parameters) Range(com.github.javaparser.Range) Then(org.jbehave.core.annotations.Then)

Example 13 with Parameters

use of org.jbehave.core.steps.Parameters in project javaparser by javaparser.

the class CommentParsingSteps method thenTheJavadocCommentsHaveTheFollowingPositions.

@Then("the Javadoc comments have the following positions: $table")
public void thenTheJavadocCommentsHaveTheFollowingPositions(ExamplesTable examplesTable) {
    int index = 0;
    for (Parameters exampleRow : examplesTable.getRowsAsParameters()) {
        Comment expectedLineComment = toComment(exampleRow, new BlockComment());
        Comment lineCommentUnderTest = getCommentAt(commentsCollection.getJavadocComments(), index);
        Range underTestRange = lineCommentUnderTest.getRange().get();
        Range expectedRange = expectedLineComment.getRange().get();
        assertThat(underTestRange.begin.line, is(expectedRange.begin.line));
        assertThat(underTestRange.begin.column, is(expectedRange.begin.column));
        assertThat(underTestRange.end.line, is(expectedRange.end.line));
        assertThat(underTestRange.end.column, is(expectedRange.end.column));
        index++;
    }
}
Also used : Parameters(org.jbehave.core.steps.Parameters) Range(com.github.javaparser.Range) Then(org.jbehave.core.annotations.Then)

Example 14 with Parameters

use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.

the class GherkinSteps method thenICanDriveThemAccordingTo.

@Then("I can drive them according to wheels: $table")
public void thenICanDriveThemAccordingTo(ExamplesTable table) {
    OutcomesTable outcomes = new OutcomesTable();
    for (Parameters row : table.getRowsAsParameters()) {
        Integer wheels = row.valueAs("wheels", Integer.class);
        Boolean canDriveWith = car.canDriveWith(wheels);
        outcomes.addOutcome("wheels " + wheels, canDriveWith, Matchers.is(row.valueAs("can_drive", Boolean.class)));
    }
    outcomes.verify();
}
Also used : Parameters(org.jbehave.core.steps.Parameters) OutcomesTable(org.jbehave.core.model.OutcomesTable) Then(org.jbehave.core.annotations.Then)

Example 15 with Parameters

use of org.jbehave.core.steps.Parameters in project jbehave-core by jbehave.

the class FrSteps method theResultsMultipliedByAre.

@Then("les valeurs multipliƩes par $multiplier sont: $table")
public void theResultsMultipliedByAre(int multiplier, ExamplesTable results) {
    OutcomesTable outcomes = new OutcomesTable(new LocalizedKeywords(new Locale("fr")));
    for (int row = 0; row < results.getRowCount(); row++) {
        Parameters expected = results.getRowAsParameters(row);
        Parameters original = table.getRowAsParameters(row);
        int one = original.valueAs("un", Integer.class);
        int two = original.valueAs("deux", Integer.class);
        outcomes.addOutcome("un", one * multiplier, Matchers.equalTo(expected.valueAs("un", Integer.class)));
        outcomes.addOutcome("deux", two * multiplier, Matchers.equalTo(expected.valueAs("deux", Integer.class)));
    }
    outcomes.verify();
}
Also used : Locale(java.util.Locale) Parameters(org.jbehave.core.steps.Parameters) LocalizedKeywords(org.jbehave.core.i18n.LocalizedKeywords) OutcomesTable(org.jbehave.core.model.OutcomesTable) Then(org.jbehave.core.annotations.Then)

Aggregations

Parameters (org.jbehave.core.steps.Parameters)17 AsParameters (org.jbehave.core.annotations.AsParameters)10 Test (org.junit.Test)10 Then (org.jbehave.core.annotations.Then)6 Range (com.github.javaparser.Range)3 OutcomesTable (org.jbehave.core.model.OutcomesTable)2 MethodReturningConverter (org.jbehave.core.steps.ParameterConverters.MethodReturningConverter)2 Locale (java.util.Locale)1 Given (org.jbehave.core.annotations.Given)1 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)1 RowNotFound (org.jbehave.core.model.ExamplesTable.RowNotFound)1 ValueNotFound (org.jbehave.core.steps.ConvertedParameters.ValueNotFound)1 Organization (org.jbehave.example.spring.security.domain.Organization)1 UserBuilder (org.jbehave.example.spring.security.domain.UserBuilder)1