@Test void testPotentiallyNoAccessToPerformGetQueueUrl() throws Exception { AmazonSQS amazonSqs = mock(AmazonSQS.class); AmazonServiceException exception = new QueueDoesNotExistException( "AWS.SimpleQueueService.NonExistentQueue"); exception.setErrorCode("AWS.SimpleQueueService.NonExistentQueue"); exception.setErrorMessage( "The specified queue does not exist or you do not have access to it."); String queueUrl = "noAccessGetQueueUrlName"; when(amazonSqs.getQueueUrl(new GetQueueUrlRequest(queueUrl))) .thenThrow(exception); DynamicQueueUrlDestinationResolver dynamicQueueDestinationResolver = new DynamicQueueUrlDestinationResolver( amazonSqs); try { dynamicQueueDestinationResolver.resolveDestination(queueUrl); } catch (DestinationResolutionException e) { assertThat(e.getMessage()).startsWith( "The queue does not exist or no access to perform action sqs:GetQueueUrl."); } }
@Override public String resolveDestination(String name) throws DestinationResolutionException { String queueName = name; if (this.resourceIdResolver != null) { queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (isValidQueueUrl(queueName)) { return queueName; } if (this.autoCreate) { CreateQueueResult createQueueResult = this.amazonSqs .createQueue(new CreateQueueRequest(queueName)); return createQueueResult.getQueueUrl(); } else { try { GetQueueUrlResult getQueueUrlResult = this.amazonSqs .getQueueUrl(new GetQueueUrlRequest(queueName)); return getQueueUrlResult.getQueueUrl(); } catch (QueueDoesNotExistException e) { throw toDestinationResolutionException(e); } } }
DynamicQueueUrlDestinationResolver implements DestinationResolver<String> { @Override public String resolveDestination(String name) throws DestinationResolutionException { String queueName = name; if (this.resourceIdResolver != null) { queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (isValidQueueUrl(queueName)) { return queueName; } if (this.autoCreate) { CreateQueueResult createQueueResult = this.amazonSqs .createQueue(new CreateQueueRequest(queueName)); return createQueueResult.getQueueUrl(); } else { try { GetQueueUrlResult getQueueUrlResult = this.amazonSqs .getQueueUrl(new GetQueueUrlRequest(queueName)); return getQueueUrlResult.getQueueUrl(); } catch (QueueDoesNotExistException e) { throw toDestinationResolutionException(e); } } } }
DynamicQueueUrlDestinationResolver implements DestinationResolver<String> { @Override public String resolveDestination(String name) throws DestinationResolutionException { String queueName = name; if (this.resourceIdResolver != null) { queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (isValidQueueUrl(queueName)) { return queueName; } if (this.autoCreate) { CreateQueueResult createQueueResult = this.amazonSqs .createQueue(new CreateQueueRequest(queueName)); return createQueueResult.getQueueUrl(); } else { try { GetQueueUrlResult getQueueUrlResult = this.amazonSqs .getQueueUrl(new GetQueueUrlRequest(queueName)); return getQueueUrlResult.getQueueUrl(); } catch (QueueDoesNotExistException e) { throw toDestinationResolutionException(e); } } } DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs,
			ResourceIdResolver resourceIdResolver);  DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs); }
DynamicQueueUrlDestinationResolver implements DestinationResolver<String> { @Override public String resolveDestination(String name) throws DestinationResolutionException { String queueName = name; if (this.resourceIdResolver != null) { queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (isValidQueueUrl(queueName)) { return queueName; } if (this.autoCreate) { CreateQueueResult createQueueResult = this.amazonSqs .createQueue(new CreateQueueRequest(queueName)); return createQueueResult.getQueueUrl(); } else { try { GetQueueUrlResult getQueueUrlResult = this.amazonSqs .getQueueUrl(new GetQueueUrlRequest(queueName)); return getQueueUrlResult.getQueueUrl(); } catch (QueueDoesNotExistException e) { throw toDestinationResolutionException(e); } } } DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs,
			ResourceIdResolver resourceIdResolver);  DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs); void setAutoCreate(boolean autoCreate); @Override String resolveDestination(String name); }
DynamicQueueUrlDestinationResolver implements DestinationResolver<String> { @Override public String resolveDestination(String name) throws DestinationResolutionException { String queueName = name; if (this.resourceIdResolver != null) { queueName = this.resourceIdResolver.resolveToPhysicalResourceId(name); } if (isValidQueueUrl(queueName)) { return queueName; } if (this.autoCreate) { CreateQueueResult createQueueResult = this.amazonSqs .createQueue(new CreateQueueRequest(queueName)); return createQueueResult.getQueueUrl(); } else { try { GetQueueUrlResult getQueueUrlResult = this.amazonSqs .getQueueUrl(new GetQueueUrlRequest(queueName)); return getQueueUrlResult.getQueueUrl(); } catch (QueueDoesNotExistException e) { throw toDestinationResolutionException(e); } } } DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs,
			ResourceIdResolver resourceIdResolver);  DynamicQueueUrlDestinationResolver(AmazonSQS amazonSqs); void setAutoCreate(boolean autoCreate); @Override String resolveDestination(String name);  }