@Generated(value="jsii-pacmak/1.67.0 (build 2c027f5)", date="2022-09-19T20:26:35.964Z") @Stability(value=Stable) public class Template extends software.amazon.jsii.JsiiObject
Typically used, as part of unit tests, to validate that the rendered CloudFormation template has expected resources and properties.
Example:
import software.amazon.awscdk.Stack; import software.amazon.awscdk.assertions.Template; Stack stack = new Stack(); // ... Template template = Template.fromStack(stack);
| Modifier | Constructor and Description |
|---|---|
protected |
Template(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) |
protected |
Template(software.amazon.jsii.JsiiObjectRef objRef) |
| Modifier and Type | Method and Description |
|---|---|
Map<String,Map<String,Object>> |
findConditions(String logicalId)
Get the set of matching Conditions that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findConditions(String logicalId,
Object props)
Get the set of matching Conditions that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findMappings(String logicalId)
Get the set of matching Mappings that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findMappings(String logicalId,
Object props)
Get the set of matching Mappings that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findOutputs(String logicalId)
Get the set of matching Outputs that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findOutputs(String logicalId,
Object props)
Get the set of matching Outputs that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findParameters(String logicalId)
Get the set of matching Parameters that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findParameters(String logicalId,
Object props)
Get the set of matching Parameters that match the given properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findResources(String type)
Get the set of matching resources of a given type and properties in the CloudFormation template.
|
Map<String,Map<String,Object>> |
findResources(String type,
Object props)
Get the set of matching resources of a given type and properties in the CloudFormation template.
|
static Template |
fromJSON(Map<String,? extends Object> template)
Base your assertions from an existing CloudFormation template formatted as an in-memory JSON object.
|
static Template |
fromStack(Stack stack)
Base your assertions on the CloudFormation template synthesized by a CDK `Stack`.
|
static Template |
fromString(String template)
Base your assertions from an existing CloudFormation template formatted as a JSON string.
|
void |
hasCondition(String logicalId,
Object props)
Assert that a Condition with the given properties exists in the CloudFormation template.
|
void |
hasMapping(String logicalId,
Object props)
Assert that a Mapping with the given properties exists in the CloudFormation template.
|
void |
hasOutput(String logicalId,
Object props)
Assert that an Output with the given properties exists in the CloudFormation template.
|
void |
hasParameter(String logicalId,
Object props)
Assert that a Parameter with the given properties exists in the CloudFormation template.
|
void |
hasResource(String type,
Object props)
Assert that a resource of the given type and given definition exists in the CloudFormation template.
|
void |
hasResourceProperties(String type,
Object props)
Assert that a resource of the given type and properties exists in the CloudFormation template.
|
void |
resourceCountIs(String type,
Number count)
Assert that the given number of resources of the given type exist in the template.
|
void |
resourcePropertiesCountIs(String type,
Object props,
Number count)
Assert that the given number of resources of the given type and properties exists in the CloudFormation template.
|
void |
templateMatches(Object expected)
Assert that the CloudFormation template matches the given value.
|
Map<String,Object> |
toJSON()
The CloudFormation template deserialized into an object.
|
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetprotected Template(software.amazon.jsii.JsiiObjectRef objRef)
protected Template(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
@Stability(value=Stable) @NotNull public static Template fromJSON(@NotNull Map<String,? extends Object> template)
template - the CloudFormation template formatted as a nested set of records. This parameter is required.@Stability(value=Stable) @NotNull public static Template fromStack(@NotNull Stack stack)
stack - the CDK Stack to run assertions on. This parameter is required.@Stability(value=Stable) @NotNull public static Template fromString(@NotNull String template)
template - the CloudFormation template in. This parameter is required.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findConditions(@NotNull String logicalId, @Nullable Object props)
logicalId - the name of the condition. This parameter is required.props - by default, matches all Conditions in the template.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findConditions(@NotNull String logicalId)
logicalId - the name of the condition. This parameter is required.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findMappings(@NotNull String logicalId, @Nullable Object props)
logicalId - the name of the mapping. This parameter is required.props - by default, matches all Mappings in the template.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findMappings(@NotNull String logicalId)
logicalId - the name of the mapping. This parameter is required.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findOutputs(@NotNull String logicalId, @Nullable Object props)
logicalId - the name of the output. This parameter is required.props - by default, matches all Outputs in the template.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findOutputs(@NotNull String logicalId)
logicalId - the name of the output. This parameter is required.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findParameters(@NotNull String logicalId, @Nullable Object props)
logicalId - the name of the parameter. This parameter is required.props - by default, matches all Parameters in the template.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findParameters(@NotNull String logicalId)
logicalId - the name of the parameter. This parameter is required.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findResources(@NotNull String type, @Nullable Object props)
type - the type to match in the CloudFormation template. This parameter is required.props - by default, matches all resources with the given type.@Stability(value=Stable) @NotNull public Map<String,Map<String,Object>> findResources(@NotNull String type)
type - the type to match in the CloudFormation template. This parameter is required.@Stability(value=Stable)
public void hasCondition(@NotNull
String logicalId,
@NotNull
Object props)
By default, performs partial matching on the resource, via the Match.objectLike().
To configure different behavour, use other matchers in the Match class.
logicalId - the name of the mapping. This parameter is required.props - the output as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void hasMapping(@NotNull
String logicalId,
@NotNull
Object props)
By default, performs partial matching on the resource, via the Match.objectLike().
To configure different behavour, use other matchers in the Match class.
logicalId - the name of the mapping. This parameter is required.props - the output as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void hasOutput(@NotNull
String logicalId,
@NotNull
Object props)
By default, performs partial matching on the resource, via the Match.objectLike().
To configure different behavour, use other matchers in the Match class.
logicalId - the name of the output. This parameter is required.props - the output as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void hasParameter(@NotNull
String logicalId,
@NotNull
Object props)
By default, performs partial matching on the parameter, via the Match.objectLike().
To configure different behavior, use other matchers in the Match class.
logicalId - the name of the parameter. This parameter is required.props - the parameter as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void hasResource(@NotNull
String type,
@NotNull
Object props)
By default, performs partial matching on the resource, via the Match.objectLike().
To configure different behavour, use other matchers in the Match class.
type - the resource type;. This parameter is required.props - the entire defintion of the resource as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void hasResourceProperties(@NotNull
String type,
@NotNull
Object props)
By default, performs partial matching on the Properties key of the resource, via the
Match.objectLike(). To configure different behavour, use other matchers in the Match class.
type - the resource type;. This parameter is required.props - the 'Properties' section of the resource as should be expected in the template. This parameter is required.@Stability(value=Stable)
public void resourceCountIs(@NotNull
String type,
@NotNull
Number count)
type - the resource type;. This parameter is required.count - number of expected instances. This parameter is required.@Stability(value=Stable)
public void resourcePropertiesCountIs(@NotNull
String type,
@NotNull
Object props,
@NotNull
Number count)
type - the resource type;. This parameter is required.props - the 'Properties' section of the resource as should be expected in the template. This parameter is required.count - number of expected instances. This parameter is required.@Stability(value=Stable)
public void templateMatches(@NotNull
Object expected)
expected - the expected CloudFormation template as key-value pairs. This parameter is required.Copyright © 2022. All rights reserved.