@Test public void deleteNoSqlTable() { TableDescription tableDescription = new TableDescription().withTableArn(ARN).withTableStatus(DELETING_STATUS); DeleteTableResult deleteResult = new DeleteTableResult().withTableDescription(tableDescription); when(dynamoDb.deleteTable(argThat((ArgumentMatcher<String>) argument -> true))).thenReturn(deleteResult); NoSqlTableDeleteResponse result = underTest.deleteNoSqlTable(new NoSqlTableDeleteRequest()); assertEquals(ARN, result.getId()); assertEquals(DELETING_STATUS, result.getTableStatus()); assertEquals(ResponseStatus.OK, result.getStatus()); }
@Override public NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) { try { LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName()); TableDescription tableDescription = deleteTableResult.getTableDescription(); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.OK) .withId(tableDescription.getTableArn()) .withTableStatus(tableDescription.getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot delete NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) { try { LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName()); TableDescription tableDescription = deleteTableResult.getTableDescription(); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.OK) .withId(tableDescription.getTableArn()) .withTableStatus(tableDescription.getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot delete NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) { try { LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName()); TableDescription tableDescription = deleteTableResult.getTableDescription(); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.OK) .withId(tableDescription.getTableArn()) .withTableStatus(tableDescription.getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot delete NoSQL table %s. " + "Provider error message: %s", request.getTableName(), e.getErrorMessage()), e); } } AwsNoSqlConnector(AwsClient awsClient); }
AwsNoSqlConnector implements NoSqlConnector { @Override public NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) { try { LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName()); TableDescription tableDescription = deleteTableResult.getTableDescription(); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.OK) .withId(tableDescription.getTableArn()) .withTableStatus(tableDescription.getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot delete 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 NoSqlTableDeleteResponse deleteNoSqlTable(NoSqlTableDeleteRequest request) { try { LOGGER.debug("Calling DynamoDB.deleteTable('{}')", request.getTableName()); AmazonDynamoDB dynamoDbClient = getAmazonDynamoDB(request); DeleteTableResult deleteTableResult = dynamoDbClient.deleteTable(request.getTableName()); LOGGER.debug("Successfully called DynamoDB.deleteTable('{}')", request.getTableName()); TableDescription tableDescription = deleteTableResult.getTableDescription(); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.OK) .withId(tableDescription.getTableArn()) .withTableStatus(tableDescription.getTableStatus()) .build(); } catch (ResourceNotFoundException e) { LOGGER.info("DynamoDB table not found '{}'", request.getTableName()); return NoSqlTableDeleteResponse.builder() .withStatus(ResponseStatus.RESOURCE_NOT_FOUND) .build(); } catch (AmazonDynamoDBException e) { LOGGER.error(String.format("DynamoDB exception on deleteTable '%s'", request.getTableName()), e); throw new CloudConnectorException(String.format("Cannot delete 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();  }