package de.widdix.awscftemplates.state;

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

public class TestDynamoDB extends ACloudFormationTest {

    @Test
    public void test() {
        final String stackName = "dynamodb-" + this.random8String();
        try {
            this.createStack(stackName,
                    "state/dynamodb.yaml",
                    new Parameter().withParameterKey("PartitionKeyName").withParameterValue("id")
            );
            // TODO how can we check if this stack works?
        } finally {
            this.deleteStack(stackName);
        }
    }

    @Test
    public void testGSI() {
        final String stackName = "dynamodb-" + this.random8String();
        try {
            this.createStack(stackName,
                    "state/dynamodb.yaml",
                    new Parameter()
                        .withParameterKey("PartitionKeyName").withParameterValue("id")
                        .withParameterKey("SortKeyName").withParameterValue("timestamp")
                        .withParameterKey("Attribute1Name").withParameterValue("organisation")
                        .withParameterKey("Attribute2Name").withParameterValue("category")
                        .withParameterKey("Index1PartitionKeyName").withParameterValue("timestamp")
                        .withParameterKey("Index2PartitionKeyName").withParameterValue("organisation")
                        .withParameterKey("Index2SortKeyName").withParameterValue("timestamp")
            );
            // TODO how can we check if this stack works?
        } finally {
            this.deleteStack(stackName);
        }
    }

}

@@ -923,33 +923,8 @@
 er()
-%0A                        
 .wit
@@ -973,32 +973,33 @@
 meterValue(%22id%22)
+,
 %0A               
@@ -995,36 +995,47 @@
                 
-    
+new Parameter()
 .withParameterKe
@@ -1074,32 +1074,33 @@
 lue(%22timestamp%22)
+,
 %0A               
@@ -1096,36 +1096,47 @@
                 
-    
+new Parameter()
 .withParameterKe
@@ -1181,32 +1181,33 @@
 (%22organisation%22)
+,
 %0A               
@@ -1203,36 +1203,47 @@
                 
-    
+new Parameter()
 .withParameterKe
@@ -1292,16 +1292,17 @@
 tegory%22)
+,
 %0A       
@@ -1306,36 +1306,47 @@
                 
-    
+new Parameter()
 .withParameterKe
@@ -1396,32 +1396,33 @@
 lue(%22timestamp%22)
+,
 %0A               
@@ -1418,36 +1418,47 @@
                 
-    
+new Parameter()
 .withParameterKe
@@ -1519,16 +1519,17 @@
 sation%22)
+,
 %0A       
@@ -1541,20 +1541,31 @@
         
-    
+new Parameter()
 .withPar
@@ -1615,25 +1615,24 @@
 rValue(%22
-timestamp
+category
 %22)%0A     

fix test (#370)