Package org.opensearch.test.rest.yaml
Class Stash
java.lang.Object
org.opensearch.test.rest.yaml.Stash
- All Implemented Interfaces:
org.opensearch.common.xcontent.ToXContent,org.opensearch.common.xcontent.ToXContentFragment
public class Stash
extends java.lang.Object
implements org.opensearch.common.xcontent.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.
-
Nested Class Summary
-
Field Summary
-
Constructor Summary
Constructors Constructor Description Stash() -
Method Summary
Modifier and Type Method Description voidclear()Clears the previously stashed valuesbooleancontainsStashedValue(java.lang.Object key)Tells whether a particular key needs to be looked up in the stash based on its name.java.lang.ObjectgetValue(java.lang.String key)Retrieves a value from the current stash.java.util.Map<java.lang.String,java.lang.Object>replaceStashedValues(java.util.Map<java.lang.String,java.lang.Object> map)Goes recursively against each map entry and replaces any string value starting with "$" with its corresponding value retrieved from the stashvoidstashValue(java.lang.String key, java.lang.Object value)Allows to saved a specific field in the stash as key-value pairorg.opensearch.common.xcontent.XContentBuildertoXContent(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params)
-
Field Details
-
Constructor Details
-
Stash
public Stash()
-
-
Method Details
-
stashValue
public void stashValue(java.lang.String key, java.lang.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(java.lang.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 starts with "$", false otherwise The stash contains fields eventually extracted from previous responses that can be reused as arguments for following requests (e.g. scroll_id) -
getValue
public java.lang.Object getValue(java.lang.String key) throws java.io.IOExceptionRetrieves 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:
java.io.IOException
-
replaceStashedValues
public java.util.Map<java.lang.String,java.lang.Object> replaceStashedValues(java.util.Map<java.lang.String,java.lang.Object> map) throws java.io.IOExceptionGoes recursively against each map entry and replaces any string value starting with "$" with its corresponding value retrieved from the stash- Throws:
java.io.IOException
-
toXContent
public org.opensearch.common.xcontent.XContentBuilder toXContent(org.opensearch.common.xcontent.XContentBuilder builder, org.opensearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Specified by:
toXContentin interfaceorg.opensearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-