@Test public void getNoSqlTableMetaDataResourceNotFound() { when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new ResourceNotFoundException("not found")); NoSqlTableMetadataResponse result = underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest()); assertNull(result.getId()); assertNull(result.getTableStatus()); assertEquals(ResponseStatus.RESOURCE_NOT_FOUND, result.getStatus()); }
@Override public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) { try { LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.OK) .withId(describeTableResult.getTable().getTableArn()) .withTableStatus(describeTableResult.getTable().getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) { try { LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.OK) .withId(describeTableResult.getTable().getTableArn()) .withTableStatus(describeTableResult.getTable().getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) { try { LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.OK) .withId(describeTableResult.getTable().getTableArn()) .withTableStatus(describeTableResult.getTable().getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } AwsNoSqlConnector(AwsClient awsClient); }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) { try { LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.OK) .withId(describeTableResult.getTable().getTableArn()) .withTableStatus(describeTableResult.getTable().getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } AwsNoSqlConnector(AwsClient awsClient); @Override NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request); @Override NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request); @Override Platform platform(); @Override Variant variant(); }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request) { try { LOGGER.debug("Calling DynamoDB.describeTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DescribeTableResult describeTableResult = dynamoDbClient.describeTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.describeTable('{}')", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.OK) .withId(describeTableResult.getTable().getTableArn()) .withTableStatus(describeTableResult.getTable().getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableMetadataResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on describeTAble '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot get metadata for NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } AwsNoSqlConnector(AwsClient awsClient); @Override NoSqlTableMetadataResponse getNoSqlTableMetaData(NoSqlTableMetadataRequest request); @Override NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request); @Override Platform platform(); @Override Variant variant();  }