Class Template
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
Typically used, as part of unit tests, to validate that the rendered CloudFormation template has expected resources and properties.
Example:
import software.amazon.awscdk.core.Stack; import software.amazon.awscdk.assertions.Template; Stack stack = new Stack(); // ... Template template = Template.fromStack(stack);
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfindConditions
(String logicalId) Get the set of matching Conditions that match the given properties in the CloudFormation template.findConditions
(String logicalId, Object props) Get the set of matching Conditions that match the given properties in the CloudFormation template.findMappings
(String logicalId) Get the set of matching Mappings that match the given properties in the CloudFormation template.findMappings
(String logicalId, Object props) Get the set of matching Mappings that match the given properties in the CloudFormation template.findOutputs
(String logicalId) Get the set of matching Outputs that match the given properties in the CloudFormation template.findOutputs
(String logicalId, Object props) Get the set of matching Outputs that match the given properties in the CloudFormation template.findParameters
(String logicalId) Get the set of matching Parameters that match the given properties in the CloudFormation template.findParameters
(String logicalId, Object props) Get the set of matching Parameters that match the given properties in the CloudFormation template.findResources
(String type) Get the set of matching resources of a given type and properties in the CloudFormation template.findResources
(String type, Object props) Get the set of matching resources of a given type and properties in the CloudFormation template.static Template
Base your assertions from an existing CloudFormation template formatted as an in-memory JSON object.static Template
Base your assertions on the CloudFormation template synthesized by a CDKStack
.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
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
templateMatches
(Object expected) Assert that the CloudFormation template matches the given value.toJSON()
The CloudFormation template deserialized into an object.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
Template
protected Template(software.amazon.jsii.JsiiObjectRef objRef) -
Template
protected Template(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
fromJSON
@Stability(Stable) @NotNull public static Template fromJSON(@NotNull Map<String, ? extends Object> template) Base your assertions from an existing CloudFormation template formatted as an in-memory JSON object.- Parameters:
template
- the CloudFormation template formatted as a nested set of records. This parameter is required.
-
fromStack
Base your assertions on the CloudFormation template synthesized by a CDKStack
.- Parameters:
stack
- the CDK Stack to run assertions on. This parameter is required.
-
fromString
Base your assertions from an existing CloudFormation template formatted as a JSON string.- Parameters:
template
- the CloudFormation template in. This parameter is required.
-
findConditions
@Stability(Stable) @NotNull public Map<String,Map<String, findConditionsObject>> (@NotNull String logicalId, @Nullable Object props) Get the set of matching Conditions that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the condition. This parameter is required.props
- by default, matches all Conditions in the template.
-
findConditions
@Stability(Stable) @NotNull public Map<String,Map<String, findConditionsObject>> (@NotNull String logicalId) Get the set of matching Conditions that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the condition. This parameter is required.
-
findMappings
@Stability(Stable) @NotNull public Map<String,Map<String, findMappingsObject>> (@NotNull String logicalId, @Nullable Object props) Get the set of matching Mappings that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the mapping. This parameter is required.props
- by default, matches all Mappings in the template.
-
findMappings
@Stability(Stable) @NotNull public Map<String,Map<String, findMappingsObject>> (@NotNull String logicalId) Get the set of matching Mappings that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the mapping. This parameter is required.
-
findOutputs
@Stability(Stable) @NotNull public Map<String,Map<String, findOutputsObject>> (@NotNull String logicalId, @Nullable Object props) Get the set of matching Outputs that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the output. This parameter is required.props
- by default, matches all Outputs in the template.
-
findOutputs
@Stability(Stable) @NotNull public Map<String,Map<String, findOutputsObject>> (@NotNull String logicalId) Get the set of matching Outputs that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the output. This parameter is required.
-
findParameters
@Stability(Stable) @NotNull public Map<String,Map<String, findParametersObject>> (@NotNull String logicalId, @Nullable Object props) Get the set of matching Parameters that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the parameter. This parameter is required.props
- by default, matches all Parameters in the template.
-
findParameters
@Stability(Stable) @NotNull public Map<String,Map<String, findParametersObject>> (@NotNull String logicalId) Get the set of matching Parameters that match the given properties in the CloudFormation template.- Parameters:
logicalId
- the name of the parameter. This parameter is required.
-
findResources
@Stability(Stable) @NotNull public Map<String,Map<String, findResourcesObject>> (@NotNull String type, @Nullable Object props) Get the set of matching resources of a given type and properties in the CloudFormation template.- Parameters:
type
- the type to match in the CloudFormation template. This parameter is required.props
- by default, matches all resources with the given type.
-
findResources
@Stability(Stable) @NotNull public Map<String,Map<String, findResourcesObject>> (@NotNull String type) Get the set of matching resources of a given type and properties in the CloudFormation template.- Parameters:
type
- the type to match in the CloudFormation template. This parameter is required.
-
hasCondition
Assert that a Condition with the given properties exists in the CloudFormation template.By default, performs partial matching on the resource, via the
Match.objectLike()
. To configure different behavour, use other matchers in theMatch
class.- Parameters:
logicalId
- the name of the mapping. This parameter is required.props
- the output as should be expected in the template. This parameter is required.
-
hasMapping
Assert that a Mapping with the given properties exists in the CloudFormation template.By default, performs partial matching on the resource, via the
Match.objectLike()
. To configure different behavour, use other matchers in theMatch
class.- Parameters:
logicalId
- the name of the mapping. This parameter is required.props
- the output as should be expected in the template. This parameter is required.
-
hasOutput
Assert that an Output with the given properties exists in the CloudFormation template.By default, performs partial matching on the resource, via the
Match.objectLike()
. To configure different behavour, use other matchers in theMatch
class.- Parameters:
logicalId
- the name of the output. This parameter is required.props
- the output as should be expected in the template. This parameter is required.
-
hasParameter
Assert that a Parameter with the given properties exists in the CloudFormation template.By default, performs partial matching on the parameter, via the
Match.objectLike()
. To configure different behavior, use other matchers in theMatch
class.- Parameters:
logicalId
- the name of the parameter. This parameter is required.props
- the parameter as should be expected in the template. This parameter is required.
-
hasResource
Assert that a resource of the given type and given definition exists in the CloudFormation template.By default, performs partial matching on the resource, via the
Match.objectLike()
. To configure different behavour, use other matchers in theMatch
class.- Parameters:
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.
-
hasResourceProperties
Assert that a resource of the given type and properties exists in the CloudFormation template.By default, performs partial matching on the
Properties
key of the resource, via theMatch.objectLike()
. To configure different behavour, use other matchers in theMatch
class.- Parameters:
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.
-
resourceCountIs
Assert that the given number of resources of the given type exist in the template.- Parameters:
type
- the resource type;. This parameter is required.count
- number of expected instances. This parameter is required.
-
templateMatches
Assert that the CloudFormation template matches the given value.- Parameters:
expected
- the expected CloudFormation template as key-value pairs. This parameter is required.
-
toJSON
The CloudFormation template deserialized into an object.
-