use of com.thoughtworks.paranamer.BytecodeReadingParanamer 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));
}
use of com.thoughtworks.paranamer.BytecodeReadingParanamer 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"));
}
use of com.thoughtworks.paranamer.BytecodeReadingParanamer in project jbehave-core by jbehave.
the class CompositeStepCandidateBehaviour method shouldMatchCompositeStepsAndCreateComposedStepsUsingParanamerNamedParameters.
@Test
@Ignore("fails as perhaps Paranamer not peer of @named in respect of @composite")
public void shouldMatchCompositeStepsAndCreateComposedStepsUsingParanamerNamedParameters() {
CompositeStepsWithoutNamedAnnotation steps = new CompositeStepsWithoutNamedAnnotation();
List<StepCandidate> candidates = steps.listCandidates();
StepCandidate candidate = candidates.get(0);
candidate.useParanamer(new BytecodeReadingParanamer());
assertThat(candidate.isComposite(), is(true));
Map<String, String> namedParameters = new HashMap<>();
namedParameters.put("customer", "Mr Jones");
namedParameters.put("product", "ticket");
List<Step> composedSteps = new ArrayList<>();
candidate.addComposedSteps(composedSteps, "Given <customer> has previously bought a <product>", namedParameters, candidates);
assertThat(composedSteps.size(), equalTo(2));
for (Step step : composedSteps) {
step.perform(null);
}
assertThat(steps.loggedIn, equalTo("Mr Jones"));
assertThat(steps.added, equalTo("ticket"));
}
Aggregations