Class ScenarioInteraction


  • @Component
    @Scope(scopeName="prototype")
    public class ScenarioInteraction
    extends FlatInteraction
    Holds context variables that are needed in the entire JBehave Scenario.

    An Interaction is a spring bean which keeps ThreadLocal state information of a single specification execution available across different steps. The Interaction is setup and torn down before and after every specification execution.

    After a first implementation of scenario interaction by Sven Schomaker, working for Deutsche Telekom AG in 2013.

    Author:
    Daniel Keiss <daniel.keiss@telekom.de>

    Copyright (c) 2020 Daniel Keiss, Deutsche Telekom IT GmbH This file is distributed under the conditions of the Apache License, Version 2.0. For details see the file license on the toplevel.

    • Constructor Detail

      • ScenarioInteraction

        public ScenarioInteraction()
    • Method Detail

      • rememberFromStoryInteraction

        public void rememberFromStoryInteraction​(String key)
        Store some data from story interaction to the scenario interaction context
        Parameters:
        key - interaction key
      • rememberObjectFromStoryInteraction

        public void rememberObjectFromStoryInteraction​(String entityKey,
                                                       String objectKey)
        Store an object from story interaction for an specific entity in the scenario interaction context. Recall this object with recallObject().
        Parameters:
        entityKey - interaction key - entity part
        objectKey - interaction key - object part
      • threadLocalScenarioInteraction

        @Bean(destroyMethod="destroy")
        public org.springframework.aop.target.ThreadLocalTargetSource threadLocalScenarioInteraction()
      • proxiedThreadLocalTargetSourceScenarioInteraction

        @Primary
        @Bean(name="proxiedThreadLocalTargetSourceScenarioInteraction")
        public org.springframework.aop.framework.ProxyFactoryBean proxiedThreadLocalTargetSourceScenarioInteraction​(@Qualifier("threadLocalScenarioInteraction")
                                                                                                                    org.springframework.aop.target.ThreadLocalTargetSource threadLocalScenarioInteraction)
      • setStoryInteraction

        public void setStoryInteraction​(StoryInteraction storyInteraction)
      • remember

        public default void remember​(Enum key,
                                     Object value)
        Store some data in the interaction context for later use. Use enum as key.
        Parameters:
        key - interaction key
        value - interaction value
      • recall

        public default <S> S recall​(Enum key)
        Get some data in the interaction context. Use enum as key.
        Type Parameters:
        S - type for value from interaction context
        Parameters:
        key - interaction key
        Returns:
        value from interaction context
      • recallNotNull

        public default <S> S recallNotNull​(String key)
        Get some data in the interaction context. Throw assertion error if value is not found.
        Type Parameters:
        S - type for value from interaction context
        Parameters:
        key - interaction key
        Returns:
        value from interaction context
      • recallNotNull

        public default <S> S recallNotNull​(Enum key)
        Get some data in the interaction context. Throw assertion error if value is not found.
        Type Parameters:
        S - type for value from interaction context
        Parameters:
        key - interaction key
        Returns:
        value from interaction context
      • rememberObject

        public default void rememberObject​(String entityKey,
                                           String objectKey,
                                           Object value)
      • rememberObject

        public default void rememberObject​(Enum entityKey,
                                           String objectKey,
                                           Object value)
      • rememberObject

        public default void rememberObject​(String entityKey,
                                           Map<String,​Object> object)
      • rememberObject

        public default void rememberObject​(Enum entityKey,
                                           Map<String,​Object> object)
      • recallObject

        public default <S> S recallObject​(String objectKey,
                                          String attributeKey)
      • recallObjectNotNull

        public default <S> S recallObjectNotNull​(String objectKey,
                                                 String attributeKey)
      • recallObject

        public default <S> S recallObject​(Enum objectKey,
                                          String attributeKey)
      • recallObjectNotNull

        public default <S> S recallObjectNotNull​(Enum objectKey,
                                                 String attributeKey)
      • recallMap

        public default <S> Map<String,​S> recallMap​(String key)
      • recallMap

        public default <S> Map<String,​S> recallMap​(Enum key)
      • recallMapOrCreateNew

        public default <S> Map<String,​S> recallMapOrCreateNew​(String key)
      • recallMapOrCreateNew

        public default <S> Map<String,​S> recallMapOrCreateNew​(Enum key)
      • rememberToList

        public default <S> void rememberToList​(String key,
                                               S value)
      • rememberToList

        public default <S> void rememberToList​(Enum key,
                                               S value)
      • recallList

        public default <S> List<S> recallList​(String key)
      • recallList

        public default <S> List<S> recallList​(Enum key)
      • recallListOrCreateNew

        public default <S> List<S> recallListOrCreateNew​(String key)
      • recallListOrCreateNew

        public default <S> List<S> recallListOrCreateNew​(Enum key)
      • clear

        public default void clear​(String key)
      • clear

        public default void clear​(Enum key)