@Test(expected = CloudConnectorException.class) public void isDeleteProtectionEnabledShouldThrowCloudConnectorExceptionInCaseOfAnyRuntimeException() { when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenThrow(RuntimeException.class); victim.isDeleteProtectionEnabled(authenticatedContext, dbStack); }
public boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack) { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult describeDBInstancesResult; try { LOGGER.debug("RDS Checking if delete protection is enabled"); describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .findFirst() .get().getDeletionProtection(); }
AwsRdsStatusLookupService { public boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack) { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult describeDBInstancesResult; try { LOGGER.debug("RDS Checking if delete protection is enabled"); describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .findFirst() .get().getDeletionProtection(); } }
AwsRdsStatusLookupService { public boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack) { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult describeDBInstancesResult; try { LOGGER.debug("RDS Checking if delete protection is enabled"); describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .findFirst() .get().getDeletionProtection(); }  }
AwsRdsStatusLookupService { public boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack) { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult describeDBInstancesResult; try { LOGGER.debug("RDS Checking if delete protection is enabled"); describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .findFirst() .get().getDeletionProtection(); }  ExternalDatabaseStatus getStatus(AuthenticatedContext ac, DatabaseStack dbStack); boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack); }
AwsRdsStatusLookupService { public boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack) { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); DescribeDBInstancesResult describeDBInstancesResult; try { LOGGER.debug("RDS Checking if delete protection is enabled"); describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .findFirst() .get().getDeletionProtection(); }  ExternalDatabaseStatus getStatus(AuthenticatedContext ac, DatabaseStack dbStack); boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack);  }