@Generated(value="jsii-pacmak/1.46.0 (build cd08c55)", date="2021-11-25T20:11:04.683Z") @Stability(value=Experimental) 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", "Cat"],
// "Waldo": ["Qix", "Qux"],
// }
// }
// }
// }
Capture fredCapture = new Capture();
Capture waldoCapture = new Capture();
Map<String, Object> expected = Map.of(
"Fred", fredCapture,
"Waldo", List.of("Qix", waldoCapture));
template.hasResourceProperties("Foo::Bar", expected);
fredCapture.asArray(); // returns ["Flob", "Cat"]
waldoCapture.asString();
| Modifier | Constructor and Description |
|---|---|
|
Capture() |
protected |
Capture(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Capture(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
List<Object> |
asArray()
(experimental) Retrieve the captured value as an array.
|
Boolean |
asBoolean()
(experimental) Retrieve the captured value as a boolean.
|
Number |
asNumber()
(experimental) Retrieve the captured value as a number.
|
Map<String,Object> |
asObject()
(experimental) Retrieve the captured value as a JSON object.
|
String |
asString()
(experimental) Retrieve the captured value as a string.
|
String |
getName()
(experimental) A name for the matcher.
|
MatchResult |
test(Object actual)
(experimental) Test whether a target matches the provided pattern.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Capture(software.amazon.jsii.JsiiObjectRef objRef)
protected Capture(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Experimental) public Capture()
@Stability(value=Experimental) @NotNull public List<Object> asArray()
An error is generated if no value is captured or if the value is not an array.
@Stability(value=Experimental) @NotNull public Boolean asBoolean()
An error is generated if no value is captured or if the value is not a boolean.
@Stability(value=Experimental) @NotNull public Number asNumber()
An error is generated if no value is captured or if the value is not a number.
@Stability(value=Experimental) @NotNull public Map<String,Object> asObject()
An error is generated if no value is captured or if the value is not an object.
@Stability(value=Experimental) @NotNull public String asString()
An error is generated if no value is captured or if the value is not a string.
@Stability(value=Experimental) @NotNull public MatchResult test(@NotNull Object actual)
Every Matcher must implement this method. This method will be invoked by the assertions framework. Do not call this method directly.
Copyright © 2021. All rights reserved.