use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest in project cloudbreak by hortonworks.
the class AwsNoSqlConnectorTest method deleteNoSqlTable.
@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());
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentAwsFailure.
@Test
void acceptTestEnvironmentAwsFailure() {
when(cloudPlatformConnectors.get(any(), any())).thenReturn(cloudConnector);
when(cloudConnector.noSql()).thenReturn(noSql);
CloudCredential cloudCredential = new CloudCredential();
when(credentialToCloudCredentialConverter.convert(any())).thenReturn(cloudCredential);
AwsParameters awsParameters = getAwsParameters(S3GuardTableCreation.CREATE_NEW);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(createEnvironment(awsParameters)));
when(noSql.getNoSqlTableMetaData(any(NoSqlTableMetadataRequest.class))).thenReturn(NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.OK).build());
Exception exception = new CloudConnectorException(String.format("Cannot delete NoSQL table %s. " + "Provider error message: %s", DYNAMO_TABLE_NAME, "errorMessage"));
when(noSql.deleteNoSqlTable(any(NoSqlTableDeleteRequest.class))).thenThrow(exception);
underTest.accept(environmentDtoEvent);
NoSqlTableDeleteRequest request = getNoSqlTableDeleteRequest(cloudCredential);
verify(cloudPlatformConnectors).get(any(), any());
verify(noSql).deleteNoSqlTable(request);
verify(mockExceptionProcessor, times(1)).handle(any(), any(), any(), any());
verify(mockExceptionProcessor, times(1)).handle(any(HandlerFailureConjoiner.class), any(Logger.class), eq(eventSender), eq(DELETE_S3GUARD_TABLE_EVENT.selector()));
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentSuccessWhenDynamoDbTableMissingOnAwsSide.
@Test
void acceptTestEnvironmentSuccessWhenDynamoDbTableMissingOnAwsSide() {
when(cloudPlatformConnectors.get(any(), any())).thenReturn(cloudConnector);
when(cloudConnector.noSql()).thenReturn(noSql);
CloudCredential cloudCredential = new CloudCredential();
when(credentialToCloudCredentialConverter.convert(any())).thenReturn(cloudCredential);
AwsParameters awsParameters = getAwsParameters(S3GuardTableCreation.CREATE_NEW);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(createEnvironment(awsParameters)));
when(noSql.getNoSqlTableMetaData(any(NoSqlTableMetadataRequest.class))).thenReturn(NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.RESOURCE_NOT_FOUND).build());
underTest.accept(environmentDtoEvent);
NoSqlTableDeleteRequest request = getNoSqlTableDeleteRequest(cloudCredential);
verify(cloudPlatformConnectors).get(any(), any());
verify(noSql, times(0)).deleteNoSqlTable(request);
verify(eventSender).sendEvent(eventArgumentCaptor.capture(), headersArgumentCaptor.capture());
verifyEnvDeleteEvent();
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandlerTest method acceptTestEnvironmentSuccess.
@Test
void acceptTestEnvironmentSuccess() {
when(cloudPlatformConnectors.get(any(), any())).thenReturn(cloudConnector);
when(cloudConnector.noSql()).thenReturn(noSql);
CloudCredential cloudCredential = new CloudCredential();
when(credentialToCloudCredentialConverter.convert(any())).thenReturn(cloudCredential);
AwsParameters awsParameters = getAwsParameters(S3GuardTableCreation.CREATE_NEW);
when(environmentService.findEnvironmentById(ENVIRONMENT_ID)).thenReturn(Optional.of(createEnvironment(awsParameters)));
when(noSql.getNoSqlTableMetaData(any(NoSqlTableMetadataRequest.class))).thenReturn(NoSqlTableMetadataResponse.builder().withStatus(ResponseStatus.OK).build());
when(noSql.deleteNoSqlTable(any(NoSqlTableDeleteRequest.class))).thenReturn(NoSqlTableDeleteResponse.builder().withStatus(ResponseStatus.OK).build());
underTest.accept(environmentDtoEvent);
NoSqlTableDeleteRequest request = getNoSqlTableDeleteRequest(cloudCredential);
verify(cloudPlatformConnectors).get(any(), any());
verify(noSql).deleteNoSqlTable(request);
verify(eventSender).sendEvent(eventArgumentCaptor.capture(), headersArgumentCaptor.capture());
verifyEnvDeleteEvent();
}
use of com.sequenceiq.cloudbreak.cloud.model.nosql.NoSqlTableDeleteRequest in project cloudbreak by hortonworks.
the class S3GuardTableDeleteHandler method deleteNoSqlTable.
private ResponseStatus deleteNoSqlTable(LocationAwareCredential locationAwareCredential, String dynamoDbTablename) {
Credential credential = locationAwareCredential.getCredential();
String cloudPlatform = credential.getCloudPlatform();
String location = locationAwareCredential.getLocation();
NoSqlConnector noSqlConnector = getNoSqlConnector(cloudPlatform);
CloudCredential cloudCredential = credentialToCloudCredentialConverter.convert(credential);
NoSqlTableMetadataRequest noSqlTableMetadataRequest = NoSqlTableMetadataRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
NoSqlTableMetadataResponse noSqlTableMetaData = noSqlConnector.getNoSqlTableMetaData(noSqlTableMetadataRequest);
if (ResponseStatus.OK.equals(noSqlTableMetaData.getStatus())) {
NoSqlTableDeleteRequest request = NoSqlTableDeleteRequest.builder().withCloudPlatform(cloudPlatform).withCredential(cloudCredential).withRegion(location).withTableName(dynamoDbTablename).build();
NoSqlTableDeleteResponse response = noSqlConnector.deleteNoSqlTable(request);
return response.getStatus();
} else {
return ResponseStatus.OK;
}
}
Aggregations