### Question:
DynamoDBService { public DynamoDBMapper createMapper(String account, String region, String tableName) { AWSEnvironment awsenv = new AWSEnvironment(account, region); AmazonDynamoDBClient dbclient; try { dbclient = awsSessionService.getDynamoDBClient(awsenv); } catch (AWSSecurityTokenServiceException ex) { String message = String.format("User not authorized to access credential table on account: %s in region: %s", account, region); logger.error(message, ex); throw new FideliusException(message, HttpStatus.FORBIDDEN); } catch (RuntimeException re) { String message = re.getMessage(); logger.error(message, re); throw new FideliusException(message, HttpStatus.INTERNAL_SERVER_ERROR); } DynamoDBMapperConfig config = new DynamoDBMapperConfig.Builder() .withTableNameOverride(DynamoDBMapperConfig.TableNameOverride.withTableNameReplacement(tableName)) .build(); return new DynamoDBMapper(dbclient, config); }  List<T> scanDynamoDB(DynamoDBScanExpression scanExp, Class<T> clazz, DynamoDBMapper mapper); List<T> queryDynamoDB(DynamoDBQueryExpression queryRequest, Class<T> clazz, DynamoDBMapper dynamoDBMapper); DynamoDBMapper createMapper(String account, String region, String tableName);  }### Answer:
@Test(expected = Exception.class) public void createMapperShouldFailIfDBClientFailsToCreate() throws Exception { when(awsSessionService.getDynamoDBClient(any())).thenThrow(new Exception()); dynamoDBService.createMapper("BAD_ACCOUNT_NAME", "bad_region", "table"); }
@Test public void createMapperShouldCompleteIfDBClientCreatesSuccessfully() throws Exception { when(awsSessionService.getDynamoDBClient(any())).thenReturn(new AmazonDynamoDBClient()); dynamoDBService.createMapper("some_account", "some_region", "table"); }
@Test(expected = FideliusException.class) public void createMapperShouldThrowFideliusExceptionIfCredentialAccessIsDenied() { when(awsSessionService.getDynamoDBClient(any())).thenThrow(new AWSSecurityTokenServiceException("Access Denied")); dynamoDBService.createMapper("some_account", "some_region", "table"); }