Search in sources :

Example 1 with CachingParanamer

use of com.thoughtworks.paranamer.CachingParanamer in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta.

@Test
public void shouldInvokeBeforeOrAfterStepMethodWithExpectedConvertedParametersFromMeta() throws Exception {
    // Given
    SomeSteps stepsInstance = new SomeSteps();
    StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
    stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
    // When
    Date aDate = new Date();
    when(parameterConverters.convert(anyString(), eq(Date.class))).thenReturn(aDate);
    Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithDate"), new Meta());
    StepResult stepResult = stepWithMeta.perform(null);
    // Then
    assertThat(stepResult, instanceOf(Silent.class));
    assertThat((Date) stepsInstance.args, is(aDate));
}
Also used : RegexStepMatcher(org.jbehave.core.parsers.RegexStepMatcher) StepMatcher(org.jbehave.core.parsers.StepMatcher) Meta(org.jbehave.core.model.Meta) CachingParanamer(com.thoughtworks.paranamer.CachingParanamer) Silent(org.jbehave.core.steps.AbstractStepResult.Silent) ParametrisedStep(org.jbehave.core.steps.StepCreator.ParametrisedStep) BytecodeReadingParanamer(com.thoughtworks.paranamer.BytecodeReadingParanamer) Date(java.util.Date) Test(org.junit.Test)

Example 2 with CachingParanamer

use of com.thoughtworks.paranamer.CachingParanamer in project jbehave-core by jbehave.

the class StepCreatorBehaviour method shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer.

@Test
public void shouldInvokeBeforeOrAfterStepMethodWithMetaUsingParanamer() throws Exception {
    // Given
    SomeSteps stepsInstance = new SomeSteps();
    StepCreator stepCreator = stepCreatorUsing(stepsInstance, mock(StepMatcher.class), new ParameterControls());
    stepCreator.useParanamer(new CachingParanamer(new BytecodeReadingParanamer()));
    Properties properties = new Properties();
    properties.put("theme", "shopping cart");
    // When
    Step stepWithMeta = stepCreator.createBeforeOrAfterStep(SomeSteps.methodFor("aMethodWithoutNamedAnnotation"), new Meta(properties));
    StepResult stepResult = stepWithMeta.perform(null);
    // Then
    assertThat(stepResult, instanceOf(Silent.class));
    assertThat((String) stepsInstance.args, is("shopping cart"));
}
Also used : RegexStepMatcher(org.jbehave.core.parsers.RegexStepMatcher) StepMatcher(org.jbehave.core.parsers.StepMatcher) Meta(org.jbehave.core.model.Meta) CachingParanamer(com.thoughtworks.paranamer.CachingParanamer) Silent(org.jbehave.core.steps.AbstractStepResult.Silent) ParametrisedStep(org.jbehave.core.steps.StepCreator.ParametrisedStep) Properties(java.util.Properties) BytecodeReadingParanamer(com.thoughtworks.paranamer.BytecodeReadingParanamer) Test(org.junit.Test)

Aggregations

BytecodeReadingParanamer (com.thoughtworks.paranamer.BytecodeReadingParanamer)2 CachingParanamer (com.thoughtworks.paranamer.CachingParanamer)2 Meta (org.jbehave.core.model.Meta)2 RegexStepMatcher (org.jbehave.core.parsers.RegexStepMatcher)2 StepMatcher (org.jbehave.core.parsers.StepMatcher)2 Silent (org.jbehave.core.steps.AbstractStepResult.Silent)2 ParametrisedStep (org.jbehave.core.steps.StepCreator.ParametrisedStep)2 Test (org.junit.Test)2 Date (java.util.Date)1 Properties (java.util.Properties)1