### Question:
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);  }### Answer:
@Test public void isDeleteProtectionEnabledTest() { when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenReturn(describeDBInstancesResult); when(describeDBInstancesResult.getDBInstances()).thenReturn(Arrays.asList(dbInstance)); when(dbInstance.getDeletionProtection()).thenReturn(true); boolean result = victim.isDeleteProtectionEnabled(authenticatedContext, dbStack); assertEquals(true, result); when(dbInstance.getDeletionProtection()).thenReturn(true); result = victim.isDeleteProtectionEnabled(authenticatedContext, dbStack); when(result).thenReturn(false); }
@Test(expected = CloudConnectorException.class) public void isDeleteProtectionEnabledShouldThrowCloudConnectorExceptionInCaseOfDBInstanceNotFoundException() { when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenThrow(DBInstanceNotFoundException.class); victim.isDeleteProtectionEnabled(authenticatedContext, dbStack); fail("Exception should be been thrown"); }
@Test(expected = CloudConnectorException.class) public void isDeleteProtectionEnabledShouldThrowCloudConnectorExceptionInCaseOfAnyRuntimeException() { when(amazonRDS.describeDBInstances(any(DescribeDBInstancesRequest.class))).thenThrow(RuntimeException.class); victim.isDeleteProtectionEnabled(authenticatedContext, dbStack); }