@@ -0,0 +1,1959 @@
+package com.exorath.service.treasurehunt.test.dynamodb;%0A%0Aimport com.amazonaws.auth.BasicAWSCredentials;%0Aimport com.amazonaws.services.dynamodbv2.AmazonDynamoDB;%0Aimport com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient;%0Aimport com.amazonaws.services.dynamodbv2.local.main.ServerRunner;%0Aimport com.amazonaws.services.dynamodbv2.local.server.DynamoDBProxyServer;%0Aimport org.junit.rules.ExternalResource;%0A%0Aimport java.io.IOException;%0Aimport java.net.ServerSocket;%0A%0A/**%0A * Creates a local DynamoDB instance for testing.%0A * See http://stackoverflow.com/a/37780083/1807588%0A */%0Apublic class LocalDynamoDBCreationRule extends ExternalResource %7B%0A%0A%09private DynamoDBProxyServer server;%0A%09private AmazonDynamoDB amazonDynamoDB;%0A%0A%09public LocalDynamoDBCreationRule() %7B%0A%09%09// This one should be copied during test-compile time. If project's basedir does not contains a folder%0A%09%09// named 'native-libs' please try '$ mvn clean install' from command line first%0A%09%09System.setProperty(%22sqlite4java.library.path%22, %22native-libs%22);%0A%09%7D%0A%0A%09@Override%0A%09protected void before() throws Throwable %7B%0A%09%09try %7B%0A%09%09%09final String port = getAvailablePort();%0A%09%09%09this.server = ServerRunner.createServerFromCommandLineArgs(new String%5B%5D%7B%22-inMemory%22, %22-port%22, port%7D);%0A%09%09%09server.start();%0A%09%09%09amazonDynamoDB = new AmazonDynamoDBClient(new BasicAWSCredentials(%22access%22, %22secret%22));%0A%09%09%09amazonDynamoDB.setEndpoint(%22http://localhost:%22 + port);%0A%09%09%7D catch (Exception e) %7B%0A%09%09%09throw new RuntimeException(e);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09protected void after() %7B%0A%09%09if (server != null) %7B%0A%09%09%09try %7B%0A%09%09%09%09server.stop();%0A%09%09%09%7D catch (Exception e) %7B%0A%09%09%09%09throw new RuntimeException(e);%0A%09%09%09%7D%0A%09%09%7D%0A%09%7D%0A%0A%09public AmazonDynamoDB getAmazonDynamoDB() %7B%0A%09%09return amazonDynamoDB;%0A%09%7D%0A%0A%09private String getAvailablePort() %7B%0A%09%09try (final ServerSocket serverSocket = new ServerSocket(0)) %7B%0A%09%09%09return String.valueOf(serverSocket.getLocalPort());%0A%09%09%7D catch (IOException e) %7B%0A%09%09%09throw new RuntimeException(%22Available port was not found%22, e);%0A%09%09%7D%0A%09%7D%0A%7D%0A

Add test creation rule for local DynamoDB