### Question:
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();  }### Answer:
@Test public void getNoSqlTableMetaDataOk() { TableDescription tableDescription = new TableDescription().withTableArn(ARN).withTableStatus(ACTIVE_STATUS); DescribeTableResult describeResult = new DescribeTableResult().withTable(tableDescription); when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenReturn(describeResult); NoSqlTableMetadataResponse result = underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest()); assertEquals(ARN, result.getId()); assertEquals(ACTIVE_STATUS, result.getTableStatus()); assertEquals(ResponseStatus.OK, result.getStatus()); }
@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()); }
@Test public void getNoSqlTableMetaDataAwsError() { when(dynamoDb.describeTable(argThat((ArgumentMatcher<String>) argument -> true))).thenThrow(new AmazonDynamoDBException("provider error")); thrown.expect(CloudConnectorException.class); thrown.expectMessage("provider error"); underTest.getNoSqlTableMetaData(new NoSqlTableMetadataRequest()); }