package de.widdix.awscftemplates.operations;

import com.amazonaws.services.cloudformation.model.Parameter;
import de.widdix.awscftemplates.ACloudFormationTest;
import org.junit.Test;

public class TestTerraformState extends ACloudFormationTest {

    @Test
    public void default() {
        final String kmsStackName = "kms-" + this.random8String();
        final String terraformStateStackName = "tf-state-" + this.random8String();
        try {
            this.createStack(kmsStackName,
                    "security/kms-key.yaml",
                    new Parameter().withParameterKey("Service").withParameterValue("s3")
            );
            try {
                this.createStack(terraformStateStackName,
                        "operations/terraform-state.yaml",
                        new Parameter().withParameterKey("ParentKmsKeyStack").withParameterValue(kmsStackName),
                        new Parameter().withParameterKey("TerrformStateIdentifier").withParameterValue(terraformStateStackName),
                        new Parameter().withParameterKey("TerraformStateUserARNs").withParameterValue('arn:aws:iam::' + this.getAccount + ':root,' + System.getenv('IAM_ROLE_ARN') + ',' + this.getCallerIdentityArn()),
                        new Parameter().withParameterKey("TerraformStateAdminARNs").withParameterValue('arn:aws:iam::' + this.getAccount + ':root,' + System.getenv('IAM_ROLE_ARN') + ',' + this.getCallerIdentityArn())
                );
            } finally {
                this.deleteStack(terraformStateStackName);
            }
        } finally {
            this.deleteStack(kmsStackName);
        }
    }

}

@@ -271,14 +271,11 @@
 oid 
-defaul
+tes
 t() 
@@ -1102,33 +1102,33 @@
 hParameterValue(
-'
+%22
 arn:aws:iam::' +
@@ -1116,33 +1116,33 @@
 e(%22arn:aws:iam::
-'
+%22
  + this.getAccou
@@ -1139,35 +1139,37 @@
 s.getAccount
+()
  + 
-'
+%22
 :root,
-'
+%22
  + System.ge
@@ -1165,33 +1165,33 @@
 + System.getenv(
-'
+%22
 IAM_ROLE_ARN') +
@@ -1182,32 +1182,32 @@
 IAM_ROLE_ARN
-'
+%22
 ) + 
-','
+%22,%22
  + this.getC
@@ -1330,17 +1330,17 @@
 erValue(
-'
+%22
 arn:aws:
@@ -1344,17 +1344,17 @@
 ws:iam::
-'
+%22
  + this.
@@ -1367,19 +1367,21 @@
 ount
+()
  + 
-'
+%22
 :root,
-'
+%22
  + S
@@ -1393,17 +1393,17 @@
 .getenv(
-'
+%22
 IAM_ROLE
@@ -1410,16 +1410,16 @@
 _ARN
-'
+%22
 ) + 
-','
+%22,%22
  + t

fix Java code