@Test(expected = CloudConnectorException.class) public void shouldThrowCloudConnectorExceptionInCaseOfRdsClientException() throws InterruptedException, ExecutionException, TimeoutException { ArgumentCaptor<StartDBInstanceRequest> startDBInstanceRequestArgumentCaptor = ArgumentCaptor.forClass(StartDBInstanceRequest.class); when(amazonRDS.startDBInstance(startDBInstanceRequestArgumentCaptor.capture())).thenThrow(new RuntimeException()); victim.start(authenticatedContext, dbStack); }
public void start(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); StartDBInstanceRequest startDBInstanceRequest = new StartDBInstanceRequest(); startDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier); try { rdsClient.startDBInstance(startDBInstanceRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } Waiter<DescribeDBInstancesRequest> rdsWaiter = rdsClient.waiters().dBInstanceAvailable(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId()); run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS start failed"); }
AwsRdsStartService { public void start(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); StartDBInstanceRequest startDBInstanceRequest = new StartDBInstanceRequest(); startDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier); try { rdsClient.startDBInstance(startDBInstanceRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } Waiter<DescribeDBInstancesRequest> rdsWaiter = rdsClient.waiters().dBInstanceAvailable(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId()); run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS start failed"); } }
AwsRdsStartService { public void start(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); StartDBInstanceRequest startDBInstanceRequest = new StartDBInstanceRequest(); startDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier); try { rdsClient.startDBInstance(startDBInstanceRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } Waiter<DescribeDBInstancesRequest> rdsWaiter = rdsClient.waiters().dBInstanceAvailable(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId()); run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS start failed"); }  }
AwsRdsStartService { public void start(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); StartDBInstanceRequest startDBInstanceRequest = new StartDBInstanceRequest(); startDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier); try { rdsClient.startDBInstance(startDBInstanceRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } Waiter<DescribeDBInstancesRequest> rdsWaiter = rdsClient.waiters().dBInstanceAvailable(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId()); run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS start failed"); }  void start(AuthenticatedContext ac, DatabaseStack dbStack); }
AwsRdsStartService { public void start(AuthenticatedContext ac, DatabaseStack dbStack) throws ExecutionException, TimeoutException, InterruptedException { AwsCredentialView credentialView = new AwsCredentialView(ac.getCloudCredential()); String regionName = ac.getCloudContext().getLocation().getRegion().value(); AmazonRDS rdsClient = awsClient.createRdsClient(credentialView, regionName); String dbInstanceIdentifier = dbStack.getDatabaseServer().getServerId(); StartDBInstanceRequest startDBInstanceRequest = new StartDBInstanceRequest(); startDBInstanceRequest.setDBInstanceIdentifier(dbInstanceIdentifier); try { rdsClient.startDBInstance(startDBInstanceRequest); } catch (RuntimeException ex) { throw new CloudConnectorException(ex.getMessage(), ex); } Waiter<DescribeDBInstancesRequest> rdsWaiter = rdsClient.waiters().dBInstanceAvailable(); DescribeDBInstancesRequest describeDBInstancesRequest = new DescribeDBInstancesRequest().withDBInstanceIdentifier(dbInstanceIdentifier); StackCancellationCheck stackCancellationCheck = new StackCancellationCheck(ac.getCloudContext().getId()); run(rdsWaiter, describeDBInstancesRequest, stackCancellationCheck, "RDS start failed"); }  void start(AuthenticatedContext ac, DatabaseStack dbStack);  }