Class Template

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.assertions.Template
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.84.0 (build 5404dcf)", date="2023-06-19T16:29:55.200Z") @Stability(Stable) public class Template extends software.amazon.jsii.JsiiObject
Suite of assertions that can be run on a CDK stack.

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
    Modifier
    Constructor
    Description
    protected
    Template(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    Template(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    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.
    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.
    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
    fromJSON(Map<String,? extends Object> 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 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
    Assert that a resource of the given type and properties exists in the CloudFormation template.
    void
    Assert that the given number of resources of the given type exist in the template.
    void
    Assert that the CloudFormation template matches the given value.
    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

      @Stability(Stable) @NotNull public static Template fromStack(@NotNull Stack stack)
      Base your assertions on the CloudFormation template synthesized by a CDK Stack.

      Parameters:
      stack - the CDK Stack to run assertions on. This parameter is required.
    • fromString

      @Stability(Stable) @NotNull public static Template fromString(@NotNull String template)
      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,Object>> findConditions(@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,Object>> findConditions(@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,Object>> findMappings(@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,Object>> findMappings(@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,Object>> findOutputs(@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,Object>> findOutputs(@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,Object>> findParameters(@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,Object>> findParameters(@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,Object>> findResources(@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,Object>> findResources(@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

      @Stability(Stable) public void hasCondition(@NotNull String logicalId, @NotNull Object props)
      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 the Match 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

      @Stability(Stable) public void hasMapping(@NotNull String logicalId, @NotNull Object props)
      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 the Match 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

      @Stability(Stable) public void hasOutput(@NotNull String logicalId, @NotNull Object props)
      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 the Match 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

      @Stability(Stable) public void hasParameter(@NotNull String logicalId, @NotNull Object props)
      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 the Match 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

      @Stability(Stable) public void hasResource(@NotNull String type, @NotNull Object props)
      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 the Match 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

      @Stability(Stable) public void hasResourceProperties(@NotNull String type, @NotNull Object props)
      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 the Match.objectLike(). To configure different behavour, use other matchers in the Match 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

      @Stability(Stable) public void resourceCountIs(@NotNull String type, @NotNull Number count)
      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

      @Stability(Stable) public void templateMatches(@NotNull Object expected)
      Assert that the CloudFormation template matches the given value.

      Parameters:
      expected - the expected CloudFormation template as key-value pairs. This parameter is required.
    • toJSON

      @Stability(Stable) @NotNull public Map<String,Object> toJSON()
      The CloudFormation template deserialized into an object.