use of org.jbehave.core.ConfigurableEmbedder in project jbehave-core by jbehave.
the class Embedder method reportStepdocsAsEmbeddables.
public void reportStepdocsAsEmbeddables(List<String> classNames) {
EmbedderControls embedderControls = embedderControls();
if (embedderControls.skip()) {
embedderMonitor.embeddablesSkipped(classNames);
return;
}
for (Embeddable embeddable : embeddables(classNames, classLoader())) {
if (embeddable instanceof ConfigurableEmbedder) {
ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) embeddable;
Embedder configuredEmbedder = configurableEmbedder.configuredEmbedder();
List<CandidateSteps> steps = configuredEmbedder.candidateSteps();
if (steps.isEmpty()) {
steps = configuredEmbedder.stepsFactory().createCandidateSteps();
}
reportStepdocs(configuredEmbedder.configuration(), steps);
} else {
embedderMonitor.embeddableNotConfigurable(embeddable.getClass().getName());
}
}
}
use of org.jbehave.core.ConfigurableEmbedder in project jbehave-core by jbehave.
the class AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromConfigurableEmbedder.
@Test
public void shouldCreateEmbeddableInstanceFromConfigurableEmbedder() {
AnnotationBuilder annotatedConfigurable = new AnnotationBuilder(AnnotedConfigurable.class);
Object instance = annotatedConfigurable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(ConfigurableEmbedder.class));
Embedder embedder = ((ConfigurableEmbedder) instance).configuredEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder configurable")));
assertThatStepsInstancesAre(embedder.stepsFactory().createCandidateSteps(), MySteps.class);
}
use of org.jbehave.core.ConfigurableEmbedder in project jbehave-core by jbehave.
the class AnnotationBuilderBehaviour method shouldCreateEmbeddableInstanceFromConfigurableEmbedderWithoutStepsFactory.
@Test
public void shouldCreateEmbeddableInstanceFromConfigurableEmbedderWithoutStepsFactory() {
AnnotationBuilder annotatedConfigurable = new AnnotationBuilder(AnnotedConfigurableWithoutStepsFactory.class);
Object instance = annotatedConfigurable.embeddableInstance();
assertThat(instance, Matchers.instanceOf(ConfigurableEmbedder.class));
Embedder embedder = ((ConfigurableEmbedder) instance).configuredEmbedder();
assertThat(embedder.configuration().keywords(), instanceOf(MyKeywords.class));
assertThat(embedder.metaFilters(), equalTo(asList("+embedder configurable")));
assertThatStepsInstancesAre(embedder.candidateSteps(), MySteps.class);
}
use of org.jbehave.core.ConfigurableEmbedder in project jbehave-core by jbehave.
the class AnnotationBuilder method injectEmbedder.
protected Object injectEmbedder(Embedder embedder, Class<?> annotatedClass) {
try {
Object instance = annotatedClass.newInstance();
if (instance instanceof Embeddable) {
Embeddable embeddable = (Embeddable) instance;
embeddable.useEmbedder(embedder);
}
if (instance instanceof ConfigurableEmbedder) {
ConfigurableEmbedder configurableEmbedder = (ConfigurableEmbedder) instance;
configurableEmbedder.useConfiguration(embedder.configuration());
configurableEmbedder.addSteps(embedder.candidateSteps());
configurableEmbedder.useStepsFactory(embedder.stepsFactory());
}
return instance;
} catch (Exception e) {
annotationMonitor.elementCreationFailed(annotatedClass, e);
throw new InstantiationFailed(annotatedClass, e);
}
}
Aggregations