@Generated(value="jsii-pacmak/1.60.0 (build ebcefe6)", date="2022-06-22T23:27:49.466Z") public class Capture extends Matcher
Using an instance of this class within a Matcher will capture the matching value.
The as*()
APIs on the instance can be used to get the captured value.
Example:
// Given a template - // { // "Resources": { // "MyBar": { // "Type": "Foo::Bar", // "Properties": { // "Fred": "Flob", // } // }, // "MyBaz": { // "Type": "Foo::Bar", // "Properties": { // "Fred": "Quib", // } // } // } // } Capture fredCapture = new Capture(); template.hasResourceProperties("Foo::Bar", Map.of( "Fred", fredCapture)); fredCapture.asString(); // returns "Flob" fredCapture.next(); // returns true fredCapture.asString();
Modifier | Constructor and Description |
---|---|
|
Capture()
Initialize a new capture.
|
protected |
Capture(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Capture(software.amazon.jsii.JsiiObjectRef objRef) |
Modifier and Type | Method and Description |
---|---|
java.util.List<java.lang.Object> |
asArray()
Retrieve the captured value as an array.
|
java.lang.Boolean |
asBoolean()
Retrieve the captured value as a boolean.
|
java.lang.Number |
asNumber()
Retrieve the captured value as a number.
|
java.util.Map<java.lang.String,java.lang.Object> |
asObject()
Retrieve the captured value as a JSON object.
|
java.lang.String |
asString()
Retrieve the captured value as a string.
|
java.lang.String |
getName()
A name for the matcher.
|
java.lang.Boolean |
next()
When multiple results are captured, move the iterator to the next result.
|
MatchResult |
test(java.lang.Object actual)
Test whether a target matches the provided pattern.
|
protected Capture(software.amazon.jsii.JsiiObjectRef objRef)
protected Capture(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
public Capture()
public java.util.List<java.lang.Object> asArray()
An error is generated if no value is captured or if the value is not an array.
public java.lang.Boolean asBoolean()
An error is generated if no value is captured or if the value is not a boolean.
public java.lang.Number asNumber()
An error is generated if no value is captured or if the value is not a number.
public java.util.Map<java.lang.String,java.lang.Object> asObject()
An error is generated if no value is captured or if the value is not an object.
public java.lang.String asString()
An error is generated if no value is captured or if the value is not a string.
public java.lang.Boolean next()
public MatchResult test(java.lang.Object actual)
Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.