Search in sources :

Example 11 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotationsUsingInjectorWithoutParent.

@Test
public void shouldBuildConfigurationFromAnnotationsUsingInjectorWithoutParent() {
    AnnotationBuilder builderAnnotated = new GuiceAnnotationBuilder(AnnotatedUsingConfigureAndGuiceConverters.class) {

        @Override
        protected Injector createInjector(List<Module> modules) {
            return Guice.createInjector(modules);
        }
    };
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatCustomObjectIsConverted(configuration.parameterConverters());
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
    assertThatExamplesTableIsConverted(configuration.parameterConverters());
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) List(java.util.List) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Example 12 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldNotBuildContainerIfModuleNotInstantiable.

@Test
public void shouldNotBuildContainerIfModuleNotInstantiable() {
    AnnotationMonitor annotationMonitor = mock(AnnotationMonitor.class);
    AnnotationBuilder builderPrivateModule = new GuiceAnnotationBuilder(AnnotatedWithPrivateModule.class, annotationMonitor);
    assertThatStepsInstancesAre(builderPrivateModule.buildCandidateSteps());
    verify(annotationMonitor).elementCreationFailed(isA(Class.class), isA(Exception.class));
}
Also used : AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) AnnotationMonitor(org.jbehave.core.configuration.AnnotationMonitor) ParseException(java.text.ParseException) Test(org.junit.Test)

Example 13 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldBuildCandidateStepsFromAnnotationsUsingStepsAndInheritingGuiceFromParent.

@Test
public void shouldBuildCandidateStepsFromAnnotationsUsingStepsAndInheritingGuiceFromParent() {
    AnnotationBuilder builderAnnotated = new GuiceAnnotationBuilder(InheritingAnnotatedUsingSteps.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatStepsInstancesAre(builderAnnotated.buildCandidateSteps(configuration), FooSteps.class);
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 14 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldBuildCandidateStepsFromAnnotationsUsingStepsAndGuice.

@Test
public void shouldBuildCandidateStepsFromAnnotationsUsingStepsAndGuice() {
    AnnotationBuilder builderAnnotated = new GuiceAnnotationBuilder(AnnotatedUsingStepsAndGuice.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatStepsInstancesAre(builderAnnotated.buildCandidateSteps(configuration), FooSteps.class);
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) Test(org.junit.Test)

Example 15 with AnnotationBuilder

use of org.jbehave.core.configuration.AnnotationBuilder in project jbehave-core by jbehave.

the class GuiceAnnotationBuilderBehaviour method shouldBuildConfigurationFromAnnotationsUsingConfigureAndGuiceConverters.

@Test
public void shouldBuildConfigurationFromAnnotationsUsingConfigureAndGuiceConverters() {
    AnnotationBuilder builderAnnotated = new GuiceAnnotationBuilder(AnnotatedUsingConfigureAndGuiceConverters.class);
    Configuration configuration = builderAnnotated.buildConfiguration();
    assertThatCustomObjectIsConverted(configuration.parameterConverters());
    assertThatDateIsConvertedWithFormat(configuration.parameterConverters(), new SimpleDateFormat("yyyy-MM-dd"));
    assertThatExamplesTableIsConverted(configuration.parameterConverters());
}
Also used : Configuration(org.jbehave.core.configuration.Configuration) MostUsefulConfiguration(org.jbehave.core.configuration.MostUsefulConfiguration) AnnotationBuilder(org.jbehave.core.configuration.AnnotationBuilder) SimpleDateFormat(java.text.SimpleDateFormat) Test(org.junit.Test)

Aggregations

AnnotationBuilder (org.jbehave.core.configuration.AnnotationBuilder)26 Test (org.junit.Test)25 MostUsefulConfiguration (org.jbehave.core.configuration.MostUsefulConfiguration)21 Configuration (org.jbehave.core.configuration.Configuration)18 SimpleDateFormat (java.text.SimpleDateFormat)6 Keywords (org.jbehave.core.configuration.Keywords)2 SilentlyAbsorbingFailure (org.jbehave.core.failures.SilentlyAbsorbingFailure)2 LocalizedKeywords (org.jbehave.core.i18n.LocalizedKeywords)2 LoadFromURL (org.jbehave.core.io.LoadFromURL)2 RegexPrefixCapturingPatternParser (org.jbehave.core.parsers.RegexPrefixCapturingPatternParser)2 ParseException (java.text.ParseException)1 List (java.util.List)1 AnnotationMonitor (org.jbehave.core.configuration.AnnotationMonitor)1 WeldBootstrap (org.jbehave.core.configuration.weld.WeldBootstrap)1 CandidateSteps (org.jbehave.core.steps.CandidateSteps)1