DynamoDBStatusCheckerFactory implements StatusCheckerFactory { @Override public StatusChecker create() { final String tableName = System.getProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_TABLE_NAME); if (tableName == null || tableName.isEmpty()) { LOGGER.error("Cert Store DynamoDB table name not specified"); throw new ResourceException(ResourceException.SERVICE_UNAVAILABLE, "DynamoDB table name not specified"); } return new DynamoDBStatusChecker(tableName, keyStore); }  @Override StatusChecker create();  }
@Test public void testCreate() { System.setProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_TABLE_NAME, "testTable"); DynamoDBStatusCheckerFactory dynamoDBStatusCheckerFactory = new DynamoDBStatusCheckerFactory(); StatusChecker statusChecker = dynamoDBStatusCheckerFactory.create(); assertNotNull(statusChecker); System.clearProperty(ZTSConsts.ZTS_PROP_CERT_DYNAMODB_TABLE_NAME); }
@Test public void testTableNameNotSpecified() { DynamoDBStatusCheckerFactory dynamoDBStatusCheckerFactory = new DynamoDBStatusCheckerFactory(); try { dynamoDBStatusCheckerFactory.create(); fail(); } catch (ResourceException ex) { assertEquals("ResourceException (503): DynamoDB table name not specified", ex.getMessage()); assertEquals(503, ex.getCode()); } }