@Test public void testMissingAttribute() { GetQueueAttributesResult getQueueAttributesResult = new GetQueueAttributesResult(); getQueueAttributesResult.setAttributes(new HashMap<>()); doReturn(getQueueAttributesResult).when(mockAmazonSQS).getQueueAttributes(any(GetQueueAttributesRequest.class)); QueueResult result = sizeRequestProcessor.processRequest( new SQSRequestContext(mockAmazonSQS, new QueueRequest(), null)); Assert.assertFalse(result.isSuccessful()); }
@Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; }
SizeRequestProcessor implements SQSRequestProcessor { @Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; } }
SizeRequestProcessor implements SQSRequestProcessor { @Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; }  }
SizeRequestProcessor implements SQSRequestProcessor { @Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; }  @Override SQSQueueResult processRequest(SQSRequestContext sqsRequestContext); }
SizeRequestProcessor implements SQSRequestProcessor { @Override public SQSQueueResult processRequest(SQSRequestContext sqsRequestContext) { SQSQueueResult result = new SQSQueueResult(); GetQueueAttributesRequest queueAttributesRequest = new GetQueueAttributesRequest() .withQueueUrl(sqsRequestContext.getQueueURL()) .withAttributeNames( QueueAttributeName.ApproximateNumberOfMessages.name() ); GetQueueAttributesResult queueAttributesResult = sqsRequestContext.getSqsClient().getQueueAttributes(queueAttributesRequest); String messageCount = queueAttributesResult.getAttributes().get(QueueAttributeName.ApproximateNumberOfMessages.name()); result.setSuccessful(messageCount != null); result.setMessage(messageCount); return result; }  @Override SQSQueueResult processRequest(SQSRequestContext sqsRequestContext);  }