@Test public void shouldLookupUpdateInProgressExternalDatabaseStatus() { when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); when(describeDBInstancesResult.getDBInstances()).thenReturn(Arrays.asList(dbInstance)); when(dbInstance.getDBInstanceStatus()).thenReturn(DB_INSTANCE_STATUS_ANY); ExternalDatabaseStatus result = victim.getStatus(authenticatedContext, dbStack); assertEquals(ExternalDatabaseStatus.UPDATE_IN_PROGRESS, result); }
public ExternalDatabaseStatus getStatus(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 { describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (DBInstanceNotFoundException ex) { return ExternalDatabaseStatus.DELETED; } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .map(i -> getExternalDatabaseStatus(i.getDBInstanceStatus())) .findFirst() .get(); }
AwsRdsStatusLookupService { public ExternalDatabaseStatus getStatus(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 { describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (DBInstanceNotFoundException ex) { return ExternalDatabaseStatus.DELETED; } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .map(i -> getExternalDatabaseStatus(i.getDBInstanceStatus())) .findFirst() .get(); } }
AwsRdsStatusLookupService { public ExternalDatabaseStatus getStatus(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 { describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (DBInstanceNotFoundException ex) { return ExternalDatabaseStatus.DELETED; } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .map(i -> getExternalDatabaseStatus(i.getDBInstanceStatus())) .findFirst() .get(); }  }
AwsRdsStatusLookupService { public ExternalDatabaseStatus getStatus(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 { describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (DBInstanceNotFoundException ex) { return ExternalDatabaseStatus.DELETED; } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .map(i -> getExternalDatabaseStatus(i.getDBInstanceStatus())) .findFirst() .get(); }  ExternalDatabaseStatus getStatus(AuthenticatedContext ac, DatabaseStack dbStack); boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack); }
AwsRdsStatusLookupService { public ExternalDatabaseStatus getStatus(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 { describeDBInstancesResult = rdsClient.describeDBInstances(describeDBInstancesRequest); } catch (DBInstanceNotFoundException ex) { return ExternalDatabaseStatus.DELETED; } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } return describeDBInstancesResult.getDBInstances() .stream() .map(i -> getExternalDatabaseStatus(i.getDBInstanceStatus())) .findFirst() .get(); }  ExternalDatabaseStatus getStatus(AuthenticatedContext ac, DatabaseStack dbStack); boolean isDeleteProtectionEnabled(AuthenticatedContext ac, DatabaseStack dbStack);  }