Class FlatInteraction

  • Direct Known Subclasses:
    ScenarioInteraction, StoryInteraction

    public class FlatInteraction
    extends Object
    Save the data flat for the test execution.

    If data is stored in this interaction, the values from maps and lists are stored recursively too. The following examples illustrate this: - remember("key", "value") = ["key", "value"] - remember("key.key", "value") = ["key.key", "value"] - remember("key", ["key": "value"]) = ["key": ["key": "value"], "key.key", "value"] - remember("key", [["key": "value"]] = ["key": ["value"], "key[0].key", "value"] Further examples can be found in @see FlatInteractionSpec.

    The advantage of this approach is the safe and fast availability of the test data, but be careful when saving large and deep maps.

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

    Copyright (c) 2022 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

      • FlatInteraction

        public FlatInteraction()
    • Method Detail

      • startInteraction

        public void startInteraction()
      • stopInteraction

        public void stopInteraction()
      • remember

        public void remember​(String key,
                             Object value)
        Store some test data in the interaction context for later use. Saves every key on every hierarchy as individual objects for lists and maps. Be careful when saving very large and deep maps as this approach increases the amount of data exponentially!
      • recall

        public <S> S recall​(String key)
        Get some data in the interaction context.
      • recallByHierarchy

        public <S> S recallByHierarchy​(String key)
        Get the value from a complex type by reflection, even in hierarchical objects. In some way the opposite way of the remember operation.
      • logAllPossibleKeysWithValue

        public void logAllPossibleKeysWithValue()
        Be careful with this method. The log can get very large. Use only for debugging purposes!
      • logAllPossibleKeysWithType

        public void logAllPossibleKeysWithType()
        Be careful with this method. The log can get very large. Use only for debugging purposes!
      • remember

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

        public default <S> S recall​(Enum key)
        Get some data in the interaction context. Use enum as key.
      • recallNotNull

        public default <S> S recallNotNull​(String key)
      • recallNotNull

        public default <S> S recallNotNull​(Enum key)
      • 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)