Class ScenarioInteraction
- java.lang.Object
-
- de.telekom.test.bddwebapp.interaction.FlatInteraction
-
- de.telekom.test.bddwebapp.interaction.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.
-
-
Field Summary
Fields Modifier and Type Field Description static StringBODYstatic StringOBJECT_KEY_SEPARATORstatic StringPATH_PARAMSstatic StringQUERY_PARAMS-
Fields inherited from class de.telekom.test.bddwebapp.interaction.FlatInteraction
context, LIST_ITEM_FORMAT
-
-
Constructor Summary
Constructors Constructor Description ScenarioInteraction()
-
Method Summary
All Methods Instance Methods Concrete Methods Default Methods Modifier and Type Method Description List<Object>arrayBody()default voidclear(Enum key)default voidclear(String key)Map<String,Object>mapBody()Map<String,String>mapPathParam()Map<String,String>mapQueryParam()org.springframework.aop.framework.ProxyFactoryBeanproxiedThreadLocalTargetSourceScenarioInteraction(org.springframework.aop.target.ThreadLocalTargetSource threadLocalScenarioInteraction)default <S> Srecall(Enum key)Get some data in the interaction context.default <S> List<S>recallList(Enum key)default <S> List<S>recallList(String key)default <S> List<S>recallListOrCreateNew(Enum key)default <S> List<S>recallListOrCreateNew(String key)default <S> Map<String,S>recallMap(Enum key)default <S> Map<String,S>recallMap(String key)default <S> Map<String,S>recallMapOrCreateNew(Enum key)default <S> Map<String,S>recallMapOrCreateNew(String key)default <S> SrecallNotNull(Enum key)Get some data in the interaction context.default <S> SrecallNotNull(String key)Get some data in the interaction context.default <S> SrecallObject(Enum objectKey, String attributeKey)default <S> SrecallObject(String objectKey, String attributeKey)default <S> SrecallObjectNotNull(Enum objectKey, String attributeKey)default <S> SrecallObjectNotNull(String objectKey, String attributeKey)default voidremember(Enum key, Object value)Store some data in the interaction context for later use.voidrememberFromStoryInteraction(String key)Store some data from story interaction to the scenario interaction contextdefault voidrememberObject(Enum entityKey, String objectKey, Object value)default voidrememberObject(Enum entityKey, Map<String,Object> object)default voidrememberObject(String entityKey, String objectKey, Object value)default voidrememberObject(String entityKey, Map<String,Object> object)voidrememberObjectFromStoryInteraction(String entityKey, String objectKey)Store an object from story interaction for an specific entity in the scenario interaction context.default <S> voidrememberToList(Enum key, S value)default <S> voidrememberToList(String key, S value)voidsetStoryInteraction(StoryInteraction storyInteraction)voidstartInteraction()org.springframework.aop.target.ThreadLocalTargetSourcethreadLocalScenarioInteraction()-
Methods inherited from class de.telekom.test.bddwebapp.interaction.FlatInteraction
getContext, logAllPossibleKeysWithType, logAllPossibleKeysWithValue, recall, recallByHierarchy, remember, stopInteraction
-
-
-
-
Field Detail
-
BODY
public static final String BODY
- See Also:
- Constant Field Values
-
PATH_PARAMS
public static final String PATH_PARAMS
- See Also:
- Constant Field Values
-
QUERY_PARAMS
public static final String QUERY_PARAMS
- See Also:
- Constant Field Values
-
OBJECT_KEY_SEPARATOR
public static final String OBJECT_KEY_SEPARATOR
- See Also:
- Constant Field Values
-
-
Method Detail
-
startInteraction
public void startInteraction()
- Overrides:
startInteractionin classFlatInteraction
-
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 partobjectKey- 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 keyvalue- 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)
-
recallObjectNotNull
public default <S> S recallObjectNotNull(String objectKey, String attributeKey)
-
rememberToList
public default <S> void rememberToList(String key, S value)
-
rememberToList
public default <S> void rememberToList(Enum key, S value)
-
clear
public default void clear(String key)
-
clear
public default void clear(Enum key)
-
-