Class MadeTable


  • public final class MadeTable
    extends Object
    A Table that can be made and dropped.

    Use it like this in your integration test:

     public class FooITCase {
       private Region region;
       private MadeTable table;
       @Before
       public void prepare() {
         this.region = new Region.Simple(..your IT credentials..);
         this.table = new MadeTable(this.region, new CreateTableRequest()...);
         this.table.createIfAbsent();
       }
       @After
       public void dropTable() {
         this.table.drop();
       }
       @Test
       public void createsAndDeletesItems() {
         Foo foo = new Foo(this.region);
         foo.doSomething();
       }
     }

    In this example, a new DynamoDB table will be created before every test method, and dropped when it's finished. This may be not the best approach performance wise, since every table creation takes at least ten seconds (at the time of writing). To speed things up a little, you can create table before the entire test case and drop when all methods are completed:

     public class FooITCase {
       private static Region region;
       private static MadeTable table;
       @BeforeClass
       public static void prepare() {
         FooITCase.region = new Region.Simple(..your IT credentials..);
         FooITCase.table = new MadeTable(
           FooITCase.region, new CreateTableRequest()...
         );
         FooITCase.table.createIfAbsent();
       }
       @AfterClass
       public static void dropTable() {
         FooITCase.table.drop();
       }
       @Test
       public void createsAndDeletesItems() {
         Foo foo = new Foo(FooITCase.region);
         foo.doSomething();
       }
     }

    You IAM user policy would look like this (XXXXX should be replaced by your AWS account number):

    {
       "Statement": [
         {
           "Action": "dynamodb:*",
           "Effect": "Allow",
           "Resource": "arn:aws:dynamodb:us-east-1:XXXXX:table/test-*"
         },
         {
           "Action": "dynamodb:ListTables",
           "Effect": "Allow",
           "Resource": "*"
         }
       ]
     }
    Since:
    0.8
    • Constructor Detail

      • MadeTable

        public MadeTable​(Region reg,
                         com.amazonaws.services.dynamodbv2.model.CreateTableRequest req)
        Public ctor.
        Parameters:
        reg - Region
        req - Request