Class Stash

java.lang.Object
org.elasticsearch.test.rest.Stash
All Implemented Interfaces:
ToXContent, ToXContentFragment

public class Stash extends Object implements ToXContentFragment
Allows to cache the last obtained test response and or part of it within variables that can be used as input values in following requests and assertions.
  • Field Details

    • EMPTY

      public static final Stash EMPTY
  • Constructor Details

    • Stash

      public Stash()
  • Method Details

    • stashValue

      public void stashValue(String key, Object value)
      Allows to saved a specific field in the stash as key-value pair
    • clear

      public void clear()
      Clears the previously stashed values
    • containsStashedValue

      public boolean containsStashedValue(Object key)
      Tells whether a particular key needs to be looked up in the stash based on its name. Returns true if the string representation of the key either starts with $ or contains a ${...} reference. The stash contains fields eventually extracted from previous responses that can be reused as arguments for following requests (e.g. scroll_id)
    • isStashedValue

      public boolean isStashedValue(Object key)
      Tells whether a particular key represents exactly a stashed value reference. Returns true if the string representation of the key either starts with $ or consists only of a ${...} reference. Unlike containsStashedValue(java.lang.Object), returns false if the key contains an a ${...} reference within a longer string.
    • getValue

      public Object getValue(String key) throws IOException
      Retrieves a value from the current stash. The stash contains fields eventually extracted from previous responses that can be reused as arguments for following requests (e.g. scroll_id)
      Throws:
      IOException
    • replaceStashedValues

      public Map<String,Object> replaceStashedValues(Map<String,Object> map) throws IOException
      Goes recursively against each map entry and replaces any string value starting with "$" with its corresponding value retrieved from the stash
      Throws:
      IOException
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException