### Question:
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();  }### Answer:
@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()); }
@Test public void getNoSqlTableResourceNotFound() { when(dynamoDb.deleteTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new ResourceNotFoundException("not found")); NoSqlTableDeleteResponse result = underTest.deleteNoSqlTable(new NoSqlTableDeleteRequest()); assertNull(result.getId()); assertNull(result.getTableStatus()); assertEquals(ResponseStatus.RESOURCE_NOT_FOUND, result.getStatus()); }
@Test public void getNoSqlTableAwsError() { when(dynamoDb.deleteTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new AmazonDynamoDBException("provider error")); thrown.expect(CloudConnectorException.class); thrown.expectMessage("provider error"); underTest.deleteNoSqlTable(new NoSqlTableDeleteRequest()); }