@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:35.962Z") @Stability(value=Stable) 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) |
|
Capture(Object pattern)
Initialize a new capture.
|
| Modifier and Type | Method and Description |
|---|---|
List<Object> |
asArray()
Retrieve the captured value as an array.
|
Boolean |
asBoolean()
Retrieve the captured value as a boolean.
|
Number |
asNumber()
Retrieve the captured value as a number.
|
Map<String,Object> |
asObject()
Retrieve the captured value as a JSON object.
|
String |
asString()
Retrieve the captured value as a string.
|
String |
getName()
A name for the matcher.
|
Boolean |
next()
When multiple results are captured, move the iterator to the next result.
|
MatchResult |
test(Object actual)
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=Stable)
public Capture(@Nullable
Object pattern)
pattern - a nested pattern or Matcher.@Stability(value=Stable) public Capture()
@Stability(value=Stable) @NotNull public List<Object> asArray()
An error is generated if no value is captured or if the value is not an array.
@Stability(value=Stable) @NotNull public Boolean asBoolean()
An error is generated if no value is captured or if the value is not a boolean.
@Stability(value=Stable) @NotNull public Number asNumber()
An error is generated if no value is captured or if the value is not a number.
@Stability(value=Stable) @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=Stable) @NotNull public String asString()
An error is generated if no value is captured or if the value is not a string.
@Stability(value=Stable) @NotNull public Boolean next()
@Stability(value=Stable) @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 © 2022. All rights reserved.